public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Roland Dreier <rdreier@cisco.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: On some configs, sparse spinlock balance checking is broken
Date: Wed, 17 Jan 2007 07:34:50 +0100	[thread overview]
Message-ID: <20070117063450.GC14027@elte.hu> (raw)
In-Reply-To: <adaejpumt41.fsf@cisco.com>


* Roland Dreier <rdreier@cisco.com> wrote:

> (Ingo -- you seem to be the last person to touch all this stuff, and I 
> can't untangle what you did, hence I'm sending this email to you)
> 
> On at least some of my configs on x86_64, when running sparse, I see 
> bogus 'warning: context imbalance in '<func>' - wrong count at exit'.
> 
> This seems to be because I have CONFIG_SMP=y, CONFIG_DEBUG_SPINLOCK=n
> and CONFIG_PREEMPT=n.  Therefore, <linux/spinlock.h> does
> 
> 	#define spin_lock(lock)			_spin_lock(lock)
> 
> which picks up
> 
> 	void __lockfunc _spin_lock(spinlock_t *lock)		__acquires(lock);
> 
> from <linux/spinlock_api_smp.h>, but <linux/spinlock.h> also has:
> 
> 	#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
> 		!defined(CONFIG_SMP)
> 	//...
> 	#else
> 	# define spin_unlock(lock)		__raw_spin_unlock(&(lock)->raw_lock)

this is the direct-inlining speedup some people insisted on.

> and <asm-x86_64/spinlock.h> has:
> 
> 	static inline void __raw_spin_unlock(raw_spinlock_t *lock)
> 	{
> 		asm volatile("movl $1,%0" :"=m" (lock->slock) :: "memory");
> 	}
> 
> so sparse doesn't see any __releases() to match the __acquires.
> 
> This all seems to go back to commit bda98685 ("x86: inline spin_unlock
> if !CONFIG_DEBUG_SPINLOCK and !CONFIG_PREEMPT") but I don't know what
> motivated that change.
> 
> Anyway, Ingo or anyone else, what's the best way to fix this?  Maybe 
> the right way to fix this is just to define away __acquires/__releases 
> unless CONFIG_DEBUG_SPINLOCK is set, but that seems suboptimal.

i think the right way to fix it might be to define a _spin_unlock() 
within those #ifdef branches, and then to define spin_lock as:

static inline void spin_lock(spinlock_t *lock) __acquires(lock)
{
	_spin_lock(lock);
}

?

	Ingo

  reply	other threads:[~2007-01-17  6:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-16 23:47 On some configs, sparse spinlock balance checking is broken Roland Dreier
2007-01-17  6:34 ` Ingo Molnar [this message]
2007-01-17 15:37   ` Roland Dreier
2007-01-17 16:28     ` Ingo Molnar

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=20070117063450.GC14027@elte.hu \
    --to=mingo@elte.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    /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