[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250819124008.GI4067720@noisy.programming.kicks-ass.net>
Date: Tue, 19 Aug 2025 14:40:08 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Menglong Dong <menglong8.dong@...il.com>
Cc: mingo@...hat.com, juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, vschneid@...hat.com, ast@...nel.org,
daniel@...earbox.net, john.fastabend@...il.com, andrii@...nel.org,
martin.lau@...ux.dev, eddyz87@...il.com, song@...nel.org,
yonghong.song@...ux.dev, kpsingh@...nel.org, sdf@...ichev.me,
haoluo@...gle.com, jolsa@...nel.org, simona.vetter@...ll.ch,
tzimmermann@...e.de, jani.nikula@...el.com,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH v2 2/3] sched: make migrate_enable/migrate_disable inline
On Tue, Aug 19, 2025 at 09:58:31AM +0800, Menglong Dong wrote:
> The "struct rq" is not available in include/linux/sched.h, so we can't
> access the "runqueues" with this_cpu_ptr(), as the compilation will fail
> in this_cpu_ptr() -> raw_cpu_ptr() -> __verify_pcpu_ptr():
> typeof((ptr) + 0)
>
> So we introduce the this_rq_raw() and access the runqueues with
> arch_raw_cpu_ptr() directly.
^ That, wants to be a comment near here:
> @@ -2312,4 +2315,78 @@ static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct allo
> #define alloc_tag_restore(_tag, _old) do {} while (0)
> #endif
>
> +#ifndef COMPILE_OFFSETS
> +
> +extern void __migrate_enable(void);
> +
> +struct rq;
> +DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
> +
> +#ifdef CONFIG_SMP
> +#define this_rq_raw() arch_raw_cpu_ptr(&runqueues)
> +#else
> +#define this_rq_raw() PERCPU_PTR(&runqueues)
> +#endif
Because that arch_ thing really is weird.
> + (*(unsigned int *)((void *)this_rq_raw() + RQ_nr_pinned))--;
> + (*(unsigned int *)((void *)this_rq_raw() + RQ_nr_pinned))++;
And since you did a macro anyway, why not fold that magic in there,
instead of duplicating it?
#define __this_rq_raw() ((void *)arch_raw_cpu_ptr(&runqueues))
#define this_rq_pinned() (*(unsigned int *)(__this_rq_raw() + RQ_nr_pinned))
this_rq_pinned()--;
this_rq_pinned()++;
is nicer, no?
Powered by blists - more mailing lists