All of lore.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:37:16 +0800	[thread overview]
Message-ID: <51C2BF3C.8020804@asianux.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1306191249260.4013@ionos.tec.linutronix.de>

On 06/19/2013 06:53 PM, Thomas Gleixner wrote:
> On Wed, 19 Jun 2013, Chen Gang wrote:
> 
>> > On 06/19/2013 05:59 PM, Thomas Gleixner wrote:
>>> > > I'm well aware how that works. And there is no difference whether you
>>> > > do:
>>> > > 
>>> > > 	local_irq_save(flags);
>>> > > 	spin_lock(&lock);
>>> > > or
>>> > > 	spin_lock_irqsave(&lock, flags);
>> > 
>> > if CONFIG_LOCKDEP is not defined, they are not semantically the same.
> Care to explain _your_ spinlock semantics to me?
> 
> The factual ones are:
> 
>     spin_lock_irqsave() returns with the lock held, interrupts and
>     preemption disabled. 
> 

Yes.

>     spin_lock() returns with the lock held, preemption disabled. It
>     does not affect interrupt disabled/enabled state
> 

Yes.

> So
> 	local_irq_save(flags);
> 	spin_lock(&lock);
> 
> is semantically the same as 
> 
> 	spin_lock_irqsave(&lock, flags);
> 

Yes (but reverse is NO).

> And this is completely independent of LOCKDEP.

NO.

 	spin_lock_irqsave(&lock, flags);

 is not semantically the same as

 	local_irq_save(flags);
 	spin_lock(&lock);

It depend on the spin_lock_irqsave() implementation, if the parameters
has no relation ship with each other, semantically the same.


Thanks.
-- 
Chen Gang

Asianux Corporation

  reply	other threads:[~2013-06-20  8:38 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
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 [this message]
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=51C2BF3C.8020804@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.