From: Jiri Slaby <jirislaby@gmail.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: torvalds@osdl.org, akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] De-macro spin_trylock_irq, spin_trylock_irqsave, write_trylock_irqsave
Date: Sat, 16 Aug 2008 15:31:00 +0200 [thread overview]
Message-ID: <48A6D694.4070302@gmail.com> (raw)
In-Reply-To: <20080816095951.GA19926@martell.zuzino.mipt.ru>
On 08/16/2008 11:59 AM, Alexey Dobriyan wrote:
> 1) de-macro, remove ({ usages as side-effect,
> 2) change calling convention to not accept "flags" by value -- trylock
> functions can modify them, so by-value is misleading, and number of users
> is relatively low.
> 3) de-macro spin_trylock_irq() for a change.
Doesn't this break on sparc -- is it tested there? Shouldn't all that be
__always_inline?
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -320,26 +320,38 @@ do { \
>
> #define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock))
>
> -#define spin_trylock_irq(lock) \
> -({ \
> - local_irq_disable(); \
> - spin_trylock(lock) ? \
> - 1 : ({ local_irq_enable(); 0; }); \
> -})
> -
> -#define spin_trylock_irqsave(lock, flags) \
> -({ \
> - local_irq_save(flags); \
> - spin_trylock(lock) ? \
> - 1 : ({ local_irq_restore(flags); 0; }); \
> -})
> -
> -#define write_trylock_irqsave(lock, flags) \
> -({ \
> - local_irq_save(flags); \
> - write_trylock(lock) ? \
> - 1 : ({ local_irq_restore(flags); 0; }); \
> -})
> +static inline int spin_trylock_irq(spinlock_t *lock)
> +{
> + local_irq_disable();
> + if (spin_trylock(lock))
> + return 1;
> + else {
> + local_irq_enable();
> + return 0;
> + }
> +}
> +
> +static inline int spin_trylock_irqsave(spinlock_t *lock, unsigned long *flags)
> +{
> + local_irq_save(*flags);
> + if (spin_trylock(lock))
> + return 1;
> + else {
> + local_irq_restore(*flags);
> + return 0;
> + }
> +}
> +
> +static inline int write_trylock_irqsave(rwlock_t *lock, unsigned long *flags)
> +{
> + local_irq_save(*flags);
> + if (write_trylock(lock))
> + return 1;
> + else {
> + local_irq_restore(*flags);
> + return 0;
> + }
> +}
>
> /*
> * Pull the atomic_t declaration:
next prev parent reply other threads:[~2008-08-16 13:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 9:59 [PATCH] De-macro spin_trylock_irq, spin_trylock_irqsave, write_trylock_irqsave Alexey Dobriyan
2008-08-16 13:31 ` Jiri Slaby [this message]
2008-08-16 20:48 ` Alexey Dobriyan
2008-08-16 21:21 ` Linus Torvalds
2008-08-17 7:52 ` David Miller
2008-08-16 13:46 ` Ingo Molnar
2008-08-16 21:04 ` Alexey Dobriyan
2008-08-16 21:18 ` Johannes Weiner
2008-08-17 9:31 ` Ingo Molnar
2008-08-17 12:30 ` Johannes Weiner
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=48A6D694.4070302@gmail.com \
--to=jirislaby@gmail.com \
--cc=adobriyan@gmail.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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