Skip to contentSkip to conversation

3.0.36-rt58-rc1 stable review

PATCH In review Steven Rostedt 3 participants 25 messages Jul 18, 2012 – Jul 31, 2012

Subsystems (7)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover 3.0.36-rt58-rc1 stable review

Dear RT Folks,

This is the RT stable review cycle of patch 3.0.36-rt58-rc1.

Please scream at me if I messed something up. Please test the patches too.

The -rc release will be uploaded to kernel.org and will be deleted when the final release is out. This is just a review release (or release candidate).

The pre-releases will not be pushed to the git repository, only the final release is.

If all goes well, this patch will be converted to the next main release on 7/20/2012.

Enjoy,

-- Steve

To build 3.0.36-rt58-rc1 directly, the following patches should be applied:

http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.xz

http://www.kernel.org/pub/linux/kernel/v3.0/patch-3.0.36.xz

http://www.kernel.org/pub/linux/kernel/projects/rt/3.0/patch-3.0.36-rt58-rc1.patch.xz

You can also build from 3.0.36-rt57 by applying the incremental patch:

http://www.kernel.org/pub/linux/kernel/projects/rt/3.0/incr/patch-3.0.36-rt57-rt58-rc1.patch.xz

Changes from 3.0.36-rt57:

---

Carsten Emde (4):
Latency histogramms: Cope with backwards running local trace clock Latency histograms: Adjust timer, if already elapsed when programmed Disable RT_GROUP_SCHED in PREEMPT_RT_FULL
Latency histograms: Detect another yet overlooked sharedprio condition

Mike Galbraith (1):
fs, jbd: pull your plug when waiting for space

Steven Rostedt (5):
cpu/rt: Rework cpu down for PREEMPT_RT cpu/rt: Fix cpu_hotplug variable initialization
workqueue: Revert workqueue: Fix PF_THREAD_BOUND abuse
workqueue: Revert workqueue: Fix cpuhotplug trainwreck Linux 3.0.36-rt58-rc1

Thomas Gleixner (1):
slab: Prevent local lock deadlock

Yong Zhang (1):
perf: Make swevent hrtimer run in irq instead of softirq

----

 fs/jbd/checkpoint.c         |    2 +
 include/linux/cpu.h         |   14 +-
 include/linux/hrtimer.h     |    3 +
 include/linux/sched.h       |    9 +-
 include/linux/workqueue.h   |    5 +-
 init/Kconfig                |    1 +
 kernel/cpu.c                |  240 ++++++++++++++----
 kernel/events/core.c        |    1 +
 kernel/hrtimer.c            |   16 +-
 kernel/sched.c              |   82 +++++-
 kernel/trace/latency_hist.c |   74 +++---
 kernel/workqueue.c          |  578 +++++++++++++++++++++++++++++++------------
 localversion-rt             |    2 +-
 mm/slab.c                   |   26 +-
 14 files changed, 792 insertions(+), 261 deletions(-)
author maintainer
#1 lore raw

PATCH 1/12 Latency histogramms: Cope with backwards running local trace clock

From: Carsten Emde <[email protected]>

Thanks to the wonders of modern technology, the local trace clock can now run backwards. Since this never happened before, the time difference between now and somewhat earlier was expected to never become negative and, thus, stored in an unsigned integer variable. Nowadays, we need a signed integer to ensure that the value is stored as underflow in the related histogram. (In cases where this is not a misfunction, bipolar histograms can be used.)

This patch takes care that all latency variables are represented as signed integers and negative numbers are considered as histogram underflows.

In one of the misbehaving processors switching to global clock solved the problem:
echo global >/sys/kernel/debug/tracing/trace_clock

---
 include/linux/sched.h       |    2 +-
 kernel/trace/latency_hist.c |   71 ++++++++++++++++++++++---------------------
 2 files changed, 38 insertions(+), 35 deletions(-)
