<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/arm64/include/asm/spinlock.h, branch linux-4.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.5.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.5.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2015-12-03T19:37:59Z</updated>
<entry>
<title>arm64: spinlock: serialise spin_unlock_wait against concurrent lockers</title>
<updated>2015-12-03T19:37:59Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2015-11-19T17:48:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d86b8da04dfa4771a68bdbad6c424d40f22f0d14'/>
<id>urn:sha1:d86b8da04dfa4771a68bdbad6c424d40f22f0d14</id>
<content type='text'>
Boqun Feng reported a rather nasty ordering issue with spin_unlock_wait
on architectures implementing spin_lock with LL/SC sequences and acquire
semantics:

 | CPU 1                   CPU 2                     CPU 3
 | ==================      ====================      ==============
 |                                                   spin_unlock(&amp;lock);
 |                         spin_lock(&amp;lock):
 |                           r1 = *lock; // r1 == 0;
 |                         o = READ_ONCE(object); // reordered here
 | object = NULL;
 | smp_mb();
 | spin_unlock_wait(&amp;lock);
 |                           *lock = 1;
 | smp_mb();
 | o-&gt;dead = true;
 |                         if (o) // true
 |                           BUG_ON(o-&gt;dead); // true!!

The crux of the problem is that spin_unlock_wait(&amp;lock) can return on
CPU 1 whilst CPU 2 is in the process of taking the lock. This can be
resolved by upgrading spin_unlock_wait to a LOCK operation, forcing it
to serialise against a concurrent locker and giving it acquire semantics
in the process (although it is not at all clear whether this is needed -
different callers seem to assume different things about the barrier
semantics and architectures are similarly disjoint in their
implementations of the macro).

This patch implements spin_unlock_wait using an LL/SC sequence with
acquire semantics on arm64. For v8.1 systems with the LSE atomics, the
exclusive writeback is omitted, since the spin_lock operation is
indivisible and no intermediate state can be observed.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: spinlock: fix ll/sc unlock on big-endian systems</title>
<updated>2015-07-28T13:48:00Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2015-07-28T13:48:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c1d7cd228b4b46eca1dbd9bb2c6053f477a1a6ff'/>
<id>urn:sha1:c1d7cd228b4b46eca1dbd9bb2c6053f477a1a6ff</id>
<content type='text'>
When unlocking a spinlock, we perform a read-modify-write on the owner
ticket in order to increment it and store it back with release
semantics.

In the LL/SC case, we load the 16-bit ticket using a 32-bit load and
therefore store back the wrong halfword on a big-endian system,
corrupting the lock after the first unlock and killing the system dead.

This patch fixes the unlock code to use 16-bit accessors consistently.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: locks: patch in lse instructions when supported by the CPU</title>
<updated>2015-07-27T14:28:51Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2015-02-10T03:03:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=81bb5c6420635dfd058c210bd342c29c95ccd145'/>
<id>urn:sha1:81bb5c6420635dfd058c210bd342c29c95ccd145</id>
<content type='text'>
On CPUs which support the LSE atomic instructions introduced in ARMv8.1,
it makes sense to use them in preference to ll/sc sequences.

This patch introduces runtime patching of our locking functions so that
LSE atomic instructions are used for spinlocks and rwlocks.

Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: rwlocks: don't fail trylock purely due to contention</title>
<updated>2015-07-27T13:26:34Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2015-07-22T17:25:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9511ca19dafbd503fb467d451fe331a6008f08cf'/>
<id>urn:sha1:9511ca19dafbd503fb467d451fe331a6008f08cf</id>
<content type='text'>
STXR can fail for a number of reasons, so don't fail an rwlock trylock
operation simply because the STXR reported failure.

I'm not aware of any issues with the current code, but this makes it
consistent with spin_trylock and also other architectures (e.g. arch/arm).

