diff options
author | Paul E. McKenney <paulmck@kernel.org> | 2022-01-28 00:20:49 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2022-04-12 01:52:30 +0300 |
commit | 46470cf85d2b61abd37c6f66c4dacc1bc510d10f (patch) | |
tree | 3f1adb38825845064a15ba7207f77ebda159db9b /include/linux/srcutree.h | |
parent | 4a230f8046454df18139ed1232f1a1e8a6dd36c5 (diff) | |
download | linux-46470cf85d2b61abd37c6f66c4dacc1bc510d10f.tar.xz |
srcu: Prevent cleanup_srcu_struct() from freeing non-dynamic ->sda
When an srcu_struct structure is created (but not in a kernel module)
by DEFINE_SRCU() and friends, the per-CPU srcu_data structure is
statically allocated. In all other cases, that structure is obtained
from alloc_percpu(), in which case cleanup_srcu_struct() must invoke
free_percpu() on the resulting ->sda pointer in the srcu_struct pointer.
Which it does.
Except that it also invokes free_percpu() on the ->sda pointer
referencing the statically allocated per-CPU srcu_data structures.
Which free_percpu() is surprisingly OK with.
This commit nevertheless stops cleanup_srcu_struct() from freeing
statically allocated per-CPU srcu_data structures.
Co-developed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Signed-off-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'include/linux/srcutree.h')
-rw-r--r-- | include/linux/srcutree.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h index 44e998643f48..44bd204498a1 100644 --- a/include/linux/srcutree.h +++ b/include/linux/srcutree.h @@ -73,6 +73,7 @@ struct srcu_struct { unsigned long srcu_gp_seq_needed_exp; /* Furthest future exp GP. */ unsigned long srcu_last_gp_end; /* Last GP end timestamp (ns) */ struct srcu_data __percpu *sda; /* Per-CPU srcu_data array. */ + bool sda_is_static; /* May ->sda be passed to free_percpu()? */ unsigned long srcu_barrier_seq; /* srcu_barrier seq #. */ struct mutex srcu_barrier_mutex; /* Serialize barrier ops. */ struct completion srcu_barrier_completion; |