<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/arch/powerpc/lib/qspinlock.c, branch v6.7</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.7</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.7'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2023-10-20T11:43:34+00:00</updated>
<entry>
<title>powerpc/qspinlock: Rename yield_propagate_owner tunable</title>
<updated>2023-10-20T11:43:34+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b629b541702b082d161c307c9d7d9867911fc933'/>
<id>urn:sha1:b629b541702b082d161c307c9d7d9867911fc933</id>
<content type='text'>
Rename yield_propagate_owner to yield_sleepy_owner, which better
describes what it does (what, not how).

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Reviewed-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-7-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: Propagate sleepy if previous waiter is preempted</title>
<updated>2023-10-20T11:43:34+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1e6d5f725738fff83e1c3cbdb8547142eb8820c2'/>
<id>urn:sha1:1e6d5f725738fff83e1c3cbdb8547142eb8820c2</id>
<content type='text'>
The sleepy (aka lock-owner-is-preempted) condition is propagated down
the queue by each waiter. If a waiter becomes preempted, it can no
longer propagate sleepy. To allow subsequent waiters to yield to the
lock owner, also check the lock owner in this case.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Reviewed-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-6-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: don't propagate the not-sleepy state</title>
<updated>2023-10-20T11:43:34+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fcf77d44274b96a55cc74043561a4b3151b9ad24'/>
<id>urn:sha1:fcf77d44274b96a55cc74043561a4b3151b9ad24</id>
<content type='text'>
To simplify things, don't propagate the not-sleepy condition back down
the queue. Instead, have the waiters clear their own node-&gt;sleepy when
finding the lock owner is not preempted.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Reviewed-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-5-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: propagate owner preemptedness rather than CPU number</title>
<updated>2023-10-20T11:43:34+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fd8fae50c9c6117c4e05954deab2cc515508666b'/>
<id>urn:sha1:fd8fae50c9c6117c4e05954deab2cc515508666b</id>
<content type='text'>
Rather than propagating the CPU number of the preempted lock owner,
just propagate whether the owner was preempted. Waiters must read the
lock value when yielding to it to prevent races anyway, so might as
well always load the owner CPU from the lock.

To further simplify the code, also don't propagate the -1 (or
sleepy=false in the new scheme) down the queue. Instead, have the
waiters clear it themselves when finding the lock owner is not
preempted.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Reviewed-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-4-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: stop queued waiters trying to set lock sleepy</title>
<updated>2023-10-20T11:43:34+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f6568647382c667912245c8d07aa26c9c6d4d0c8'/>
<id>urn:sha1:f6568647382c667912245c8d07aa26c9c6d4d0c8</id>
<content type='text'>
If a queued waiter notices the lock owner or the previous waiter has
been preempted, it attempts to mark the lock sleepy, but it does this
as a try-set operation using the original lock value it got when
queueing, which will become stale as the queue progresses, and the
try-set will fail. Drop this and just set the sleepy seen clock.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Reviewed-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-3-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: Fix stale propagated yield_cpu</title>
<updated>2023-10-18T10:07:21+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2023-10-16T12:43:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f9bc9bbe8afdf83412728f0b464979a72a3b9ec2'/>
<id>urn:sha1:f9bc9bbe8afdf83412728f0b464979a72a3b9ec2</id>
<content type='text'>
yield_cpu is a sample of a preempted lock holder that gets propagated
back through the queue. Queued waiters use this to yield to the
preempted lock holder without continually sampling the lock word (which
would defeat the purpose of MCS queueing by bouncing the cache line).

The problem is that yield_cpu can become stale. It can take some time to
be passed down the chain, and if any queued waiter gets preempted then
it will cease to propagate the yield_cpu to later waiters.

This can result in yielding to a CPU that no longer holds the lock,
which is bad, but particularly if it is currently in H_CEDE (idle),
then it appears to be preempted and some hypervisors (PowerVM) can
cause very long H_CONFER latencies waiting for H_CEDE wakeup. This
results in latency spikes and hard lockups on oversubscribed
partitions with lock contention.

This is a minimal fix. Before yielding to yield_cpu, sample the lock
word to confirm yield_cpu is still the owner, and bail out of it is not.

Thanks to a bunch of people who reported this and tracked down the
exact problem using tracepoints and dispatch trace logs.

