From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422987AbdKQWtB (ORCPT ); Fri, 17 Nov 2017 17:49:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:48448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936953AbdKQWsy (ORCPT ); Fri, 17 Nov 2017 17:48:54 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15F05218B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Fri, 17 Nov 2017 17:48:51 -0500 From: Steven Rostedt To: joe.korty@concurrent-rt.com Cc: Thomas Gleixner , Peter Zijlstra , Linux Kernel Mailing List Subject: Re: [PATCH] 4.4.86-rt99: fix sync breakage between nr_cpus_allowed and cpus_allowed Message-ID: <20171117174851.2a253785@gandalf.local.home> In-Reply-To: <20171115192529.GA14158@zipoli.concurrent-rt.com> References: <20171115192529.GA14158@zipoli.concurrent-rt.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Nov 2017 14:25:29 -0500 joe.korty@concurrent-rt.com wrote: > 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(...) Have you tested v4.9-rt or 4.13-rt if it has the same bug? If it is a bug in 4.13-rt then it needs to go there first, and then backported to the stable releases (which I'm actually working on now). -- Steve > > 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 > > 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; > }