lkml.org 
[lkml]   [2019]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC 4/5] sched/toplogy: Use smp_store_release() instead of rcu_assign_pointer
Date
From: Joel Fernandes <joel@joelfernandes.org>

The scheduler's topology code seems to want to use rcu_assign_pointer()
to initialize various pointers for no apparent reason.

With a guess that what was needed here is smp_store_release(), I am
replacing it with that. This suppresses the new sparse errors caused by
an annotation check I added to rcu_assign_pointer(). Let us avoid (ab)using
RCU API and be explicit about what we want.

Fixes sparse errors:
kernel//sched/topology.c:206:1: sparse: warning: symbol
'sched_energy_mutex' was not declared. Should it be static?
kernel//sched/topology.c:207:6: sparse: warning: symbol
'sched_energy_update' was not declared. Should it be static? >>
kernel//sched/topology.c:378:9: sparse: error: incompatible types in
comparison expression (different address spaces)
kernel//sched/topology.c:387:9: sparse: error: incompatible types in
comparison expression (different address spaces)
kernel//sched/topology.c:612:9: sparse: error: incompatible types in
comparison expression (different address spaces)
kernel//sched/topology.c:615:9: sparse: error: incompatible types in
comparison expression (different address spaces)
kernel//sched/topology.c:618:9: sparse: error: incompatible types in
comparison expression (different address spaces)
kernel//sched/topology.c:621:9: sparse: error: incompatible types in
comparison expression (different address spaces)

Signed-off-by: Joel Fernandes <joel@joelfernandes.org>
---
kernel/sched/topology.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 3f35ba1d8fde..e7a424d8de8e 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -375,7 +375,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map)

/* Attach the new list of performance domains to the root domain. */
tmp = rd->pd;
- rcu_assign_pointer(rd->pd, pd);
+ smp_store_release(&rd->pd, pd);
if (tmp)
call_rcu(&tmp->rcu, destroy_perf_domain_rcu);

@@ -384,7 +384,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map)
free:
free_pd(pd);
tmp = rd->pd;
- rcu_assign_pointer(rd->pd, NULL);
+ smp_store_release(&rd->pd, NULL);
if (tmp)
call_rcu(&tmp->rcu, destroy_perf_domain_rcu);

@@ -609,19 +609,19 @@ static void update_top_cache_domain(int cpu)
sds = sd->shared;
}

- rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
+ smp_store_release(&per_cpu(sd_llc, cpu), sd);
per_cpu(sd_llc_size, cpu) = size;
per_cpu(sd_llc_id, cpu) = id;
- rcu_assign_pointer(per_cpu(sd_llc_shared, cpu), sds);
+ smp_store_release(&per_cpu(sd_llc_shared, cpu), sds);

sd = lowest_flag_domain(cpu, SD_NUMA);
- rcu_assign_pointer(per_cpu(sd_numa, cpu), sd);
+ smp_store_release(&per_cpu(sd_numa, cpu), sd);

sd = highest_flag_domain(cpu, SD_ASYM_PACKING);
- rcu_assign_pointer(per_cpu(sd_asym_packing, cpu), sd);
+ smp_store_release(&per_cpu(sd_asym_packing, cpu), sd);

sd = lowest_flag_domain(cpu, SD_ASYM_CPUCAPACITY);
- rcu_assign_pointer(per_cpu(sd_asym_cpucapacity, cpu), sd);
+ smp_store_release(&per_cpu(sd_asym_cpucapacity, cpu), sd);
}

/*
@@ -668,7 +668,7 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)

rq_attach_root(rq, rd);
tmp = rq->sd;
- rcu_assign_pointer(rq->sd, sd);
+ smp_store_release(&rq->sd, sd);
dirty_sched_domain_sysctl(cpu);
destroy_sched_domains(tmp);

--
2.21.0.rc0.258.g878e2cd30e-goog
\
 
 \ /
  Last update: 2019-02-20 05:10    [W:0.098 / U:1.796 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site