lkml.org 
[lkml]   [2008]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] De-macro spin_trylock_irq, spin_trylock_irqsave, write_trylock_irqsave
On Sat, Aug 16, 2008 at 03:31:00PM +0200, Jiri Slaby wrote:
> 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?

What's so special about sparc?

If you mean compile-tested, yes, compile-tested on

sparc-allnoconfig
sparc-defconfig
sparc-smp-n-debug-n
sparc-smp-n-debug-y
sparc-smp-y-debug-n
sparc-smp-y-debug-y

> Shouldn't all that be __always_inline?

I don't know, likely nobody cares if they are inline or not.

>> --- 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:



\
 
 \ /
  Last update: 2008-08-16 22:53    [W:0.109 / U:1.132 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site