From: Steven Rostedt <rostedt@goodmis.org>
To: Lee Revell <rlrevell@joe-job.com>
Cc: Ingo Molnar <mingo@elte.hu>, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01
Date: Mon, 14 Mar 2005 10:50:07 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.58.0503141024530.697@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.58.0503140509170.697@localhost.localdomain>
On Mon, 14 Mar 2005, Steven Rostedt wrote:
>
> On Mon, 14 Mar 2005, Steven Rostedt wrote:
> >
> > I just downloaded -40 and applied my patch, compiled it with
> > PREEMPT_DESKTOP and data=ordered, ran it and everything seems OK, except
> > I'm getting the following...
> >
> > BUG: Unable to handle kernel NULL pointer dereference at virtual address
> > 00000000
> > printing eip:
> > c0213438
> > *pde = 00000000
>
> [snip]
>
> >
> >
> > I'll see if this happens without the patch, and if so, then I'll look into
> > this further.
> >
>
> Well, I took out my patch and this bug didn't happen, so I guess it's may
> fault! OK, I'll dig into it further.
>
Here's a new patch. All I did was move BUFFER_FNS(JournalHead,journalhead)
to inside the #ifdef CONFIG_PREEMPT_RT and my oops went away !?! This
really bothers me since it just declares some functions and is not used
with CONFIG_PREEMPT_RT off. I have no idea what's going on.
Lee, can you see if this still crashes for you.
Thanks,
-- Steve
diff -ur linux-2.6.11-final-V0.7.40-00.orig/fs/jbd/journal.c linux-2.6.11-final-V0.7.40-00/fs/jbd/journal.c
--- linux-2.6.11-final-V0.7.40-00.orig/fs/jbd/journal.c 2005-03-02 02:37:49.000000000 -0500
+++ linux-2.6.11-final-V0.7.40-00/fs/jbd/journal.c 2005-03-14 09:46:41.000000000 -0500
@@ -80,6 +80,10 @@
EXPORT_SYMBOL(journal_try_to_free_buffers);
EXPORT_SYMBOL(journal_force_commit);
+#ifdef CONFIG_PREEMPT_RT
+spinlock_t jbd_journal_head_lock = SPIN_LOCK_UNLOCKED;
+#endif
+
static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
/*
@@ -1727,6 +1731,9 @@
jh = new_jh;
new_jh = NULL; /* We consumed it */
set_buffer_jbd(bh);
+#ifdef CONFIG_PREEMPT_RT
+ spin_lock_init(&jh->b_state_lock);
+#endif
bh->b_private = jh;
jh->b_bh = bh;
get_bh(bh);
@@ -1767,26 +1774,34 @@
if (jh->b_transaction == NULL &&
jh->b_next_transaction == NULL &&
jh->b_cp_transaction == NULL) {
- J_ASSERT_BH(bh, buffer_jbd(bh));
- J_ASSERT_BH(bh, jh2bh(jh) == bh);
- BUFFER_TRACE(bh, "remove journal_head");
- if (jh->b_frozen_data) {
- printk(KERN_WARNING "%s: freeing "
- "b_frozen_data\n",
- __FUNCTION__);
- kfree(jh->b_frozen_data);
- }
- if (jh->b_committed_data) {
- printk(KERN_WARNING "%s: freeing "
- "b_committed_data\n",
- __FUNCTION__);
- kfree(jh->b_committed_data);
+#ifdef CONFIG_PREEMPT_RT
+ if (atomic_read(&jh->b_state_wait_count)) {
+ BUG_ON(buffer_journalhead(bh));
+ set_buffer_journalhead(bh);
+ } else
+#endif
+ {
+ J_ASSERT_BH(bh, buffer_jbd(bh));
+ J_ASSERT_BH(bh, jh2bh(jh) == bh);
+ BUFFER_TRACE(bh, "remove journal_head");
+ if (jh->b_frozen_data) {
+ printk(KERN_WARNING "%s: freeing "
+ "b_frozen_data\n",
+ __FUNCTION__);
+ kfree(jh->b_frozen_data);
+ }
+ if (jh->b_committed_data) {
+ printk(KERN_WARNING "%s: freeing "
+ "b_committed_data\n",
+ __FUNCTION__);
+ kfree(jh->b_committed_data);
+ }
+ bh->b_private = NULL;
+ jh->b_bh = NULL; /* debug, really */
+ clear_buffer_jbd(bh);
+ __brelse(bh);
+ journal_free_journal_head(jh);
}
- bh->b_private = NULL;
- jh->b_bh = NULL; /* debug, really */
- clear_buffer_jbd(bh);
- __brelse(bh);
- journal_free_journal_head(jh);
} else {
BUFFER_TRACE(bh, "journal_head was locked");
}
diff -ur linux-2.6.11-final-V0.7.40-00.orig/fs/jbd/transaction.c linux-2.6.11-final-V0.7.40-00/fs/jbd/transaction.c
--- linux-2.6.11-final-V0.7.40-00.orig/fs/jbd/transaction.c 2005-03-02 02:37:53.000000000 -0500
+++ linux-2.6.11-final-V0.7.40-00/fs/jbd/transaction.c 2005-03-14 09:46:41.000000000 -0500
@@ -1207,11 +1207,17 @@
BUFFER_TRACE(bh, "entry");
+ /*
+ * Is it OK to check to see if this isn't a jbd buffer outside of
+ * locks? Now that jbd_lock_bh_state only works with jbd buffers
+ * I sure hope so.
+ */
+ if (!buffer_jbd(bh))
+ goto not_jbd;
+
jbd_lock_bh_state(bh);
spin_lock(&journal->j_list_lock);
- if (!buffer_jbd(bh))
- goto not_jbd;
jh = bh2jh(bh);
/* Critical error: attempting to delete a bitmap buffer, maybe?
@@ -1219,7 +1225,7 @@
if (!J_EXPECT_JH(jh, !jh->b_committed_data,
"inconsistent data on disk")) {
err = -EIO;
- goto not_jbd;
+ goto bad_jbd;
}
if (jh->b_transaction == handle->h_transaction) {
@@ -1274,9 +1280,11 @@
}
}
-not_jbd:
+
+bad_jbd:
spin_unlock(&journal->j_list_lock);
jbd_unlock_bh_state(bh);
+not_jbd:
__brelse(bh);
return err;
}
diff -ur linux-2.6.11-final-V0.7.40-00.orig/include/linux/jbd.h linux-2.6.11-final-V0.7.40-00/include/linux/jbd.h
--- linux-2.6.11-final-V0.7.40-00.orig/include/linux/jbd.h 2005-03-02 02:38:19.000000000 -0500
+++ linux-2.6.11-final-V0.7.40-00/include/linux/jbd.h 2005-03-14 09:46:57.000000000 -0500
@@ -324,6 +324,68 @@
return bh->b_private;
}
+void journal_remove_journal_head(struct buffer_head *bh);
+
+#ifdef CONFIG_PREEMPT_RT
+
+BUFFER_FNS(JournalHead,journalhead)
+
+extern spinlock_t jbd_journal_head_lock;
+
+static inline void jbd_lock_bh_state(struct buffer_head *bh)
+{
+ BUG_ON(!bh->b_private);
+ atomic_inc(&bh2jh(bh)->b_state_wait_count);
+ spin_lock(&bh2jh(bh)->b_state_lock);
+}
+
+static inline int jbd_trylock_bh_state(struct buffer_head *bh)
+{
+ int ret;
+
+ BUG_ON(!bh->b_private);
+
+ if ((ret = spin_trylock(&bh2jh(bh)->b_state_lock)))
+ atomic_inc(&bh2jh(bh)->b_state_wait_count);
+
+ return ret;
+}
+
+static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
+{
+ return bh2jh(bh) ? spin_is_locked(&bh2jh(bh)->b_state_lock) : 0;
+}
+
+static inline void jbd_unlock_bh_state(struct buffer_head *bh)
+{
+ int rmjh = 0;
+
+ BUG_ON(!atomic_read(&bh2jh(bh)->b_state_wait_count));
+ atomic_dec(&bh2jh(bh)->b_state_wait_count);
+
+ if (buffer_journalhead(bh)) {
+ clear_buffer_journalhead(bh);
+ rmjh = 1;
+ }
+
+ spin_unlock(&bh2jh(bh)->b_state_lock);
+
+ if (rmjh)
+ journal_remove_journal_head(bh);
+}
+
+static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
+{
+ spin_lock(&jbd_journal_head_lock);
+}
+
+static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
+{
+ spin_unlock(&jbd_journal_head_lock);
+}
+
+#else /* !CONFIG_PREEMPT_RT */
+
static inline void jbd_lock_bh_state(struct buffer_head *bh)
{
bit_spin_lock(BH_State, &bh->b_state);
@@ -354,6 +416,8 @@
bit_spin_unlock(BH_JournalHead, &bh->b_state);
}
+#endif /* CONFIG_PREEMPT_RT */
+
struct jbd_revoke_table_s;
/**
@@ -918,7 +982,6 @@
*/
struct journal_head *journal_add_journal_head(struct buffer_head *bh);
struct journal_head *journal_grab_journal_head(struct buffer_head *bh);
-void journal_remove_journal_head(struct buffer_head *bh);
void journal_put_journal_head(struct journal_head *jh);
/*
diff -ur linux-2.6.11-final-V0.7.40-00.orig/include/linux/journal-head.h linux-2.6.11-final-V0.7.40-00/include/linux/journal-head.h
--- linux-2.6.11-final-V0.7.40-00.orig/include/linux/journal-head.h 2005-03-02 02:38:25.000000000 -0500
+++ linux-2.6.11-final-V0.7.40-00/include/linux/journal-head.h 2005-03-14 09:46:41.000000000 -0500
@@ -80,6 +80,16 @@
* [j_list_lock]
*/
struct journal_head *b_cpnext, *b_cpprev;
+
+ /*
+ * Lock the state of the buffer head.
+ */
+ spinlock_t b_state_lock;
+
+ /*
+ * Count the processes that want/have the state lock.
+ */
+ atomic_t b_state_wait_count;
};
#endif /* JOURNAL_HEAD_H_INCLUDED */
diff -ur linux-2.6.11-final-V0.7.40-00.orig/include/linux/spinlock.h linux-2.6.11-final-V0.7.40-00/include/linux/spinlock.h
--- linux-2.6.11-final-V0.7.40-00.orig/include/linux/spinlock.h 2005-03-14 06:00:54.000000000 -0500
+++ linux-2.6.11-final-V0.7.40-00/include/linux/spinlock.h 2005-03-14 09:46:41.053696484 -0500
@@ -774,6 +774,10 @@
}))
+#ifndef CONFIG_PREEMPT_RT
+
+/* These are just plain evil! */
+
/*
* bit-based spin_lock()
*
@@ -789,10 +793,15 @@
* busywait with less bus contention for a good time to
* attempt to acquire the lock bit.
*/
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT)
- while (test_and_set_bit(bitnum, addr))
- while (test_bit(bitnum, addr))
+ preempt_disable();
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+ while (test_and_set_bit(bitnum, addr)) {
+ while (test_bit(bitnum, addr)) {
+ preempt_enable();
cpu_relax();
+ preempt_disable();
+ }
+ }
#endif
__acquire(bitlock);
}
@@ -802,9 +811,12 @@
*/
static inline int bit_spin_trylock(int bitnum, unsigned long *addr)
{
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT)
- if (test_and_set_bit(bitnum, addr))
+ preempt_disable();
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+ if (test_and_set_bit(bitnum, addr)) {
+ preempt_enable();
return 0;
+ }
#endif
__acquire(bitlock);
return 1;
@@ -815,11 +827,12 @@
*/
static inline void bit_spin_unlock(int bitnum, unsigned long *addr)
{
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT)
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
BUG_ON(!test_bit(bitnum, addr));
smp_mb__before_clear_bit();
clear_bit(bitnum, addr);
#endif
+ preempt_enable();
__release(bitlock);
}
@@ -828,12 +841,15 @@
*/
static inline int bit_spin_is_locked(int bitnum, unsigned long *addr)
{
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT)
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
return test_bit(bitnum, addr);
+#elif defined CONFIG_PREEMPT
+ return preempt_count();
#else
return 1;
#endif
}
+#endif /* CONFIG_PREEMPT_RT */
#define DEFINE_SPINLOCK(name) \
spinlock_t name __cacheline_aligned_in_smp = _SPIN_LOCK_UNLOCKED(name)
next prev parent reply other threads:[~2005-03-14 15:51 UTC|newest]
Thread overview: 125+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-04 10:03 [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01 Ingo Molnar
2005-02-04 15:19 ` Kevin Hilman
2005-02-04 17:30 ` Ingo Molnar
2005-02-04 18:19 ` Tom Rini
2005-02-07 9:03 ` Ingo Molnar
2005-02-07 14:35 ` Tom Rini
2005-02-08 8:27 ` Ingo Molnar
2005-02-06 4:19 ` Valdis.Kletnieks
2005-02-07 9:21 ` Ingo Molnar
2005-02-07 15:08 ` Real-Time Preemption and UML? Esben Nielsen
2005-02-07 18:35 ` Jeff Dike
2005-02-07 23:14 ` Esben Nielsen
2005-02-08 8:39 ` Ingo Molnar
2005-02-08 18:55 ` Jeff Dike
2005-02-08 21:20 ` Esben Nielsen
2005-02-08 21:44 ` Ingo Molnar
2005-02-08 23:02 ` Esben Nielsen
2005-02-08 7:55 ` [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01 Valdis.Kletnieks
2005-02-08 8:45 ` Ingo Molnar
2005-02-08 10:26 ` Valdis.Kletnieks
2005-02-08 21:58 ` William Weston
2005-02-09 11:51 ` Ingo Molnar
2005-02-10 2:13 ` William Weston
2005-02-10 7:52 ` Ingo Molnar
2005-02-10 20:21 ` George Anzinger
2005-02-10 20:40 ` Ingo Molnar
2005-02-10 21:05 ` George Anzinger
2005-02-11 8:34 ` Ingo Molnar
2005-02-11 9:38 ` Sven Dietrich
2005-02-11 9:42 ` Ingo Molnar
2005-02-11 0:09 ` Sven Dietrich
2005-02-11 6:01 ` George Anzinger
2005-02-11 8:28 ` Ingo Molnar
2005-02-11 9:53 ` Sven Dietrich
2005-02-11 10:04 ` Ingo Molnar
2005-02-11 21:49 ` Steven Rostedt
2005-02-13 12:59 ` Ingo Molnar
2005-02-13 15:11 ` Steven Rostedt
2005-03-03 19:36 ` [patch] Real-Time Preemption, deactivate() scheduling issue Eugeny S. Mints
2005-03-03 22:32 ` Esben Nielsen
2005-03-04 11:56 ` Eugeny S. Mints
2005-03-04 15:45 ` George Anzinger
2005-03-29 8:45 ` Ingo Molnar
2005-02-09 12:48 ` [patch] Real-Time Preemption, -RT-2.6.11-rc3-V0.7.38-01 Stephen Smalley
2005-02-10 2:20 ` William Weston
2005-02-19 5:08 ` Lee Revell
2005-02-19 6:47 ` Lee Revell
2005-02-19 9:00 ` Ingo Molnar
2005-02-19 9:03 ` Ingo Molnar
2005-02-19 20:45 ` Lee Revell
2005-02-20 0:19 ` Lee Revell
2005-03-17 16:33 ` Lee Revell
2005-02-23 2:22 ` Lee Revell
2005-03-10 9:37 ` Steven Rostedt
2005-03-10 9:54 ` Steven Rostedt
2005-03-11 9:57 ` Ingo Molnar
2005-03-11 10:15 ` Steven Rostedt
2005-03-11 10:17 ` Ingo Molnar
2005-03-11 10:24 ` Steven Rostedt
2005-03-11 10:43 ` Andrew Morton
2005-03-11 10:53 ` Steven Rostedt
2005-03-11 14:40 ` Steven Rostedt
2005-03-11 15:08 ` Steven Rostedt
2005-03-11 15:30 ` K.R. Foley
2005-03-11 15:38 ` Ingo Molnar
2005-03-11 16:01 ` Steven Rostedt
2005-03-11 20:39 ` Steven Rostedt
2005-03-11 20:46 ` Lee Revell
2005-03-11 22:06 ` Lee Revell
2005-03-14 7:37 ` Steven Rostedt
2005-03-14 9:33 ` Steven Rostedt
2005-03-14 10:10 ` Steven Rostedt
2005-03-14 15:50 ` Steven Rostedt [this message]
2005-03-14 19:02 ` Steven Rostedt
2005-03-15 11:44 ` Steven Rostedt
2005-03-15 12:00 ` Ingo Molnar
2005-03-15 13:07 ` Steven Rostedt
2005-03-15 13:35 ` Ingo Molnar
2005-03-15 13:55 ` Steven Rostedt
2005-03-15 19:12 ` Andrew Morton
2005-03-15 18:05 ` Steven Rostedt
2005-03-15 19:09 ` Lee Revell
2005-03-16 7:50 ` Steven Rostedt
2005-03-16 18:21 ` Lee Revell
2005-03-16 7:31 ` Steven Rostedt
2005-03-16 8:50 ` Ingo Molnar
2005-03-16 9:15 ` Andrew Morton
2005-03-16 9:51 ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Ingo Molnar
2005-03-16 9:53 ` [patch 1/3] j_state_lock -> j_state_sem Ingo Molnar
2005-03-16 9:53 ` [patch 2/3] j_list_lock -> j_list_sem Ingo Molnar
2005-03-16 9:57 ` [patch 3/3] remove bitlocks Ingo Molnar
2005-03-16 10:04 ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Andrew Morton
2005-03-16 10:12 ` Ingo Molnar
2005-03-16 10:23 ` Steven Rostedt
2005-03-16 10:26 ` Ingo Molnar
2005-03-16 10:26 ` Andrew Morton
2005-03-16 10:29 ` Ingo Molnar
2005-03-16 10:41 ` Andrew Morton
2005-03-16 10:34 ` Arjan van de Ven
2005-03-16 10:19 ` Ingo Molnar
2005-03-16 10:40 ` Andrew Morton
2005-03-16 10:51 ` Ingo Molnar
2005-03-16 11:05 ` Steven Rostedt
2005-03-16 11:19 ` Andrew Morton
2005-03-16 14:04 ` Steven Rostedt
2005-03-16 16:47 ` Steven Rostedt
2005-03-16 17:47 ` Steven Rostedt
2005-03-16 19:20 ` Lee Revell
2005-03-17 7:15 ` Steven Rostedt
2005-03-17 15:41 ` Lee Revell
2005-03-17 16:23 ` Steven Rostedt
2005-03-17 16:36 ` Lee Revell
2005-03-18 6:58 ` Steven Rostedt
2005-03-18 18:19 ` Lee Revell
2005-03-16 21:15 ` Andrew Morton
2005-03-17 9:21 ` Steven Rostedt
2005-03-18 9:23 ` [PATCH] remove lame schedule in journal inverted_lock (was: Re: [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks) Steven Rostedt
2005-03-18 9:32 ` Andrew Morton
2005-03-18 10:38 ` Steven Rostedt
2005-03-18 11:07 ` Andrew Morton
2005-03-18 12:10 ` Steven Rostedt
2005-03-17 9:58 ` [patch 0/3] j_state_lock, j_list_lock, remove-bitlocks Steven Rostedt
2005-03-11 9:28 ` [patch] Real-Time Preemption, -RT-2.6.11-final-V0.7.40-00 Ingo Molnar
2005-03-11 12:10 ` Andrew Walrond
2005-03-14 20:19 ` Tom Rini
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=Pine.LNX.4.58.0503141024530.697@localhost.localdomain \
--to=rostedt@goodmis.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rlrevell@joe-job.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