public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@o2.pl>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org,
	Arjan van de Ven <arjan@infradead.org>,
	Ingo Molnar <mingo@elte.hu>, Jiri Kosina <jikos@jikos.cz>,
	Marcel Holtmann <marcel@holtmann.org>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 1/2] lockdep: spin_lock_irqsave_nested()
Date: Mon, 30 Oct 2006 14:12:41 +0100	[thread overview]
Message-ID: <20061030131241.GA1657@ff.dom.local> (raw)
In-Reply-To: <1162199005.24143.169.camel@taijtu>

Here are some doubts...

Jarek P.

On 30-10-2006 10:03, Peter Zijlstra wrote:
> From: Arjan van de Ven <arjan@linux.intel.com>
> Subject: spin_lock_irqsave_nested()
> 
> Introduce spin_lock_irqsave_nested(); implementation from:
>  http://lkml.org/lkml/2006/6/1/122
> Patch from:
>  http://lkml.org/lkml/2006/9/13/258
> 
> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> Signed-off-by: Jiri Kosina <jikos@jikos.cz>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> ---
>  include/linux/spinlock.h         |    5 +++++
>  include/linux/spinlock_api_smp.h |    2 ++
>  include/linux/spinlock_api_up.h  |    1 +
>  kernel/spinlock.c                |   21 +++++++++++++++++++++
>  4 files changed, 29 insertions(+)
> 
> Index: linux-2.6/include/linux/spinlock_api_smp.h
> ===================================================================
> --- linux-2.6.orig/include/linux/spinlock_api_smp.h
> +++ linux-2.6/include/linux/spinlock_api_smp.h
> @@ -32,6 +32,8 @@ void __lockfunc _read_lock_irq(rwlock_t 
>  void __lockfunc _write_lock_irq(rwlock_t *lock)		__acquires(lock);
>  unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
>  							__acquires(lock);
> +unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
> +							__acquires(spinlock_t);

According to neighbours rather:
 +							__acquires(lock);

>  unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)
>  							__acquires(lock);
>  unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
> Index: linux-2.6/include/linux/spinlock_api_up.h
> ===================================================================
> --- linux-2.6.orig/include/linux/spinlock_api_up.h
> +++ linux-2.6/include/linux/spinlock_api_up.h
> @@ -59,6 +59,7 @@
>  #define _read_lock_irq(lock)			__LOCK_IRQ(lock)
>  #define _write_lock_irq(lock)			__LOCK_IRQ(lock)
>  #define _spin_lock_irqsave(lock, flags)		__LOCK_IRQSAVE(lock, flags)
> +#define _spin_lock_irqsave_nested(lock, flags, subclass) __LOCK_IRQSAVE(lock, flags, subclass)

Is __LOCK_IRQSAVE() with 3 args defined?

