Skip to content

Commit

Permalink
parisc: Remove unnecessary barriers from spinlock.h
Browse files Browse the repository at this point in the history
commit 3b885ac upstream.

Now that mb() is an instruction barrier, it will slow performance if we issue
unnecessary barriers.

The spinlock defines have a number of unnecessary barriers.  The __ldcw()
define is both a hardware and compiler barrier.  The mb() barriers in the
routines using __ldcw() serve no purpose.

The only barrier needed is the one in arch_spin_unlock().  We need to ensure
all accesses are complete prior to releasing the lock.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org # 4.0+
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
John David Anglin authored and Greg Kroah-Hartman committed Aug 24, 2018
1 parent 6d124ea commit 400db6f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions arch/parisc/include/asm/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
{
volatile unsigned int *a;

mb();
a = __ldcw_align(x);
while (__ldcw(a) == 0)
while (*a == 0)
Expand All @@ -31,27 +30,24 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *x,
local_irq_disable();
} else
cpu_relax();
mb();
}

static inline void arch_spin_unlock(arch_spinlock_t *x)
{
volatile unsigned int *a;
mb();

a = __ldcw_align(x);
*a = 1;
mb();
*a = 1;
}

static inline int arch_spin_trylock(arch_spinlock_t *x)
{
volatile unsigned int *a;
int ret;

mb();
a = __ldcw_align(x);
ret = __ldcw(a) != 0;
mb();

return ret;
}
Expand Down

0 comments on commit 400db6f

Please sign in to comment.