include/linux/sched.h +1 -1
index 77e132f..beffba3 100644
@@ -1580,7 +1580,7 @@ struct task_struct {
 #ifdef CONFIG_WAKEUP_LATENCY_HIST
 	u64 preempt_timestamp_hist;
 #ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
-	unsigned long timer_offset;
+	long timer_offset;
 #endif
 #endif
 #endif /* CONFIG_TRACING */
kernel/trace/latency_hist.c +37 -34

198 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#2 lore raw

PATCH 2/12 Latency histograms: Adjust timer, if already elapsed when programmed

In reply to Steven Rostedt

From: Carsten Emde <[email protected]>

Nothing prevents a programmer from calling clock_nanosleep() with an already elapsed wakeup time in absolute time mode or with a too small delay in relative time mode. Such timers cannot wake up in time and, thus, should be corrected when entered into the missed timers latency histogram (CONFIG_MISSED_TIMERS_HIST).

This patch marks such timers and uses a corrected expiration time.

---
 include/linux/hrtimer.h |    3 +++
 kernel/hrtimer.c        |   16 ++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
include/linux/hrtimer.h +3 -0
index 0e37086..7408760 100644
@@ -113,6 +113,9 @@ struct hrtimer {
 	unsigned long			state;
 	struct list_head		cb_entry;
 	int				irqsafe;
+#ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
+	ktime_t 			praecox;
+#endif
 #ifdef CONFIG_TIMER_STATS
 	int				start_pid;
 	void				*start_site;
kernel/hrtimer.c +14 -2
index bb07742..363965f 100644
@@ -1021,6 +1021,17 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
 #endif
 	}
 
+#ifdef CONFIG_MISSED_TIMER_OFFSETS_HIST
+	{
+		ktime_t now = new_base->get_time();
+
+		if (ktime_to_ns(tim) < ktime_to_ns(now))
+			timer->praecox = now;
+		else
+			timer->praecox = ktime_set(0, 0);
+	}
+#endif
+
 	hrtimer_set_expires_range_ns(timer, tim, delta_ns);
 
 	timer_stats_hrtimer_set_start_info(timer);
@@ -1458,8 +1469,9 @@ retry:
 			timer = container_of(node, struct hrtimer, node);
 
 			trace_hrtimer_interrupt(raw_smp_processor_id(),
-			    ktime_to_ns(ktime_sub(
-				hrtimer_get_expires(timer), basenow)),
+			    ktime_to_ns(ktime_sub(ktime_to_ns(timer->praecox) ?
+				timer->praecox : hrtimer_get_expires(timer),
+				basenow)),
 			    current,
 			    timer->function == hrtimer_wakeup ?
 			    container_of(timer, struct hrtimer_sleeper,
Signature · 1 line
1.7.10.4
author maintainer
#3 lore raw

PATCH 3/12 Disable RT_GROUP_SCHED in PREEMPT_RT_FULL

In reply to Steven Rostedt

From: Carsten Emde <[email protected]>

Strange CPU stalls have been observed in RT when RT_GROUP_SCHED was configured.

Disable it for now.

---
 init/Kconfig |    1 +
 1 file changed, 1 insertion(+)
init/Kconfig +1 -0
index 89e40a4..5ed453f 100644
@@ -719,6 +719,7 @@ config RT_GROUP_SCHED
 	bool "Group scheduling for SCHED_RR/FIFO"
 	depends on EXPERIMENTAL
 	depends on CGROUP_SCHED
+	depends on !PREEMPT_RT_FULL
 	default n
 	help
 	  This feature lets you explicitly allocate real CPU bandwidth
Signature · 1 line
1.7.10.4
author maintainer
#4 lore raw

PATCH 4/12 Latency histograms: Detect another yet overlooked sharedprio condition

In reply to Steven Rostedt

From: Carsten Emde <[email protected]>

While waiting for an RT process to be woken up, the previous process may go to wait and switch to another one with the same priority which then becomes current. This condition was not correctly recognized and led to erroneously high latency recordings during periods of low CPU load.

This patch correctly marks such latencies as sharedprio and prevents them from being recorded as actual system latency.

---
 kernel/trace/latency_hist.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/trace/latency_hist.c +3 -0
index d514eef..6a4c869 100644
@@ -935,6 +935,9 @@ static notrace void probe_wakeup_latency_hist_stop(void *v,
 		goto out;
 	}
 
+	if (current->prio == cpu_wakeup_task->prio)
+		per_cpu(wakeup_sharedprio, cpu) = 1;
+
 	/*
 	 * The task we are waiting for is about to be switched to.
 	 * Calculate latency and store it in histogram.
Signature · 1 line
1.7.10.4
author maintainer
#5 lore raw

PATCH 5/12 slab: Prevent local lock deadlock

In reply to Steven Rostedt

From: Thomas Gleixner <[email protected]>

On RT we avoid the cross cpu function calls and take the per cpu local locks instead. Now the code missed that taking the local lock on the cpu which runs the code must use the proper local lock functions and not a simple spin_lock(). Otherwise it deadlocks later when trying to acquire the local lock with the proper function.

---
 mm/slab.c |   26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
mm/slab.c +22 -4
index 5251b99..827e2d6 100644
@@ -737,8 +737,26 @@ slab_on_each_cpu(void (*func)(void *arg, int this_cpu), void *arg)
 {
 	unsigned int i;
 
+	get_cpu_light();
 	for_each_online_cpu(i)
 		func(arg, i);
+	put_cpu_light();
+}
+
+static void lock_slab_on(unsigned int cpu)
+{
+	if (cpu == smp_processor_id())
+		local_lock_irq(slab_lock);
+	else
+		local_spin_lock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock);
+}
+
+static void unlock_slab_on(unsigned int cpu)
+{
+	if (cpu == smp_processor_id())
+		local_unlock_irq(slab_lock);
+	else
+		local_spin_unlock_irq(slab_lock, &per_cpu(slab_lock, cpu).lock);
 }
 #endif
 
@@ -2625,10 +2643,10 @@ static void do_drain(void *arg, int cpu)
 {
 	LIST_HEAD(tmp);
 
-	spin_lock_irq(&per_cpu(slab_lock, cpu).lock);
+	lock_slab_on(cpu);
 	__do_drain(arg, cpu);
 	list_splice_init(&per_cpu(slab_free_list, cpu), &tmp);
-	spin_unlock_irq(&per_cpu(slab_lock, cpu).lock);
+	unlock_slab_on(cpu);
 	free_delayed(&tmp);
 }
 #endif
@@ -4099,9 +4117,9 @@ static void do_ccupdate_local(void *info)
 #else
 static void do_ccupdate_local(void *info, int cpu)
 {
-	spin_lock_irq(&per_cpu(slab_lock, cpu).lock);
+	lock_slab_on(cpu);
 	__do_ccupdate_local(info, cpu);
-	spin_unlock_irq(&per_cpu(slab_lock, cpu).lock);
+	unlock_slab_on(cpu);
 }
 #endif
 
Signature · 1 line
1.7.10.4
#6 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 8 lines · Steven Rostedt

From: Thomas Gleixner <[email protected]>

On RT we avoid the cross cpu function calls and take the per cpu local locks instead. Now the code missed that taking the local lock on the cpu which runs the code must use the proper local lock functions and not a simple spin_lock(). Otherwise it deadlocks later when trying to acquire the local lock with the proper function.

Quoted 6 lines
---
 mm/slab.c |   26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

This patch leads to a warning during boot on the ARM pandaboard:

[    0.225097] Brought up 2 CPUs
[    0.225097] SMP: Total of 2 processors activated (2007.19 BogoMIPS).
[    0.225952] 
[    0.225982] =============================================
[    0.225982] [ INFO: possible recursive locking detected ]
[    0.225982] 3.0.36-rt58 #1
[    0.225982] ---------------------------------------------
[    0.225982] swapper/0/1 is trying to acquire lock:
[    0.226013]  (&per_cpu(slab_lock, __cpu).lock){+.+...}, at: [<c0147544>] do_ccupdate_local+0x18/0x44
[    0.226043] 
[    0.226043] but task is already holding lock:
[    0.226043]  (&per_cpu(slab_lock, __cpu).lock){+.+...}, at: [<c014737c>] lock_slab_on+0x48/0x134
[    0.226074] 
[    0.226074] other info that might help us debug this:
[    0.226074]  Possible unsafe locking scenario:
[    0.226074] 
[    0.226074]        CPU0
[    0.226074]        ----
[    0.226074]   lock(&per_cpu(slab_lock, __cpu).lock);
[    0.226104]   lock(&per_cpu(slab_lock, __cpu).lock);
[    0.226104] 
[    0.226104]  *** DEADLOCK ***
[    0.226104] 
[    0.226104]  May be due to missing lock nesting notation
[    0.226104] 
[    0.226104] 2 locks held by swapper/0/1:
[    0.226135]  #0:  (cache_chain_mutex){+.+.+.}, at: [<c014a618>] kmem_cache_create+0x74/0x4bc
[    0.226135]  #1:  (&per_cpu(slab_lock, __cpu).lock){+.+...}, at: [<c014737c>] lock_slab_on+0x48/0x134
[    0.226165] 
[    0.226165] stack backtrace:
[    0.226196] [<c00681f8>] (unwind_backtrace+0x0/0xf0) from [<c00da918>] (__lock_acquire+0x1984/0x1ce8)
[    0.226196] [<c00da918>] (__lock_acquire+0x1984/0x1ce8) from [<c00db29c>] (lock_acquire+0x100/0x120)
[    0.226226] [<c00db29c>] (lock_acquire+0x100/0x120) from [<c0485c10>] (rt_spin_lock+0x4c/0x5c)
[    0.226257] [<c0485c10>] (rt_spin_lock+0x4c/0x5c) from [<c0147544>] (do_ccupdate_local+0x18/0x44)
[    0.226257] [<c0147544>] (do_ccupdate_local+0x18/0x44) from [<c01476e8>] (slab_on_each_cpu+0x2c/0x64)
[    0.226287] [<c01476e8>] (slab_on_each_cpu+0x2c/0x64) from [<c0149c70>] (do_tune_cpucache+0xd8/0x3e8)
[    0.226287] [<c0149c70>] (do_tune_cpucache+0xd8/0x3e8) from [<c014a154>] (enable_cpucache+0x50/0xcc)
[    0.226318] [<c014a154>] (enable_cpucache+0x50/0xcc) from [<c014a974>] (kmem_cache_create+0x3d0/0x4bc)
[    0.226318] [<c014a974>] (kmem_cache_create+0x3d0/0x4bc) from [<c0021e54>] (init_tmpfs+0x3c/0xe8)
[    0.226348] [<c0021e54>] (init_tmpfs+0x3c/0xe8) from [<c00083b4>] (kernel_init+0x80/0x150)
[    0.226379] [<c00083b4>] (kernel_init+0x80/0x150) from [<c0061e30>] (kernel_thread_exit+0x0/0x8)
[    0.239776] omap_hwmod: _populate_mpu_rt_base found no _mpu_rt_va for emif_fw
[    0.239776] omap_hwmod: _populate_mpu_rt_base found no _mpu_rt_va for l3_instr

Config is from arch/arm/configs/omap2plus_defconfig plus:

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_PREEMPT_RT_FULL=y

-Frank

author maintainer
#7 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 8 lines · Frank Rowand

Config is from arch/arm/configs/omap2plus_defconfig plus:

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_PREEMPT_RT_FULL=y

Interesting, I just booted my panda board against 3.0.36-rt58 with that config and these three set, and I didn't get this error.

-- Steve

#8 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 6 lines · Steven Rostedt
Quoted 4 lines · Frank Rowand

Config is from arch/arm/configs/omap2plus_defconfig plus:

Quoted 7 lines
Quoted 4 lines

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_PREEMPT_RT_FULL=y

Interesting, I just booted my panda board against 3.0.36-rt58 with that config and these three set, and I didn't get this error.

I don't know if it makes any difference, but my root fs is nfs mounted.

I'll try to look at this some more tomorrow.

-Frank

author maintainer
#9 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 12 lines · Frank Rowand
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · Frank Rowand

Config is from arch/arm/configs/omap2plus_defconfig plus:

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_PREEMPT_RT_FULL=y

Quoted 7 lines
Quoted 2 lines

Interesting, I just booted my panda board against 3.0.36-rt58 with that config and these three set, and I didn't get this error.

I don't know if it makes any difference, but my root fs is nfs mounted.

I'll try to look at this some more tomorrow.

Yeah, my root fs is on the sdcard. Did you get this bug every time or was it sporadic?

-- Steve

#10 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 16 lines · Steven Rostedt
Quoted 15 lines · Frank Rowand
Quoted 13 lines · Steven Rostedt
Quoted 8 lines · Frank Rowand

Config is from arch/arm/configs/omap2plus_defconfig plus:

CONFIG_USB_EHCI_HCD=y
CONFIG_USB_NET_SMSC95XX=y
CONFIG_PREEMPT_RT_FULL=y

Interesting, I just booted my panda board against 3.0.36-rt58 with that config and these three set, and I didn't get this error.

Quoted 7 lines
Quoted 4 lines

I don't know if it makes any difference, but my root fs is nfs mounted.

I'll try to look at this some more tomorrow.

Yeah, my root fs is on the sdcard. Did you get this bug every time or was it sporadic?

I get it every boot.

-Frank

author maintainer
#11 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 4 lines · Frank Rowand
Quoted 2 lines

Yeah, my root fs is on the sdcard. Did you get this bug every time or was it sporadic?

I get it every boot.

Can you try it with an SD card? I can set it up for nfs as well, but that would take a bit of time.

-- Steve

#12 lore raw

Re: [PATCH RT 05/12] slab: Prevent local lock deadlock

Quoted 9 lines · Steven Rostedt
Quoted 4 lines · Frank Rowand
Quoted 2 lines

Yeah, my root fs is on the sdcard. Did you get this bug every time or was it sporadic?

I get it every boot.

Can you try it with an SD card? I can set it up for nfs as well, but that would take a bit of time.

That would turn into a project for me, not likely to get to it soon. But I'll put it on my "try to get to" list.

-Frank

author maintainer
#13 lore raw

PATCH 6/12 fs, jbd: pull your plug when waiting for space

In reply to Steven Rostedt

From: Mike Galbraith <[email protected]>

With an -rt kernel, and a heavy sync IO load, tasks can jam up on journal locks without unplugging, which can lead to terminal IO starvation. Unplug and schedule when waiting for space.

---
 fs/jbd/checkpoint.c |    2 ++
 1 file changed, 2 insertions(+)
fs/jbd/checkpoint.c +2 -0
index e4b87bc..e24b2d5 100644
@@ -123,6 +123,8 @@ void __log_wait_for_space(journal_t *journal)
 		if (journal->j_flags & JFS_ABORT)
 			return;
 		spin_unlock(&journal->j_state_lock);
+		if (current->plug)
+			io_schedule();
 		mutex_lock(&journal->j_checkpoint_mutex);
 
 		/*
Signature · 1 line
1.7.10.4
author maintainer
#14 lore raw

PATCH 7/12 perf: Make swevent hrtimer run in irq instead of softirq

In reply to Steven Rostedt

From: Yong Zhang <[email protected]>

Otherwise we get a deadlock like below:

[ 1044.042749] BUG: scheduling while atomic: ksoftirqd/21/141/0x00010003
[ 1044.042752] INFO: lockdep is turned off.
[ 1044.042754] Modules linked in:
[ 1044.042757] Pid: 141, comm: ksoftirqd/21 Tainted: G        W    3.4.0-rc2-rt3-23676-ga723175-dirty #29
[ 1044.042759] Call Trace:
[ 1044.042761]  <IRQ>  [<ffffffff8107d8e5>] __schedule_bug+0x65/0x80
[ 1044.042770]  [<ffffffff8168978c>] __schedule+0x83c/0xa70
[ 1044.042775]  [<ffffffff8106bdd2>] ? prepare_to_wait+0x32/0xb0
[ 1044.042779]  [<ffffffff81689a5e>] schedule+0x2e/0xa0
[ 1044.042782]  [<ffffffff81071ebd>] hrtimer_wait_for_timer+0x6d/0xb0
[ 1044.042786]  [<ffffffff8106bb30>] ? wake_up_bit+0x40/0x40
[ 1044.042790]  [<ffffffff81071f20>] hrtimer_cancel+0x20/0x40
[ 1044.042794]  [<ffffffff8111da0c>] perf_swevent_cancel_hrtimer+0x3c/0x50
[ 1044.042798]  [<ffffffff8111da31>] task_clock_event_stop+0x11/0x40
[ 1044.042802]  [<ffffffff8111da6e>] task_clock_event_del+0xe/0x10
[ 1044.042805]  [<ffffffff8111c568>] event_sched_out+0x118/0x1d0
[ 1044.042809]  [<ffffffff8111c649>] group_sched_out+0x29/0x90
[ 1044.042813]  [<ffffffff8111ed7e>] __perf_event_disable+0x18e/0x200
[ 1044.042817]  [<ffffffff8111c343>] remote_function+0x63/0x70
[ 1044.042821]  [<ffffffff810b0aae>] generic_smp_call_function_single_interrupt+0xce/0x120
[ 1044.042826]  [<ffffffff81022bc7>] smp_call_function_single_interrupt+0x27/0x40
[ 1044.042831]  [<ffffffff8168d50c>] call_function_single_interrupt+0x6c/0x80
[ 1044.042833]  <EOI>  [<ffffffff811275b0>] ? perf_event_overflow+0x20/0x20
[ 1044.042840]  [<ffffffff8168b970>] ? _raw_spin_unlock_irq+0x30/0x70
[ 1044.042844]  [<ffffffff8168b976>] ? _raw_spin_unlock_irq+0x36/0x70
[ 1044.042848]  [<ffffffff810702e2>] run_hrtimer_softirq+0xc2/0x200
[ 1044.042853]  [<ffffffff811275b0>] ? perf_event_overflow+0x20/0x20
[ 1044.042857]  [<ffffffff81045265>] __do_softirq_common+0xf5/0x3a0
[ 1044.042862]  [<ffffffff81045c3d>] __thread_do_softirq+0x15d/0x200
[ 1044.042865]  [<ffffffff81045dda>] run_ksoftirqd+0xfa/0x210
[ 1044.042869]  [<ffffffff81045ce0>] ? __thread_do_softirq+0x200/0x200
[ 1044.042873]  [<ffffffff81045ce0>] ? __thread_do_softirq+0x200/0x200
[ 1044.042877]  [<ffffffff8106b596>] kthread+0xb6/0xc0
[ 1044.042881]  [<ffffffff8168b97b>] ? _raw_spin_unlock_irq+0x3b/0x70
[ 1044.042886]  [<ffffffff8168d994>] kernel_thread_helper+0x4/0x10
[ 1044.042889]  [<ffffffff8107d98c>] ? finish_task_switch+0x8c/0x110
[ 1044.042894]  [<ffffffff8168b97b>] ? _raw_spin_unlock_irq+0x3b/0x70
[ 1044.042897]  [<ffffffff8168bd5d>] ? retint_restore_args+0xe/0xe
[ 1044.042900]  [<ffffffff8106b4e0>] ? kthreadd+0x1e0/0x1e0
[ 1044.042902]  [<ffffffff8168d990>] ? gs_change+0xb/0xb
---
 kernel/events/core.c |    1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index 08315ad..1c876e02 100644
@@ -5702,6 +5702,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event)
 
 	hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	hwc->hrtimer.function = perf_swevent_hrtimer;
+	hwc->hrtimer.irqsafe = 1;
 
 	/*
 	 * Since hrtimers have a fixed rate, we can do a static freq->period
Signature · 1 line
1.7.10.4
author maintainer
#15 lore raw

PATCH 8/12 cpu/rt: Rework cpu down for PREEMPT_RT

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Bringing a CPU down is a pain with the PREEMPT_RT kernel because tasks can be preempted in many more places than in non-RT. In order to handle per_cpu variables, tasks may be pinned to a CPU for a while, and even sleep. But these tasks need to be off the CPU if that CPU is going down.

Several synchronization methods have been tried, but when stressed they failed. This is a new approach.

A sync_tsk thread is still created and tasks may still block on a lock when the CPU is going down, but how that works is a bit different. When cpu_down() starts, it will create the sync_tsk and wait on it to inform that current tasks that are pinned on the CPU are no longer pinned. But new tasks that are about to be pinned will still be allowed to do so at this time.

Then the notifiers are called. Several notifiers will bring down tasks that will enter these locations. Some of these tasks will take locks of other tasks that are on the CPU. If we don't let those other tasks continue, but make them block until CPU down is done, the tasks that the notifiers are waiting on will never complete as they are waiting for the locks held by the tasks that are blocked.

Thus we still let the task pin the CPU until the notifiers are done. After the notifiers run, we then make new tasks entering the pinned CPU sections grab a mutex and wait. This mutex is now a per CPU mutex in the hotplug_pcp descriptor.

To help things along, a new function in the scheduler code is created called migrate_me(). This function will try to migrate the current task off the CPU this is going down if possible. When the sync_tsk is created, all tasks will then try to migrate off the CPU going down. There are several cases that this wont work, but it helps in most cases.

After the notifiers are called and if a task can't migrate off but enters the pin CPU sections, it will be forced to wait on the hotplug_pcp mutex until the CPU down is complete. Then the scheduler will force the migration anyway.

Also, I found that THREAD_BOUND need to also be accounted for in the pinned CPU, and the migrate_disable no longer treats them special. This helps fix issues with ksoftirqd and workqueue that unbind on CPU down.

---
 include/linux/sched.h |    7 ++
 kernel/cpu.c          |  236 +++++++++++++++++++++++++++++++++++++++++--------
 kernel/sched.c        |   82 ++++++++++++++++-
 3 files changed, 285 insertions(+), 40 deletions(-)
include/linux/sched.h +7 -0
index beffba3..d25892e 100644
@@ -1908,6 +1908,10 @@ extern void do_set_cpus_allowed(struct task_struct *p,
 
 extern int set_cpus_allowed_ptr(struct task_struct *p,
 				const struct cpumask *new_mask);
+int migrate_me(void);
+void tell_sched_cpu_down_begin(int cpu);
+void tell_sched_cpu_down_done(int cpu);
+
 #else
 static inline void do_set_cpus_allowed(struct task_struct *p,
 				      const struct cpumask *new_mask)
@@ -1920,6 +1924,9 @@ static inline int set_cpus_allowed_ptr(struct task_struct *p,
 		return -EINVAL;
 	return 0;
 }
+static inline int migrate_me(void) { return 0; }
+static inline void tell_sched_cpu_down_begin(int cpu) { }
+static inline void tell_sched_cpu_down_done(int cpu) { }
 #endif
 
 #ifndef CONFIG_CPUMASK_OFFSTACK
kernel/cpu.c +198 -38

340 lines not on this page · raw message

kernel/sched.c +80 -2

100 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#16 lore raw

PATCH 9/12 cpu/rt: Fix cpu_hotplug variable initialization

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The commit "cpu/rt: Rework cpu down for PREEMPT_RT" changed the double meaning of the cpu_hotplug.lock, where it was a spinlock for RT and a mutex for non-RT, to just a mutex for both. But the initialization of the variable was not updated to reflect this change.

---
 kernel/cpu.c |    4 ----
 1 file changed, 4 deletions(-)
kernel/cpu.c +0 -4
index 11e6e9a..3bcbf99 100644
@@ -54,11 +54,7 @@ static struct {
 	int refcount;
 } cpu_hotplug = {
 	.active_writer = NULL,
-#ifdef CONFIG_PREEMPT_RT_FULL
-	.lock = __SPIN_LOCK_UNLOCKED(cpu_hotplug.lock),
-#else
 	.lock = __MUTEX_INITIALIZER(cpu_hotplug.lock),
-#endif
 	.refcount = 0,
 };
 
Signature · 1 line
1.7.10.4
author maintainer
#17 lore raw

PATCH 10/12 workqueue: Revert workqueue: Fix PF_THREAD_BOUND abuse

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Revert commit

Author: Peter Zijlstra <[email protected]>
Date: Mon Oct 3 12:43:25 2011 +0200
workqueue: Fix PF_THREAD_BOUND abuse

As TREAD_BOUND no longer affects cpu down, and this code introduced a lot of races with taking down a CPU.

---
 kernel/workqueue.c |   29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)
kernel/workqueue.c +9 -20
index a08a963..53268e3 100644
@@ -1287,14 +1287,8 @@ __acquires(&gcwq->lock)
 			return false;
 		if (task_cpu(task) == gcwq->cpu &&
 		    cpumask_equal(&current->cpus_allowed,
-				  get_cpu_mask(gcwq->cpu))) {
-			/*
-			 * Since we're binding to a particular cpu and need to
-			 * stay there for correctness, mark us PF_THREAD_BOUND.
-			 */
-			task->flags |= PF_THREAD_BOUND;
+				  get_cpu_mask(gcwq->cpu)))
 			return true;
-		}
 		spin_unlock_irq(&gcwq->lock);
 
 		/*
@@ -1308,18 +1302,6 @@ __acquires(&gcwq->lock)
 	}
 }
 
-static void worker_unbind_and_unlock(struct worker *worker)
-{
-	struct global_cwq *gcwq = worker->gcwq;
-	struct task_struct *task = worker->task;
-
-	/*
-	 * Its no longer required we're PF_THREAD_BOUND, the work is done.
-	 */
-	task->flags &= ~PF_THREAD_BOUND;
-	spin_unlock_irq(&gcwq->lock);
-}
-
 static struct worker *alloc_worker(void)
 {
 	struct worker *worker;
@@ -1382,9 +1364,15 @@ static struct worker *create_worker(struct global_cwq *gcwq, bool bind)
 	if (IS_ERR(worker->task))
 		goto fail;
 
+	/*
+	 * A rogue worker will become a regular one if CPU comes
+	 * online later on.  Make sure every worker has
+	 * PF_THREAD_BOUND set.
+	 */
 	if (bind && !on_unbound_cpu)
 		kthread_bind(worker->task, gcwq->cpu);
 	else {
+		worker->task->flags |= PF_THREAD_BOUND;
 		if (on_unbound_cpu)
 			worker->flags |= WORKER_UNBOUND;
 	}
@@ -2061,7 +2049,7 @@ repeat:
 		if (keep_working(gcwq))
 			wake_up_worker(gcwq);
 
-		worker_unbind_and_unlock(rescuer);
+		spin_unlock_irq(&gcwq->lock);
 	}
 
 	schedule();
