From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756083Ab3FTIiK (ORCPT ); Thu, 20 Jun 2013 04:38:10 -0400 Received: from intranet.asianux.com ([58.214.24.6]:22586 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755028Ab3FTIiH (ORCPT ); Thu, 20 Jun 2013 04:38:07 -0400 X-Spam-Score: -100.8 Message-ID: <51C2BF3C.8020804@asianux.com> Date: Thu, 20 Jun 2013 16:37:16 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Thomas Gleixner CC: "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 References: <51C11E83.8030902@asianux.com> <51C17D01.2060208@asianux.com> <51C1861A.6030901@asianux.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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