From: Peter Zijlstra <peterz@infradead.org>
To: Menglong Dong <menglong8.dong@gmail.com>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, ast@kernel.org, daniel@iogearbox.net,
john.fastabend@gmail.com, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, simona.vetter@ffwll.ch,
tzimmermann@suse.de, jani.nikula@intel.com,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2 2/3] sched: make migrate_enable/migrate_disable inline
Date: Tue, 19 Aug 2025 14:40:08 +0200 [thread overview]
Message-ID: <20250819124008.GI4067720@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250819015832.11435-3-dongml2@chinatelecom.cn>
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?
next prev parent reply other threads:[~2025-08-19 12:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 1:58 [PATCH v2 0/3] " Menglong Dong
2025-08-19 1:58 ` [PATCH v2 1/3] arch: add the macro COMPILE_OFFSETS to all the asm-offsets.c Menglong Dong
2025-08-19 1:58 ` [PATCH v2 2/3] sched: make migrate_enable/migrate_disable inline Menglong Dong
2025-08-19 12:32 ` Peter Zijlstra
2025-08-19 12:45 ` Peter Zijlstra
2025-08-19 12:49 ` Jani Nikula
2025-08-19 13:08 ` Peter Zijlstra
2025-08-20 2:32 ` Menglong Dong
2025-08-19 12:40 ` Peter Zijlstra [this message]
2025-08-20 2:34 ` Menglong Dong
2025-08-19 1:58 ` [PATCH v2 3/3] sched: fix some typos in include/linux/preempt.h Menglong Dong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250819124008.GI4067720@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=bsegall@google.com \
--cc=daniel@iogearbox.net \
--cc=dietmar.eggemann@arm.com \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=jani.nikula@intel.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong8.dong@gmail.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sdf@fomichev.me \
--cc=simona.vetter@ffwll.ch \
--cc=song@kernel.org \
--cc=tzimmermann@suse.de \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®