Fixes: 28db61e207ea ("powerpc/qspinlock: allow propagation of yield CPU down the queue")
Cc: stable@vger.kernel.org # v6.2+
Reported-by: Srikar Dronamraju &lt;srikar@linux.vnet.ibm.com&gt;
Reported-by: Laurent Dufour &lt;ldufour@linux.ibm.com&gt;
Reported-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Debugged-by: "Nysal Jan K.A" &lt;nysal@linux.ibm.com&gt;
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Tested-by: Shrikanth Hegde &lt;sshegde@linux.vnet.ibm.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20231016124305.139923-2-npiggin@gmail.com
</content>
</entry>
<entry>
<title>powerpc: qspinlock: Enforce qnode writes prior to publishing to queue</title>
<updated>2023-06-21T05:13:57+00:00</updated>
<author>
<name>Rohan McLure</name>
<email>rmclure@linux.ibm.com</email>
</author>
<published>2023-05-10T03:31:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6f3136326ee47ae2dd5dac9306c9b08ccbc7e81e'/>
<id>urn:sha1:6f3136326ee47ae2dd5dac9306c9b08ccbc7e81e</id>
<content type='text'>
Annotate the release barrier and memory clobber (in effect, producing a
compiler barrier) in the publish_tail_cpu call. These barriers have the
effect of ensuring that qnode attributes are all written to prior to
publish the node to the waitqueue.

Even while the initial write to the 'locked' attribute is guaranteed to
terminate prior to the node being visible, KCSAN still complains that
the write is reorderable by the compiler. Issue a kcsan_release() to
inform KCSAN of the release barrier contained in publish_tail_cpu().

Signed-off-by: Rohan McLure &lt;rmclure@linux.ibm.com&gt;
Reviewed-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20230510033117.1395895-3-rmclure@linux.ibm.com

</content>
</entry>
<entry>
<title>powerpc: qspinlock: Mark accesses to qnode lock checks</title>
<updated>2023-06-21T05:13:57+00:00</updated>
<author>
<name>Rohan McLure</name>
<email>rmclure@linux.ibm.com</email>
</author>
<published>2023-05-10T03:31:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=03d44ee80eac980a869ed3d5637ed85de6fb957f'/>
<id>urn:sha1:03d44ee80eac980a869ed3d5637ed85de6fb957f</id>
<content type='text'>
The powerpc implementation of qspinlocks will both poll and spin on the
bitlock guarding a qnode. Mark these accesses with READ_ONCE to convey
to KCSAN that polling is intentional here.

Signed-off-by: Rohan McLure &lt;rmclure@linux.ibm.com&gt;
Reviewed-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://msgid.link/20230510033117.1395895-2-rmclure@linux.ibm.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: Fix 32-bit build</title>
<updated>2022-12-12T01:34:52+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2022-12-08T12:32:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=13959373e9c9021cc80730c7bd1242e07b10b328'/>
<id>urn:sha1:13959373e9c9021cc80730c7bd1242e07b10b328</id>
<content type='text'>
Some 32-bit configurations don't pull in the spin_begin/end/relax
definitions. Fix is to restore a lost include.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Fixes: 84990b169557 ("powerpc/qspinlock: add mcs queueing for contended waiters")
Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/oe-kbuild-all/202212050224.i7uh9fOh-lkp@intel.com
Link: https://lore.kernel.org/r/20221208123225.1566113-1-npiggin@gmail.com

</content>
</entry>
<entry>
<title>powerpc/qspinlock: add compile-time tuning adjustments</title>
<updated>2022-12-02T06:48:50+00:00</updated>
<author>
<name>Nicholas Piggin</name>
<email>npiggin@gmail.com</email>
</author>
<published>2022-11-26T09:59:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0b2199841a7952d01a717b465df028b40b2cf3e9'/>
<id>urn:sha1:0b2199841a7952d01a717b465df028b40b2cf3e9</id>
<content type='text'>
This adds compile-time options that allow the EH lock hint bit to be
enabled or disabled, and adds some new options that may or may not
help matters. To help with experimentation and tuning.

Signed-off-by: Nicholas Piggin &lt;npiggin@gmail.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Link: https://lore.kernel.org/r/20221126095932.1234527-18-npiggin@gmail.com

</content>
</entry>
</feed>
