3.2.23-rt37-rc1 stable review
Subsystems (3)
Steven Rostedt
reviewercover 3.2.23-rt37-rc1 stable review
Dear RT Folks,
This is the RT stable review cycle of patch 3.2.23-rt37-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/19/2012.
Enjoy,
-- Steve
To build 3.2.23-rt37-rc1 directly, the following patches should be applied:
http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.tar.xz
http://www.kernel.org/pub/linux/kernel/v3.x/patch-3.2.23.xz
http://www.kernel.org/pub/linux/kernel/projects/rt/3.2/patch-3.2.23-rt37-rc1.patch.xz
You can also build from 3.2.23-rt36 by applying the incremental patch:
http://www.kernel.org/pub/linux/kernel/projects/rt/3.2/incr/patch-3.2.23-rt36-rt37-rc1.patch.xz
Changes from 3.2.23-rt36:
---
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.2.23-rt37-rc1
----
include/linux/cpu.h | 6 +- include/linux/sched.h | 7 + include/linux/workqueue.h | 5 +- kernel/cpu.c | 240 +++++++++++++++---- kernel/sched.c | 82 ++++++- kernel/workqueue.c | 578 ++++++++++++++++++++++++++++++++------------- localversion-rt | 2 +- 7 files changed, 704 insertions(+), 216 deletions(-)
Steven Rostedt
reviewerPATCH 1/5 cpu/rt: Rework cpu down for PREEMPT_RT
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
@@ -1933,6 +1933,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)
@@ -1945,6 +1949,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
Steven Rostedt
reviewerPATCH 2/5 cpu/rt: Fix cpu_hotplug variable initialization
In reply to Steven RostedtFrom: 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
@@ -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
Steven Rostedt
reviewerPATCH 3/5 workqueue: Revert workqueue: Fix PF_THREAD_BOUND abuse
In reply to Steven RostedtFrom: 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
@@ -1288,14 +1288,8 @@ __acquires(&gcwq->lock)return false;if (task_cpu (task) == gcwq->cpu &&cpumask_equal (¤t->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);/*
@@ -1309,18 +1303,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;
@@ -1383,9 +1365,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 ; }
@@ -2062,7 +2050,7 @@ repeat:if (keep_working (gcwq))wake_up_worker (gcwq); -worker_unbind_and_unlock (rescuer); +spin_unlock_irq (&gcwq->lock); }schedule ();
@@ -3011,6 +2999,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
Steven Rostedt
reviewerPATCH 4/5 workqueue: Revert workqueue: Fix cpuhotplug trainwreck
In reply to Steven RostedtFrom: 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.
--- include/linux/cpu.h | 6 +- include/linux/workqueue.h | 5 +- kernel/workqueue.c | 561 +++++++++++++++++++++++++++++++++------------ 3 files changed, 415 insertions(+), 157 deletions(-)
include/linux/cpu.h +2 -4
@@ -66,10 +66,8 @@ enum {/* 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 */ +/* prepare workqueues for other notifiers */ + CPU_PRI_WORKQUEUE = 5, };#define CPU_ONLINE 0x0002/* CPU (unsigned)v is up */
include/linux/workqueue.h +2 -3
@@ -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_DRAINING =1 <<7 ,/* internal: workqueue is draining */ -WQ_RESCUER =1 <<8 ,/* internal: workqueue has rescuer */ +WQ_DRAINING =1 <<6 ,/* internal: workqueue is draining */ +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
Steven Rostedt
reviewerPATCH 5/5 Linux 3.2.23-rt37-rc1
In reply to Steven RostedtFrom: Steven Rostedt <[email protected]>
--- localversion-rt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
localversion-rt +1 -1
@@ -1 +1 @@ --rt36 +-rt37-rc1
Signature · 1 line
1.7.10.4