>  #define _read_lock_irqsave(lock, flags)		__LOCK_IRQSAVE(lock, flags)
>  #define _write_lock_irqsave(lock, flags)	__LOCK_IRQSAVE(lock, flags)
>  #define _spin_trylock(lock)			({ __LOCK(lock); 1; })
> Index: linux-2.6/include/linux/spinlock.h
> ===================================================================
> --- linux-2.6.orig/include/linux/spinlock.h
> +++ linux-2.6/include/linux/spinlock.h
> @@ -186,6 +186,11 @@ do {								\
>  #define spin_lock_irqsave(lock, flags)	flags = _spin_lock_irqsave(lock)
>  #define read_lock_irqsave(lock, flags)	flags = _read_lock_irqsave(lock)
>  #define write_lock_irqsave(lock, flags)	flags = _write_lock_irqsave(lock)
> +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> +#define spin_lock_irqsave_nested(lock, flags, subclass)	flags = _spin_lock_irqsave_nested(lock, subclass)
> +#else
> +#define spin_lock_irqsave_nested(lock, flags, subclass)	flags = _spin_lock_irqsave(lock)
> +#endif
>  #else

Plus for api_up:

+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+#define spin_lock_irqsave_nested(lock, flags, subclass)	_spin_lock_irqsave_nested(lock, flags, subclass)
+#else
+#define spin_lock_irqsave_nested(lock, flags, subclass)	_spin_lock_irqsave(lock, flags)
+#endif

>  #define spin_lock_irqsave(lock, flags)	_spin_lock_irqsave(lock, flags)
>  #define read_lock_irqsave(lock, flags)	_read_lock_irqsave(lock, flags)
> Index: linux-2.6/kernel/spinlock.c
> ===================================================================
> --- linux-2.6.orig/kernel/spinlock.c
> +++ linux-2.6/kernel/spinlock.c
> @@ -293,6 +293,27 @@ void __lockfunc _spin_lock_nested(spinlo
>  }
>  
>  EXPORT_SYMBOL(_spin_lock_nested);
> +unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
> +{
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	preempt_disable();
> +	spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
> +	/*
> +	 * On lockdep we dont want the hand-coded irq-enable of
> +	 * _raw_spin_lock_flags() code, because lockdep assumes
> +	 * that interrupts are not re-enabled during lock-acquire:
> +	 */
> +#ifdef CONFIG_PROVE_SPIN_LOCKING
> +	_raw_spin_lock(lock);
> +#else
> +	_raw_spin_lock_flags(lock, &flags);
> +#endif
> +	return flags;
> +}
> +
> +EXPORT_SYMBOL(_spin_lock_irqsave_nested);
>  
>  #endif
>  
> 

Shouldn't this _nested locks be considered in: 
#else /* CONFIG_PREEMPT: */
part?

  parent reply	other threads:[~2006-10-30 13:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-30  9:03 [PATCH 1/2] lockdep: spin_lock_irqsave_nested() Peter Zijlstra
2006-10-30  9:06 ` [PATCH 2/2] lockdep: annotate bcsp driver Peter Zijlstra
2006-10-30  9:06   ` Ingo Molnar
2006-10-30  9:30   ` Marcel Holtmann
2006-10-30  9:31   ` [PATCH 2/2] lockdep: annotate bcsp driver - v2 Peter Zijlstra
2006-10-30  9:07 ` [PATCH 1/2] lockdep: spin_lock_irqsave_nested() Ingo Molnar
2006-10-30 13:12 ` Jarek Poplawski [this message]
2006-10-30 13:27   ` Jarek Poplawski
2006-10-30 13:40   ` [PATCH 1/2] lockdep: spin_lock_irqsave_nested() -v2 Peter Zijlstra
2006-10-30 14:12     ` Jarek Poplawski
2006-10-31  6:48 ` [PATCH 1/2] lockdep: spin_lock_irqsave_nested() Andrew Morton
2006-10-31  7:25   ` [PATCH] splice : two smp_mb() can be omitted Eric Dumazet
2006-10-31  7:32     ` Jens Axboe
2006-10-31  7:41       ` Eric Dumazet
2006-10-31  7:46         ` Jens Axboe
2006-10-31  9:40     ` Nick Piggin
2006-10-31  9:49       ` Jens Axboe
2006-10-31 10:51       ` Eric Dumazet
2006-10-31 22:16         ` Nick Piggin
2006-10-31 23:08           ` Eric Dumazet
2006-10-31 23:45             ` Nick Piggin
2006-11-02 17:02         ` [PATCH] splice : Must fully check for fifos Eric Dumazet
2006-11-02 17:05           ` Eric Dumazet
2006-11-02 19:07             ` Jens Axboe
2006-11-03  8:50               ` Jens Axboe

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=20061030131241.GA1657@ff.dom.local \
    --to=jarkao2@o2.pl \
    --cc=a.p.zijlstra@chello.nl \
    --cc=arjan@infradead.org \
    --cc=dwmw2@infradead.org \
    --cc=jikos@jikos.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mingo@elte.hu \
    /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