From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755126Ab3A2JBc (ORCPT ); Tue, 29 Jan 2013 04:01:32 -0500 Received: from mail-bk0-f50.google.com ([209.85.214.50]:64737 "EHLO mail-bk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754695Ab3A2JBa (ORCPT ); Tue, 29 Jan 2013 04:01:30 -0500 Date: Tue, 29 Jan 2013 10:01:26 +0100 From: Ingo Molnar To: nan chen Cc: Andrew Morton , Yuanhan Liu , linux-kernel@vger.kernel.org, Thomas Gleixner , Steven Rostedt Subject: Re: [PATCH 2/2] mutex: use spin_[un]lock instead of arch_spin_[un]lock Message-ID: <20130129090126.GA5547@gmail.com> References: <1359019365-23646-1-git-send-email-yuanhan.liu@linux.intel.com> <1359019365-23646-2-git-send-email-yuanhan.liu@linux.intel.com> <20130124161413.a3903fa4.akpm@linux-foundation.org> <20130125074053.GD18243@gmail.com> <20130125092422.GA19541@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * nan chen wrote: > 2013/1/25 Ingo Molnar > > > > > * nan chen wrote: > > > > > 2013/1/25 Ingo Molnar > > > > > > > > > > > * Andrew Morton wrote: > > > > > > > > > On Thu, 24 Jan 2013 17:22:45 +0800 > > > > > Yuanhan Liu wrote: > > > > > > > > > > > Use spin_[un]lock instead of arch_spin_[un]lock in mutex-debug.h so > > > > > > that we can collect the lock statistics of spin_lock_mutex from > > > > > > /proc/lock_stat. > > > > > > > > So, as per the discussion we don't want this patch, because we > > > > are using raw locks there to keep mutex lockdep overhead low. > > > > The value of lockdep-checking such a basic locking primitive is > > > > minimal - it's rarely tweaked and if it breaks we won't have a > > > > bootable kernel to begin with. > > > > > > > > So instead I suggested a different patch: adding a comment to > > > > explain why we don't lockdep-cover the mutex code spinlocks. > > > > > > > > > Also, I believe your patch permits this cleanup: > > > > > > > > > > --- > > > > > > a/kernel/mutex-debug.h~mutex-use-spin_lock-instead-of-arch_spin_lock-fix > > > > > +++ a/kernel/mutex-debug.h > > > > > @@ -42,14 +42,12 @@ static inline void mutex_clear_owner(str > > > > > struct mutex *l = container_of(lock, struct mutex, > > > > wait_lock); \ > > > > > \ > > > > > DEBUG_LOCKS_WARN_ON(in_interrupt()); \ > > > > > - local_irq_save(flags); \ > > > > > - spin_lock(lock); \ > > > > > + spin_lock_irqsave(lock, flags); \ > > > > > > > > Yes, I mentioned that yesterday, but we really don't want the > > > > change to begin with. > > > > > > > > Thanks, > > > > > > > > Ingo > > > > > > > > > > Hi, > > > > > > Looks like in mutex.h, it does not disable local interrupt. > > > But why the code disable local interrupt in mutex-debug.h? > > > > To protect against preemption I suspect. preempt_disable() could > > be used in the mutex-debug.h variant I suppose. > > > > Thanks, > > > > Ingo > > > > > spin_lock() itself already protects against preemption. Yes, but mutex-debug.h does not use spin_lock(), it uses arch_spin_lock(): #define spin_lock_mutex(lock, flags) \ do { \ struct mutex *l = container_of(lock, struct mutex, wait_lock); \ \ DEBUG_LOCKS_WARN_ON(in_interrupt()); \ local_irq_save(flags); \ arch_spin_lock(&(lock)->rlock.raw_lock);\ DEBUG_LOCKS_WARN_ON(l->magic != l); \ } while (0) The original question was why mutex-debug.h (unmodified) uses irq disabling. Thanks, Ingo