From: Tao Zhou <tao.zhou@linux.dev>
To: Vincent Donnefort <vincent.donnefort@arm.com>
Cc: peterz@infradead.org, mingo@redhat.com,
vincent.guittot@linaro.org, linux-kernel@vger.kernel.org,
dietmar.eggemann@arm.com, valentin.schneider@arm.com,
morten.rasmussen@arm.com, chris.redpath@arm.com,
qperret@google.com, lukasz.luba@arm.com,
Tao Zhou <tao.zhou@linux.dev>
Subject: Re: [PATCH v2 1/7] sched/fair: Provide u64 read for 32-bits arch helper
Date: Tue, 18 Jan 2022 07:44:54 +0800 [thread overview]
Message-ID: <YeX/dkwAAalVFmGg@geo.homenetwork> (raw)
In-Reply-To: <YeXDLDBX2GbfSQ+S@FVFF7649Q05P>
On Mon, Jan 17, 2022 at 07:42:04PM +0000, Vincent Donnefort wrote:
> [...]
>
> > > +/*
> > > + * u64_u32_load/u64_u32_store
> > > + *
> > > + * Use a copy of a u64 value to protect against data race. This is only
> > > + * applicable for 32-bits architectures.
> > > + */
> > > +#ifdef CONFIG_64BIT
> > > +# define u64_u32_load_copy(var, copy) var
> > > +# define u64_u32_store_copy(var, copy, val) (var = val)
> > > +#else
> > > +# define u64_u32_load_copy(var, copy) \
> > > +({ \
> > > + u64 __val, __val_copy; \
> > > + do { \
> > > + __val_copy = copy; \
> > > + /* \
> > > + * paired with u64_u32_store, ordering access \
> > > + * to var and copy. \
> > > + */ \
> > > + smp_rmb(); \
> > > + __val = var; \
> > > + } while (__val != __val_copy); \
> > > + __val; \
> > > +})
> > > +# define u64_u32_store_copy(var, copy, val) \
> > > +do { \
> > > + typeof(val) __val = (val); \
> > > + var = __val; \
> > > + /* \
> > > + * paired with u64_u32_load, ordering access to var and \
> > > + * copy. \
> > > + */ \
> > > + smp_wmb(); \
> > > + copy = __val; \
> > > +} while (0)
> >
> > Code stay there some time from me. Just from my crude review;
> > The above macro need a variable to load @var temporarily for
> > later store; that means the @copy value is from @var not @val.
> >
> > # define u64_u32_store_copy(var, copy, val) \
> > do { \
> > typeof(val) __val = (val), __var = (var); \
> > var = __val; \
> > /* \
> > * paired with u64_u32_load, ordering access to var and \
> > * copy. \
> > */ \
> > smp_wmb(); \
> > copy = __var; \
> > } while (0)
>
>
> Hi Tao,
>
> __var would then contain the previous value of @var, wouldn't it? We need
> both @var and @copy to be equal to @val.
Sorry for the noise, I'm wrong here.
>
> >
> >
> >
> > Thanks,
> > Tao
next prev parent reply other threads:[~2022-01-17 23:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 16:12 [PATCH v2 0/7] feec() energy margin removal Vincent Donnefort
2022-01-12 16:12 ` [PATCH v2 1/7] sched/fair: Provide u64 read for 32-bits arch helper Vincent Donnefort
2022-01-17 16:11 ` Tao Zhou
2022-01-17 19:42 ` Vincent Donnefort
2022-01-17 23:44 ` Tao Zhou [this message]
2022-01-12 16:12 ` [PATCH v2 2/7] sched/fair: Decay task PELT values during migration Vincent Donnefort
2022-01-17 17:31 ` Vincent Guittot
2022-01-18 10:56 ` Vincent Donnefort
2022-01-19 9:54 ` Vincent Guittot
2022-01-19 11:59 ` Vincent Donnefort
2022-01-19 13:22 ` Vincent Guittot
2022-01-20 21:12 ` Vincent Donnefort
2022-01-21 15:27 ` Vincent Guittot
2022-01-12 16:12 ` [PATCH v2 3/7] sched, drivers: Remove max param from effective_cpu_util()/sched_cpu_util() Vincent Donnefort
2022-01-12 16:12 ` [PATCH v2 4/7] sched/fair: Rename select_idle_mask to select_rq_mask Vincent Donnefort
2022-01-12 16:12 ` [PATCH v2 5/7] sched/fair: Use the same cpumask per-PD throughout find_energy_efficient_cpu() Vincent Donnefort
2022-01-12 16:12 ` [PATCH v2 6/7] sched/fair: Remove task_util from effective utilization in feec() Vincent Donnefort
2022-01-17 13:17 ` Dietmar Eggemann
2022-01-18 9:46 ` Vincent Donnefort
2022-01-12 16:12 ` [PATCH v2 7/7] sched/fair: Remove the energy margin " Vincent Donnefort
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=YeX/dkwAAalVFmGg@geo.homenetwork \
--to=tao.zhou@linux.dev \
--cc=chris.redpath@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=qperret@google.com \
--cc=valentin.schneider@arm.com \
--cc=vincent.donnefort@arm.com \
--cc=vincent.guittot@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).