public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel/timer.c: using spin_lock_irqsave instead of spin_lock + local_irq_save, especially when CONFIG_LOCKDEP not defined
Date: Thu, 20 Jun 2013 16:42:31 +0800	[thread overview]
Message-ID: <51C2C077.2050900@asianux.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1306200903520.4013@ionos.tec.linutronix.de>

On 06/20/2013 03:36 PM, Thomas Gleixner wrote:
> On Thu, 20 Jun 2013, Chen Gang wrote:
>> > On 06/19/2013 06:49 PM, Thomas Gleixner wrote:
>>> > > We must do this because some architectures implement
>>> > > do_raw_spin_lock_flags() in the following way:
>>> > > 
>>> > > do_raw_spin_lock_flags(l, flags)
>>> > > {
>>> > > 	while (!arch_spin_trylock(l)) {
>>> > > 	      if (!irq_disabled_flags(flags)) {
>>> > > 	      	      arch_irq_restore(flags);
>>> > > 		      cpu_relax();
>>> > > 		      arch_irq_disable();
>>> > > 	      }
>>> > > 	}
>>> > > }
>>> > > 
>> > 
>> > For mn10300 and sparc64 (not space32), it doesn't like your demo above.
> Sigh. You're an sparc64 and mn10300 assembler expert, right?
>  

No, do you mean: "only the related expert can discuss about it" ?


>> > For powerpc and s390, it seems your demo above (although not quite
>> > precious)
> It does not matter at all whether the code is implemented exactly that
> way. What matters is that the semantics are the same.
>  

>> > For x86 and parisc, it like your demo above.
> For parisc, yes.
> 
> For x86, no. 
> 
> static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock,
>                                                   unsigned long flags)
> {
>         arch_spin_lock(lock);
> }
> 

That is one of x86 implementation, not all (please see xen implementation)


>>> > > And again. Both are semantically the same.
>>> > > 
>> > 
>> > I am not quite sure about mn10300 and sparc64.
>> > 
>> > Could you be sure about it ?
> I am sure, because I can read _and_ understand the asm code.
> 

Are you expert of them ?  ;-)

But whether you stick to or not, I do not care about it.


>> > At least, for mn10300 and sparc64, they have no duty to make sure of
>> > our using ways to be correct.
> You think that architectures can implement these functions as they
> want and see fit? No, they can't otherwise their kernel would not work
> at all. Again the semantics are what we care about, not the
> implementation. And it's totally irrelevant whether its implemented in
> C or in assembler.
> 

Of cause, it is independent with language.

>>> > > spin_lock_irqsave() semantics are:
>>> > > 
>>> > > The function returns with the lock acquired, interrupts and preemption
>>> > > disabled. Both variants do that.
>>> > > 
>>> > > The internal details whether an architecture reenables interrupts
>>> > > while spinning on a contended lock or not are completely irrelevant
>>> > > and do not affect the correctness of the code.
>> > 
>> > For API definition, it has no duty to make it correct if the user call
>> > them with informal ways, especially, the implementation is related with
>> > various architectures.
> Nonsense.
>

The word 'Nonsense' seems not quite polite.  ;-)

At least, when some one see this usage below:

   spin_lock_irqsave(&l1, flags);
   spin_unlock(&l1);
   spin_lock(&l2);
   spin_unlock_irqrestore(&l2, flags);

most of them will be amazing.


Thanks.
-- 
Chen Gang

Asianux Corporation

  reply	other threads:[~2013-06-20  8:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19  2:59 [PATCH] kernel/timer.c: using spin_lock_irqsave instead of spin_lock + local_irq_save, especially when CONFIG_LOCKDEP not defined Chen Gang
2013-06-19  8:41 ` Thomas Gleixner
2013-06-19  9:42   ` Chen Gang
2013-06-19  9:59     ` Thomas Gleixner
2013-06-19 10:07       ` Chen Gang
2013-06-19 10:49         ` Thomas Gleixner
2013-06-20  4:14           ` Chen Gang
2013-06-20  7:36             ` Thomas Gleixner
2013-06-20  8:42               ` Chen Gang [this message]
2013-06-20  9:02                 ` Thomas Gleixner
2013-06-20 10:31                   ` Chen Gang
2013-06-19 10:21       ` Chen Gang
2013-06-19 10:53         ` Thomas Gleixner
2013-06-20  8:37           ` Chen Gang
2013-06-20  9:07             ` Thomas Gleixner
2013-06-20  9:53               ` Chen Gang
2013-06-20 10:42                 ` Thomas Gleixner
2013-06-20 10:59                   ` Chen Gang
2013-06-20  9:12             ` Eric Dumazet

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=51C2C077.2050900@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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