mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@labri.fr>
To: linux-kernel@vger.kernel.org
Cc: torvalds@osdl.org
Subject: Re: [PATCH] spin_unlock_bh() and preempt_check_resched()
Date: Sat, 21 May 2005 17:50:15 +0200	[thread overview]
Message-ID: <20050521155015.GA3687@bouh.labri.fr> (raw)
In-Reply-To: <20050520151846.GP3690@bouh.labri.fr>

Hi,

Samuel Thibault, le Fri 20 May 2005 17:18:46 +0200, a dit :
> I'm wondering about macros like _spin_unlock_bh(lock):
> do { \
>         _raw_spin_unlock(lock); \
>         preempt_enable(); \
>         local_bh_enable(); \
>         __release(lock); \
> } while (0)
> 
> Is there a reason for using preempt_enable() instead of a simple
> preempt_enable_no_resched() ?
> 
> Since we know bottom halves are disabled, preempt_schedule() will always
> return at once (preempt_count!=0), and hence preempt_check_resched() is
> useless here...

Here is a patch.

Avoid useless preempt_check_resched() just before re-enabling bottom
halves.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

diff -urNp linux-2.6-git/include/linux/spinlock.h linux-2.6-git-mine/include/linux/spinlock.h
--- linux-2.6-git/include/linux/spinlock.h	2005-05-21 15:41:33.000000000 +0200
+++ linux-2.6-git-mine/include/linux/spinlock.h	2005-05-21 15:45:11.000000000 +0200
@@ -248,7 +248,7 @@
 
 #define _spin_trylock_bh(lock)	({preempt_disable(); local_bh_disable(); \
 				_raw_spin_trylock(lock) ? \
-				1 : ({preempt_enable(); local_bh_enable(); 0;});})
+				1 : ({preempt_enable_no_resched(); local_bh_enable(); 0;});})
 
 #define _spin_lock(lock)	\
 do { \
@@ -383,7 +383,7 @@
 #define _spin_unlock_bh(lock) \
 do { \
 	_raw_spin_unlock(lock); \
-	preempt_enable(); \
+	preempt_enable_no_resched(); \
 	local_bh_enable(); \
 	__release(lock); \
 } while (0)
@@ -391,7 +391,7 @@
 #define _write_unlock_bh(lock) \
 do { \
 	_raw_write_unlock(lock); \
-	preempt_enable(); \
+	preempt_enable_no_resched(); \
 	local_bh_enable(); \
 	__release(lock); \
 } while (0)
@@ -423,8 +423,8 @@
 #define _read_unlock_bh(lock)	\
 do { \
 	_raw_read_unlock(lock);	\
+	preempt_enable_no_resched();	\
 	local_bh_enable();	\
-	preempt_enable();	\
 	__release(lock); \
 } while (0)
 
diff -urNp linux-2.6-git/kernel/spinlock.c linux-2.6-git-mine/kernel/spinlock.c
--- linux-2.6-git/kernel/spinlock.c	2005-05-21 15:41:08.000000000 +0200
+++ linux-2.6-git-mine/kernel/spinlock.c	2005-05-21 15:42:36.000000000 +0200
@@ -294,7 +294,7 @@
 void __lockfunc _spin_unlock_bh(spinlock_t *lock)
 {
 	_raw_spin_unlock(lock);
-	preempt_enable();
+	preempt_enable_no_resched();
 	local_bh_enable();
 }
 EXPORT_SYMBOL(_spin_unlock_bh);
@@ -318,7 +318,7 @@
 void __lockfunc _read_unlock_bh(rwlock_t *lock)
 {
 	_raw_read_unlock(lock);
-	preempt_enable();
+	preempt_enable_no_resched();
 	local_bh_enable();
 }
 EXPORT_SYMBOL(_read_unlock_bh);
@@ -342,7 +342,7 @@
 void __lockfunc _write_unlock_bh(rwlock_t *lock)
 {
 	_raw_write_unlock(lock);
-	preempt_enable();
+	preempt_enable_no_resched();
 	local_bh_enable();
 }
 EXPORT_SYMBOL(_write_unlock_bh);
@@ -354,7 +354,7 @@ int __lockfunc _spin_trylock_bh(spinlock
 	if (_raw_spin_trylock(lock))
 		return 1;
 
-	preempt_enable();
+	preempt_enable_no_resched();
 	local_bh_enable();
 	return 0;
 }

Regards,
Samuel Thibault

      reply	other threads:[~2005-05-21 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-20 15:18 Samuel Thibault
2005-05-21 15:50 ` Samuel Thibault [this message]

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=20050521155015.GA3687@bouh.labri.fr \
    --to=samuel.thibault@labri.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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

Powered by JetHome