linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 4.4.86-rt99: fix sync breakage between nr_cpus_allowed and cpus_allowed
@ 2017-11-15 19:25 joe.korty
  2017-11-17 22:48 ` Steven Rostedt
  0 siblings, 1 reply; 9+ messages in thread
From: joe.korty @ 2017-11-15 19:25 UTC (permalink / raw)
  To: Thomas Gleixner, Peter Zijlstra, Steven Rostedt; +Cc: Linux Kernel Mailing List

4.4.86-rt99's patch

  0037-Intrduce-migrate_disable-cpu_light.patch

introduces a place where a task's cpus_allowed mask is
updated without a corresponding update to nr_cpus_allowed.

This path is executed when task affinity is changed while
migrate_disabled() is true.  As there is no code present
to set nr_cpus_allowed when the migrate_disable state is
dropped, the scheduler at that point on may make incorrect
scheduling decisions for this task.

My testing consists of temporarily adding a

 if (tsk_nr_cpus_allowed(p) == cpumask_weight(tsk_cpus_allowed(p))
 	printk_ratelimited(...)

stmt to schedule() and running a simple affinity rotation
program I wrote, one that rotates the threads of stress(1).
While rotating, I got the expected kernel error messages.
With this patch applied the messages disappeared.

Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com>

Index: b/kernel/sched/core.c
===================================================================
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1220,6 +1220,7 @@ void do_set_cpus_allowed(struct task_str
 	lockdep_assert_held(&p->pi_lock);
 
 	if (__migrate_disabled(p)) {
+		p->nr_cpus_allowed = cpumask_weight(new_mask);
 		cpumask_copy(&p->cpus_allowed, new_mask);
 		return;
 	}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-29 14:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-15 19:25 [PATCH] 4.4.86-rt99: fix sync breakage between nr_cpus_allowed and cpus_allowed joe.korty
2017-11-17 22:48 ` Steven Rostedt
2017-11-20 16:30   ` joe.korty
2017-11-21  4:02     ` Steven Rostedt
2017-11-21  4:57       ` Steven Rostedt
2017-11-21 14:33         ` joe.korty
2017-11-21 15:33           ` joe.korty
2017-11-29  0:22             ` Steven Rostedt
2017-11-29 14:24               ` joe.korty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).