[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ed3yebei.fsf@mpe.ellerman.id.au>
Date: Wed, 30 Oct 2024 10:29:09 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: "Nysal Jan K.A." <nysal@...ux.ibm.com>, Andrew Morton
<akpm@...ux-foundation.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>
Cc: Segher Boessenkool <segher@...nel.crashing.org>, Stephen Rothwell
<sfr@...b.auug.org.au>, Peter Zijlstra <peterz@...radead.org>,
linuxppc-dev@...ts.ozlabs.org, "Nysal Jan K.A." <nysal@...ux.ibm.com>,
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>, "Liam R.
Howlett" <Liam.Howlett@...cle.com>, Mark Brown <broonie@...nel.org>,
Michal Hocko <mhocko@...e.com>, Kent Overstreet
<kent.overstreet@...ux.dev>, Rick Edgecombe <rick.p.edgecombe@...el.com>,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH v2] sched/membarrier: Fix redundant load of
membarrier_state
"Nysal Jan K.A." <nysal@...ux.ibm.com> writes:
> On architectures where ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
> is not selected, sync_core_before_usermode() is a no-op.
> In membarrier_mm_sync_core_before_usermode() the compiler does not
> eliminate redundant branches and load of mm->membarrier_state
> for this case as the atomic_read() cannot be optimized away.
>
> Here's a snippet of the code generated for finish_task_switch() on powerpc
> prior to this change:
>
> 1b786c: ld r26,2624(r30) # mm = rq->prev_mm;
> .......
> 1b78c8: cmpdi cr7,r26,0
> 1b78cc: beq cr7,1b78e4 <finish_task_switch+0xd0>
> 1b78d0: ld r9,2312(r13) # current
> 1b78d4: ld r9,1888(r9) # current->mm
> 1b78d8: cmpd cr7,r26,r9
> 1b78dc: beq cr7,1b7a70 <finish_task_switch+0x25c>
> 1b78e0: hwsync
> 1b78e4: cmplwi cr7,r27,128
> .......
> 1b7a70: lwz r9,176(r26) # atomic_read(&mm->membarrier_state)
> 1b7a74: b 1b78e0 <finish_task_switch+0xcc>
Reviewed-by: Michael Ellerman <mpe@...erman.id.au>
cheers
Powered by blists - more mailing lists