@@ -2957,6 +2945,7 @@ struct workqueue_struct *__alloc_workqueue_key(const char *name,
 		if (IS_ERR(rescuer->task))
 			goto err;
 
+		rescuer->task->flags |= PF_THREAD_BOUND;
 		wake_up_process(rescuer->task);
 	}
 
Signature · 1 line
1.7.10.4
author maintainer
#18 lore raw

PATCH 11/12 workqueue: Revert workqueue: Fix cpuhotplug trainwreck

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

Revert

Author: Peter Zijlstra <[email protected]>
Date: Fri Sep 30 11:57:58 2011 +0200
workqueue: Fix cpuhotplug trainwreck

As TREAD_BOUND no longer affects cpu down, and this code introduced a lot of races with taking down a CPU.

Conflicts:

include/linux/cpu.h
include/linux/workqueue.h

---
 include/linux/cpu.h       |   14 +-
 include/linux/workqueue.h |    5 +-
 kernel/workqueue.c        |  561 +++++++++++++++++++++++++++++++++------------
 3 files changed, 419 insertions(+), 161 deletions(-)
include/linux/cpu.h +6 -8
index d7d7a12..c7823c5 100644
@@ -60,16 +60,14 @@ enum {
 	 */
 	CPU_PRI_SCHED_ACTIVE	= INT_MAX,
 	CPU_PRI_CPUSET_ACTIVE	= INT_MAX - 1,
-
-	/* migration should happen before other stuff but after perf */
-	CPU_PRI_PERF			= 20,
-	CPU_PRI_MIGRATION		= 10,
-	CPU_PRI_WORKQUEUE_ACTIVE	= 5,  /* prepare workqueues for others */
-	CPU_PRI_NORMAL			= 0,
-	CPU_PRI_WORKQUEUE_INACTIVE	= -5, /* flush workqueues after others */
-
 	CPU_PRI_SCHED_INACTIVE	= INT_MIN + 1,
 	CPU_PRI_CPUSET_INACTIVE	= INT_MIN,
+
+	/* migration should happen before other stuff but after perf */
+	CPU_PRI_PERF		= 20,
+	CPU_PRI_MIGRATION	= 10,
+	/* prepare workqueues for other notifiers */
+	CPU_PRI_WORKQUEUE	= 5,
 };
 
 #ifdef CONFIG_SMP
