[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025134026.54ca0d57@canb.auug.org.au>
Date: Fri, 25 Oct 2024 13:40:26 +1100
From: Stephen Rothwell <sfr@...b.auug.org.au>
To: Michael Ellerman <mpe@...erman.id.au>
Cc: "Nysal Jan K.A." <nysal@...ux.ibm.com>, Andrew Morton
<akpm@...ux-foundation.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, linuxppc-dev@...ts.ozlabs.org, Nathan
Chancellor <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>, Kent Overstreet
<kent.overstreet@...ux.dev>, Rick Edgecombe <rick.p.edgecombe@...el.com>,
Roman Gushchin <roman.gushchin@...ux.dev>, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH] sched/membarrier: Fix redundant load of
membarrier_state
Hi Michael,
On Fri, 25 Oct 2024 11:29:38 +1100 Michael Ellerman <mpe@...erman.id.au> wrote:
>
> > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
> > index 07bb8d4181d7..042e60ab853a 100644
> > --- a/include/linux/sched/mm.h
> > +++ b/include/linux/sched/mm.h
> > @@ -540,6 +540,8 @@ enum {
> >
> > static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm)
> > {
> > + if (!IS_ENABLED(CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE))
> > + return;
> > if (current->mm != mm)
> > return;
> > if (likely(!(atomic_read(&mm->membarrier_state) &
>
> The other option would be to have a completely separate stub, eg:
>
> #ifdef CONFIG_ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
> static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm)
> {
> if (current->mm != mm)
> return;
> if (likely(!(atomic_read(&mm->membarrier_state) &
> MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE)))
> return;
> sync_core_before_usermode();
> }
> #else
> static inline void membarrier_mm_sync_core_before_usermode(struct mm_struct *mm) { }
> #endif
>
> Not sure what folks prefer.
I case it matters, in general I prefer the first as there is less code
to get out of sync and all the code still gets parsed by the compiler
whether the CONFIG option is set or not.
--
Cheers,
Stephen Rothwell
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists