public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, akpm@zip.com.au
Subject: [PATCH] simple preemption debug check
Date: 03 Apr 2002 18:54:18 -0500	[thread overview]
Message-ID: <1017878059.22299.85.camel@phantasy> (raw)

Linus,

This simple check was first suggested by Andrew Morton.  Pretty basic -
whines if a task exits with a nonzero preempt_count value.

I put an identical check in the 2.4 preempt-kernel patch and - sure
enough - it was found that XFS essentially disables preemption as it
destroys data structures containing locks without first unlocking.  The
SGI folks are working on that.

Anyhow, its a quick and clean solution to debugging potential problems. 
Patch is against 2.5.7, please apply.

	Robert Love

diff -urN linux-2.5.7/include/linux/spinlock.h linux/include/linux/spinlock.h
--- linux-2.5.7/include/linux/spinlock.h	Mon Mar 18 15:37:15 2002
+++ linux/include/linux/spinlock.h	Wed Apr  3 18:46:00 2002
@@ -204,7 +204,7 @@
 
 #else
 
-#define preempt_get_count()	do { } while (0)
+#define preempt_get_count()	(0)
 #define preempt_disable()	do { } while (0)
 #define preempt_enable_no_resched()	do {} while(0)
 #define preempt_enable()	do { } while (0)
diff -urN linux-2.5.7/kernel/exit.c linux/kernel/exit.c
--- linux-2.5.7/kernel/exit.c	Mon Mar 18 15:37:10 2002
+++ linux/kernel/exit.c	Wed Apr  3 18:44:24 2002
@@ -492,6 +492,11 @@
 	tsk->flags |= PF_EXITING;
 	del_timer_sync(&tsk->real_timer);
 
+	if (unlikely(preempt_get_count()))
+		printk(KERN_ERR "error: %s[%d] exited with preempt_count %d\n",
+				current->comm, current->pid,
+				preempt_get_count());
+
 fake_volatile:
 #ifdef CONFIG_BSD_PROCESS_ACCT
 	acct_process(code);


                 reply	other threads:[~2002-04-03 23:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1017878059.22299.85.camel@phantasy \
    --to=rml@tech9.net \
    --cc=akpm@zip.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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