lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADxym3Z1w0tseWGDPM00FRtL=5ckMioo51Yna1oACW72Haaxxg@mail.gmail.com>
Date: Wed, 20 Aug 2025 10:34:12 +0800
From: Menglong Dong <menglong8.dong@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
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 8:40 PM Peter Zijlstra <peterz@...radead.org> wrote:
>
> 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.

OK! I'll comment on this part.

>
> > +     (*(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?

Yeah, much better!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