Reported-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64/spinlock: Replace ACCESS_ONCE READ_ONCE</title>
<updated>2014-12-18T08:54:40Z</updated>
<author>
<name>Christian Borntraeger</name>
</author>
<published>2014-11-24T09:53:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=af2e7aaed1ccf30e61af3e096ac2c7df2f2d6c2a'/>
<id>urn:sha1:af2e7aaed1ccf30e61af3e096ac2c7df2f2d6c2a</id>
<content type='text'>
ACCESS_ONCE does not work reliably on non-scalar types. For
example gcc 4.6 and 4.7 might remove the volatile tag for such
accesses during the SRA (scalar replacement of aggregates) step
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145)

Change the spinlock code to replace ACCESS_ONCE with READ_ONCE.

Signed-off-by: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Acked-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>arm64: asm: remove redundant "cc" clobbers</title>
<updated>2014-02-07T16:46:07Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2014-02-04T12:29:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=95c4189689f92fba7ecf9097173404d4928c6e9b'/>
<id>urn:sha1:95c4189689f92fba7ecf9097173404d4928c6e9b</id>
<content type='text'>
cbnz/tbnz don't update the condition flags, so remove the "cc" clobbers
from inline asm blocks that only use these instructions to implement
conditional branches.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: lockref: add support for lockless lockrefs using cmpxchg</title>
<updated>2013-10-24T14:46:34Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2013-10-09T14:54:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5686b06cea34e31ec0a549d9b5ac00776e8e8d6d'/>
<id>urn:sha1:5686b06cea34e31ec0a549d9b5ac00776e8e8d6d</id>
<content type='text'>
Our spinlocks are only 32-bit (2x16-bit tickets) and our cmpxchg can
deal with 8-bytes (as one would hope!).

This patch wires up the cmpxchg-based lockless lockref implementation
for arm64.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: locks: introduce ticket-based spinlock implementation</title>
<updated>2013-10-24T14:46:33Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2013-10-09T14:54:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=52ea2a560a9dba57fe5fd6b4726b1089751accf2'/>
<id>urn:sha1:52ea2a560a9dba57fe5fd6b4726b1089751accf2</id>
<content type='text'>
This patch introduces a ticket lock implementation for arm64, along the
same lines as the implementation for arch/arm/.

Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: spinlock: retry trylock operation if strex fails on free lock</title>
<updated>2013-06-07T16:58:31Z</updated>
<author>
<name>Catalin Marinas</name>
</author>
<published>2013-05-31T15:30:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4ecf7ccb1973fd826456b6ab1e6dfafe9023c753'/>
<id>urn:sha1:4ecf7ccb1973fd826456b6ab1e6dfafe9023c753</id>
<content type='text'>
An exclusive store instruction may fail for reasons other than lock
contention (e.g. a cache eviction during the critical section) so, in
line with other architectures using similar exclusive instructions
(alpha, mips, powerpc), retry the trylock operation if the lock appears
to be free but the strex reported failure.

Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Reported-by: Tony Thompson &lt;anthony.thompson@arm.com&gt;
Acked-by: Will Deacon &lt;will.deacon@arm.com&gt;
</content>
</entry>
<entry>
<title>arm64: atomics: fix grossly inconsistent asm constraints for exclusives</title>
<updated>2013-02-11T18:16:41Z</updated>
<author>
<name>Will Deacon</name>
</author>
<published>2013-02-04T12:12:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3a0310eb369aae985d6409d8ff1340146578e5c1'/>
<id>urn:sha1:3a0310eb369aae985d6409d8ff1340146578e5c1</id>
<content type='text'>
Our uses of inline asm constraints for atomic operations are fairly
wild and varied. We basically need to guarantee the following:

  1. Any instructions with barrier implications
     (load-acquire/store-release) have a "memory" clobber

  2. When performing exclusive accesses, the addresing mode is generated
     using the "Q" constraint

  3. Atomic blocks which use the condition flags, have a "cc" clobber

This patch addresses these concerns which, as well as fixing the
semantics of the code, stops GCC complaining about impossible asm
constraints.

Signed-off-by: Will Deacon &lt;will.deacon@arm.com&gt;
Signed-off-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
</content>
</entry>
</feed>
