Messages in this thread | | | Date | Mon, 10 Oct 2022 09:14:50 +0800 | Subject | Re: [PATCH -next] sched/core: Fix the bug that traversal in sched_group_cookie_match is wrong | From | Aubrey Li <> |
| |
On 10/8/22 10:27, Lin Shengwang wrote: > In commit 97886d9dcd86 ("sched: Migration changes for core scheduling"), > sched_group_cookie_match() was added to help finding cookie matched > group, but was inconsistent with the actual purpose. > > Using cpu_rq(cpu) instead of rq to fix the bug. > > Fixes: 97886d9dcd86 ("sched: Migration changes for core scheduling") > Signed-off-by: Lin Shengwang <linshengwang1@huawei.com> > --- > kernel/sched/sched.h | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 23c6f9f42ba1..1ba602139840 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -1182,6 +1182,14 @@ static inline bool is_migration_disabled(struct task_struct *p) > #endif > } > > +DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); > + > +#define cpu_rq(cpu) (&per_cpu(runqueues, (cpu))) > +#define this_rq() this_cpu_ptr(&runqueues) > +#define task_rq(p) cpu_rq(task_cpu(p)) > +#define cpu_curr(cpu) (cpu_rq(cpu)->curr) > +#define raw_rq() raw_cpu_ptr(&runqueues) > + > struct sched_group; > #ifdef CONFIG_SCHED_CORE > static inline struct cpumask *sched_group_span(struct sched_group *sg); > @@ -1269,7 +1277,7 @@ static inline bool sched_group_cookie_match(struct rq *rq, > return true; > > for_each_cpu_and(cpu, sched_group_span(group), p->cpus_ptr) { > - if (sched_core_cookie_match(rq, p)) > + if (sched_core_cookie_match(cpu_rq(cpu), p))> return true; > } > return false; This looks a proper fix to me. Thanks!
-Aubrey
| |