From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: locks: remove opencoded #16 for ticket shift
Date: Tue, 16 Jul 2013 17:35:28 +0100 [thread overview]
Message-ID: <20130716163528.GC3428@localhost.localdomain> (raw)
In-Reply-To: <1373894879-30559-1-git-send-email-will.deacon@arm.com>
On Mon, Jul 15, 2013 at 02:27:59PM +0100, Will Deacon wrote:
> The ticket width of our spinlocks is defined by TICKET_SHIFT, so remove
> the opencoded #16 from the trylock implementation.
>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm/include/asm/spinlock.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
> index f8b8965..fa3ccce 100644
> --- a/arch/arm/include/asm/spinlock.h
> +++ b/arch/arm/include/asm/spinlock.h
> @@ -104,11 +104,11 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
> __asm__ __volatile__(
> " ldrex %0, [%3]\n"
> " mov %2, #0\n"
> - " subs %1, %0, %0, ror #16\n"
> - " addeq %0, %0, %4\n"
> + " subs %1, %0, %0, ror %4\n"
> + " addeq %0, %0, %5\n"
%5! Argh.
> " strexeq %2, %0, [%3]"
> : "=&r" (slock), "=&r" (contended), "=r" (res)
> - : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
> + : "r" (&lock->slock), "I" (TICKET_SHIFT), "I" (1 << TICKET_SHIFT)
I guess that should work.
Strictly speaking, "M" is the right constraint to use for explicit shift
counts, though it won't make much difference in practice.
(Unless it ICEs the compiler for you ... seems to work on the 4.6.3
GCC I have here.)
Cheers
---Dave
> : "cc");
> } while (res);
>
> --
> 1.8.2.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2013-07-16 16:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-15 13:27 [PATCH] ARM: locks: remove opencoded #16 for ticket shift Will Deacon
2013-07-16 16:35 ` Dave Martin [this message]
2013-07-17 13:56 ` Nicolas Pitre
2013-07-18 17:21 ` Will Deacon
2013-07-18 17:53 ` Nicolas Pitre
2013-07-19 9:05 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130716163528.GC3428@localhost.localdomain \
--to=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).