include/linux/workqueue.h +2 -3
index 5b86348..6c56a14 100644
@@ -254,10 +254,9 @@ enum {
 	WQ_MEM_RECLAIM		= 1 << 3, /* may be used for memory reclaim */
 	WQ_HIGHPRI		= 1 << 4, /* high priority */
 	WQ_CPU_INTENSIVE	= 1 << 5, /* cpu instensive workqueue */
-	WQ_NON_AFFINE		= 1 << 6, /* free to move works around cpus */
 
-	WQ_DYING		= 1 << 7, /* internal: workqueue is dying */
-	WQ_RESCUER		= 1 << 8, /* internal: workqueue has rescuer */
+	WQ_DYING		= 1 << 6, /* internal: workqueue is dying */
+	WQ_RESCUER		= 1 << 7, /* internal: workqueue has rescuer */
 
 	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
 	WQ_MAX_UNBOUND_PER_CPU	= 4,	  /* 4 * #cpus for unbound wq */
kernel/workqueue.c +411 -150

722 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#19 lore raw

PATCH 12/12 Linux 3.0.36-rt58-rc1

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

---
 localversion-rt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
localversion-rt +1 -1
index c06cc43..1fdcd49 100644
@@ -1 +1 @@
--rt57
+-rt58-rc1
Signature · 1 line
1.7.10.4
#20 lore raw
In reply to Steven Rostedt
Quoted 1 line · Steven Rostedt

Please test the patches too.

Your hotplug stress test script made x3550 M3 box fall over. It took a bit, but down she went. 64 core test box fell over quickly, but that's very far from virgin source.. seems to be the same though.

[  255.016043] CPU 1 MCA<0>Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 7
Pid: 9914, comm: migration/7 Not tainted 3.0.36-rt57 #49
Call Trace:
 <NMI>  [<ffffffff814a0f7b>] panic+0x9b/0x1b0
 [<ffffffff810b0627>] watchdog_overflow_callback+0xd7/0xe0
 [<ffffffff810c3dad>] __perf_event_overflow+0x9d/0x240
 [<ffffffff810c066b>] ? perf_event_update_userpage+0x9b/0xe0
 [<ffffffff810c41a4>] perf_event_overflow+0x14/0x20
 [<ffffffff81015707>] intel_pmu_handle_irq+0x177/0x230
 [<ffffffff814a5549>] perf_event_nmi_handler+0x39/0xc0
 [<ffffffff814a727d>] notifier_call_chain+0x4d/0x70
 [<ffffffff814a72e3>] __atomic_notifier_call_chain+0x43/0x60
 [<ffffffff814a7311>] atomic_notifier_call_chain+0x11/0x20
 [<ffffffff814a734e>] notify_die+0x2e/0x30
 [<ffffffff814a4699>] default_do_nmi+0x39/0x200
 [<ffffffff814a4a48>] do_nmi+0x78/0x80
 [<ffffffff814a44d0>] nmi+0x20/0x30
 [<ffffffff810a461a>] ? stop_machine_cpu_stop+0x6a/0xe0
 <<EOE>>  [<ffffffff810a47f4>] cpu_stopper_thread+0xf4/0x1d0
 [<ffffffff810a45b0>] ? wait_for_stop_done+0xa0/0xa0
 [<ffffffff814a1397>] ? __schedule+0x2c7/0x630
 [<ffffffff810a4700>] ? cpu_stop_queue_work+0x70/0x70
 [<ffffffff810a4700>] ? cpu_stop_queue_work+0x70/0x70
 [<ffffffff810702c6>] kthread+0xa6/0xb0
 [<ffffffff81056328>] ? do_exit+0x278/0x450
 [<ffffffff810016b2>] ? __switch_to+0xf2/0x370
 [<ffffffff81040f15>] ? finish_task_switch+0x55/0xd0
 [<ffffffff814aa6e4>] kernel_thread_helper+0x4/0x10
 [<ffffffff81070220>] ? __init_kthread_worker+0x50/0x50
 [<ffffffff814aa6e0>] ? gs_change+0x13/0x13
author maintainer
#21 lore raw
Quoted 7 lines · Mike Galbraith
Quoted 1 line · Steven Rostedt

Please test the patches too.

Your hotplug stress test script made x3550 M3 box fall over. It took a bit, but down she went. 64 core test box fell over quickly, but that's very far from virgin source.. seems to be the same though.

Thanks for the report. I know a few areas in the hotplug code that can still deadlock (but are hard to hit). But there's no easy fix for them. Basically, the only thing we can do is redesign cpu hotplug (I think someone is already trying to do that ;-).

But these patches do fix the main issues of cpu hotplug (albeit, making the code even uglier).

The panic below isn't telling much. We really need to know what the other CPUs were up to. This call trace is just telling us that one of the CPUs is waiting for other CPUs to stop or to finish something up.

-- Steve

Quoted 32 lines
[  255.016043] CPU 1 MCA<0>Kernel panic - not syncing: Watchdog detected hard LOCKUP on cpu 7
Pid: 9914, comm: migration/7 Not tainted 3.0.36-rt57 #49
Call Trace:
 <NMI>  [<ffffffff814a0f7b>] panic+0x9b/0x1b0
 [<ffffffff810b0627>] watchdog_overflow_callback+0xd7/0xe0
 [<ffffffff810c3dad>] __perf_event_overflow+0x9d/0x240
 [<ffffffff810c066b>] ? perf_event_update_userpage+0x9b/0xe0
 [<ffffffff810c41a4>] perf_event_overflow+0x14/0x20
 [<ffffffff81015707>] intel_pmu_handle_irq+0x177/0x230
 [<ffffffff814a5549>] perf_event_nmi_handler+0x39/0xc0
 [<ffffffff814a727d>] notifier_call_chain+0x4d/0x70
 [<ffffffff814a72e3>] __atomic_notifier_call_chain+0x43/0x60
 [<ffffffff814a7311>] atomic_notifier_call_chain+0x11/0x20
 [<ffffffff814a734e>] notify_die+0x2e/0x30
 [<ffffffff814a4699>] default_do_nmi+0x39/0x200
 [<ffffffff814a4a48>] do_nmi+0x78/0x80
 [<ffffffff814a44d0>] nmi+0x20/0x30
 [<ffffffff810a461a>] ? stop_machine_cpu_stop+0x6a/0xe0
 <<EOE>>  [<ffffffff810a47f4>] cpu_stopper_thread+0xf4/0x1d0
 [<ffffffff810a45b0>] ? wait_for_stop_done+0xa0/0xa0
 [<ffffffff814a1397>] ? __schedule+0x2c7/0x630
 [<ffffffff810a4700>] ? cpu_stop_queue_work+0x70/0x70
 [<ffffffff810a4700>] ? cpu_stop_queue_work+0x70/0x70
 [<ffffffff810702c6>] kthread+0xa6/0xb0
 [<ffffffff81056328>] ? do_exit+0x278/0x450
 [<ffffffff810016b2>] ? __switch_to+0xf2/0x370
 [<ffffffff81040f15>] ? finish_task_switch+0x55/0xd0
 [<ffffffff814aa6e4>] kernel_thread_helper+0x4/0x10
 [<ffffffff81070220>] ? __init_kthread_worker+0x50/0x50
 [<ffffffff814aa6e0>] ? gs_change+0x13/0x13
#22 lore raw
Quoted 5 lines · Steven Rostedt
Quoted 4 lines · Mike Galbraith
Quoted 1 line · Steven Rostedt

Please test the patches too.

Quoted 8 lines
Quoted 3 lines

Your hotplug stress test script made x3550 M3 box fall over. It took a bit, but down she went. 64 core test box fell over quickly, but that's very far from virgin source.. seems to be the same though.

Thanks for the report. I know a few areas in the hotplug code that can still deadlock (but are hard to hit). But there's no easy fix for them. Basically, the only thing we can do is redesign cpu hotplug (I think someone is already trying to do that ;-).

Every kernel I've fed you script to has died sooner or later, so I wish him fair sailing. Here there be sea monsters ;-)

-Mike

author maintainer
#23 lore raw
Quoted 2 lines · Mike Galbraith

Every kernel I've fed you script to has died sooner or later, so I wish him fair sailing. Here there be sea monsters ;-)

I'm curious. Can my script bring down a non-rt kernel?

-- Steve

#24 lore raw
Quoted 6 lines · Steven Rostedt
Quoted 2 lines · Mike Galbraith

Every kernel I've fed you script to has died sooner or later, so I wish him fair sailing. Here there be sea monsters ;-)

I'm curious. Can my script bring down a non-rt kernel?

Yeah, it took a couple non-rt (and virgin) kernels down on my 64 core box.

-Mike