mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
srcutree: Make init_srcu_struct_atomic() prevent transition to big
The is_atomic parameter of init_srcu_struct_fields() exists so that atomic SRCU never transitions to big, but neither init_srcu_struct_atomic() nor its lockdep counterpart __init_srcu_struct_atomic() sets it. On systems where srcutree.convert_to_big selects SRCU_SIZING_INIT, this needlessly allocates a full srcu_node combining tree for any dynamically initialized atomic srcu_struct, despite atomic SRCU having neither callbacks nor srcu_barrier() operations. Pass true from both atomic entry points, adding an is_atomic parameter to __init_srcu_struct_common(). Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
cc7287f9ee
commit
cbd520f619
|
|
@ -305,26 +305,27 @@ static int init_srcu_struct_fields(struct srcu_struct *ssp, bool is_static, bool
|
|||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
|
||||
static int
|
||||
__init_srcu_struct_common(struct srcu_struct *ssp, const char *name, struct lock_class_key *key)
|
||||
__init_srcu_struct_common(struct srcu_struct *ssp, const char *name,
|
||||
struct lock_class_key *key, bool is_atomic)
|
||||
{
|
||||
/* Don't re-initialize a lock while it is held. */
|
||||
debug_check_no_locks_freed((void *)ssp, sizeof(*ssp));
|
||||
lockdep_init_map(&ssp->dep_map, name, key, 0);
|
||||
return init_srcu_struct_fields(ssp, false, false);
|
||||
return init_srcu_struct_fields(ssp, false, is_atomic);
|
||||
}
|
||||
|
||||
int init_srcu_struct_lockdep(struct srcu_struct *ssp, const char *name,
|
||||
struct lock_class_key *key)
|
||||
{
|
||||
ssp->srcu_reader_flavor = 0;
|
||||
return __init_srcu_struct_common(ssp, name, key);
|
||||
return __init_srcu_struct_common(ssp, name, key, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(init_srcu_struct_lockdep);
|
||||
|
||||
int __init_srcu_struct_fast(struct srcu_struct *ssp, const char *name, struct lock_class_key *key)
|
||||
{
|
||||
ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_FAST;
|
||||
return __init_srcu_struct_common(ssp, name, key);
|
||||
return __init_srcu_struct_common(ssp, name, key, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__init_srcu_struct_fast);
|
||||
|
||||
|
|
@ -332,14 +333,14 @@ int __init_srcu_struct_fast_updown(struct srcu_struct *ssp, const char *name,
|
|||
struct lock_class_key *key)
|
||||
{
|
||||
ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_FAST_UPDOWN;
|
||||
return __init_srcu_struct_common(ssp, name, key);
|
||||
return __init_srcu_struct_common(ssp, name, key, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__init_srcu_struct_fast_updown);
|
||||
|
||||
int __init_srcu_struct_atomic(struct srcu_struct *ssp, const char *name, struct lock_class_key *key)
|
||||
{
|
||||
ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_ATOMIC;
|
||||
return __init_srcu_struct_common(ssp, name, key);
|
||||
return __init_srcu_struct_common(ssp, name, key, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__init_srcu_struct_atomic);
|
||||
|
||||
|
|
@ -414,7 +415,7 @@ EXPORT_SYMBOL_GPL(init_srcu_struct_fast_updown);
|
|||
int init_srcu_struct_atomic(struct srcu_struct *ssp)
|
||||
{
|
||||
ssp->srcu_reader_flavor = SRCU_READ_FLAVOR_ATOMIC;
|
||||
return init_srcu_struct_fields(ssp, false, false);
|
||||
return init_srcu_struct_fields(ssp, false, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(init_srcu_struct_atomic);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user