Messages in this thread Patch in this message | | | From | Chen Yu <> | Subject | [PATCH 1/2][RFC] sched/topology: Add update_domain_cpu() | Date | Tue, 7 Jul 2020 03:36:41 +0800 |
| |
Introduce update_domain_cpu(), which is a wrapper of update_top_cache_domain(). In update_domain_cpu() the cpu hotplug lock is to protect against the rebuild of sched domain, and the rcu read lock is to protect against the dereference of domain tree(rq->sd) in update_top_cache_domain(). This patch is to prepare for the next patch to update the flags of sched domain via sysctl.
No intentional functional impact.
Signed-off-by: Chen Yu <yu.c.chen@intel.com> --- include/linux/sched/topology.h | 5 +++++ kernel/sched/topology.c | 11 +++++++++++ 2 files changed, 16 insertions(+)
diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index fb11091129b3..dc81736090e3 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -161,6 +161,7 @@ cpumask_var_t *alloc_sched_domains(unsigned int ndoms); void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms); bool cpus_share_cache(int this_cpu, int that_cpu); +void update_domain_cpu(int cpu); typedef const struct cpumask *(*sched_domain_mask_f)(int cpu); typedef int (*sched_domain_flags_f)(void); @@ -214,6 +215,10 @@ static inline bool cpus_share_cache(int this_cpu, int that_cpu) return true; } +static inline void update_domain_cpu(int cpu) +{ +} + #endif /* !CONFIG_SMP */ #ifndef arch_scale_cpu_capacity diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index ba81187bb7af..495b65367a12 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -651,6 +651,17 @@ static void update_top_cache_domain(int cpu) rcu_assign_pointer(per_cpu(sd_asym_cpucapacity, cpu), sd); } +void update_domain_cpu(int cpu) +{ + /* Protect against sched domain rebuild. */ + get_online_cpus(); + /* Guard read-side sched domain dereference. */ + rcu_read_lock(); + update_top_cache_domain(cpu); + rcu_read_unlock(); + put_online_cpus(); +} + /* * Attach the domain 'sd' to 'cpu' as its base domain. Callers must * hold the hotplug lock. -- 2.17.1
| |