public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Udo van den Heuvel <udovdh@xs4all.nl>
Cc: RT <linux-rt-users@vger.kernel.org>
Subject: Re: 2.6.33.1-rt11 BUG: sleeping function called from invalid context at kernel/rtmutex.c:684
Date: Tue, 6 Apr 2010 10:07:26 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1004061005300.32352@localhost.localdomain> (raw)
In-Reply-To: <4BB8587F.40307@xs4all.nl>

On Sun, 4 Apr 2010, Udo van den Heuvel wrote:

> Hello,
> 
> I see a load of these after booting into 2.6.33.1-rt11:
> 
> BUG: sleeping function called from invalid context at kernel/rtmutex.c:684
> pcnt: 1 0 in_atomic(): 1, irqs_disabled(): 0, pid: 1507, name: md1_raid5
> Pid: 1507, comm: md1_raid5 Not tainted 2.6.33.1-rt11 #1
> Call Trace:
>  [<ffffffff8138fb8c>] ? rt_spin_lock+0x2c/0x70
>  [<ffffffff812becc4>] ? __raid_run_ops+0x304/0xc60
>  [<ffffffff812c0ccd>] ? handle_stripe+0x6bd/0x1a70
>  [<ffffffff8104b460>] ? mod_timer+0x150/0x200
>  [<ffffffff812c23f6>] ? raid5d+0x376/0x4f0
>  [<ffffffff8138e5bd>] ? schedule_timeout+0x22d/0x2b0
>  [<ffffffff8138fb8c>] ? rt_spin_lock+0x2c/0x70
>  [<ffffffff812cd0f3>] ? md_thread+0x53/0x120
>  [<ffffffff810573a0>] ? autoremove_wake_function+0x0/0x30
>  [<ffffffff812cd0a0>] ? md_thread+0x0/0x120
>  [<ffffffff81057016>] ? kthread+0x96/0xa0
>  [<ffffffff81037908>] ? finish_task_switch+0x58/0xd0
>  [<ffffffff810032d4>] ? kernel_thread_helper+0x4/0x10
>  [<ffffffff81056f80>] ? kthread+0x0/0xa0
>  [<ffffffff810032d0>] ? kernel_thread_helper+0x0/0x10
> 
> As these appear to be touching my raid array I am quite eager to learn
> how I can fix the BUGs.
> 
> Please have a look and explain.

That's caused by the get_cpu()/put_cpu() preempt disabled region. Can
you try the following (untested) patch ?

Thanks,

	tglx
---
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ceb24af..b61eaa6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1149,8 +1149,9 @@ static void __raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
 	struct raid5_percpu *percpu;
 	unsigned long cpu;
 
-	cpu = get_cpu();
+	cpu = raw_smp_processor_id();
 	percpu = per_cpu_ptr(conf->percpu, cpu);
+	spin_lock(&percpu->lock);
 	if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) {
 		ops_run_biofill(sh);
 		overlap_clear++;
@@ -1202,7 +1203,7 @@ static void __raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
 			if (test_and_clear_bit(R5_Overlap, &dev->flags))
 				wake_up(&sh->raid_conf->wait_for_overlap);
 		}
-	put_cpu();
+	spin_unlock(&percpu->lock);
 }
 
 #ifdef CONFIG_MULTICORE_RAID456
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index dd70835..2db71cd 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -400,6 +400,7 @@ struct raid5_private_data {
 					    */
 	/* per cpu variables */
 	struct raid5_percpu {
+		spinlock_t	lock;	     /* Protection for -RT */
 		struct page	*spare_page; /* Used when checking P/Q in raid6 */
 		void		*scribble;   /* space for constructing buffer
 					      * lists and performing address

  parent reply	other threads:[~2010-04-06  8:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-04  9:14 2.6.33.1-rt11 BUG: sleeping function called from invalid context at kernel/rtmutex.c:684 Udo van den Heuvel
2010-04-04  9:17 ` Udo van den Heuvel
2010-04-06  8:07 ` Thomas Gleixner [this message]
2010-04-06 13:34   ` Udo van den Heuvel
2010-04-06 13:43     ` Luis Claudio R. Goncalves
2010-04-06 14:01       ` Udo van den Heuvel
2010-04-06 14:39     ` Thomas Gleixner

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=alpine.LFD.2.00.1004061005300.32352@localhost.localdomain \
    --to=tglx@linutronix.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=udovdh@xs4all.nl \
    /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