Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4559195imb; Wed, 6 Mar 2019 16:55:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwUxU4gAlrTo1x+iD7+J/kALV82/EbNCgSvg0gqlvBWmHdS2iJNzg48ef8Kc5M5ikNWYjCl X-Received: by 2002:a63:2a86:: with SMTP id q128mr8954052pgq.424.1551920153162; Wed, 06 Mar 2019 16:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551920153; cv=none; d=google.com; s=arc-20160816; b=D79RdZSQedBtk2fVkzyy/1hJNX7RUBAyEc/66VB7NzIUXOYwO1nZM1+PYNxOiOB0K9 +brOnB4eOO3vWVE7elzrOcF8ICjieTfaqcZj5u8wIlyN2bRm7aIVfSKBpxbT96NWQoQs xoYIKuXiSxTcJI4bHNV5FtSHe0CsX5EKzeYPXHfz1bJcm+t6oGIMaEIkbMEwBR+gh2LU WKU1sRuqKMEy2xzyYk26GbIlJ9oFHhyNu58/7QmuIinR16J7MyK5BiJa8lr4E8djmxJS JaJpIwaDnbO29qeYXZqShYS8nd/P1uMGxkWVnW/hiJ23LRJCjUiGT+hdWIVWq6N0md4n 7RvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=LzUzvXn27WiNxvJ8IPr81iGe94Qu2N96CNxY1RSVNhI=; b=chnM2TvxlVCRp8cNtk1lUNDpB2wQremyHjucPU5GOHKrzTDVbhyo6/GZecMdIGrB5X 4mB5oK81qDOUZTsSjs4lsH5sLd6buyYeyWXcNvG1fV+IRVxbn42vi7HN82gHYqCIStAw +KDAeALksPOtkWGuFZ5P8NB9TJD8hcxfHc0QoEeRRGp6zHdA5pnYc4fJB5Pp+TbiBMli L4Ddcrj4/IhpIcvhGEUT0EQDb1RD17gDG+S3xri5JBg2Xoq7bspfiCVO/kaiRjec4r6T AG495HRDC4qU8VNbKFQSEGTGoOH97dqZPyO2bg8gVN4aqOFijpspT3hvtyLINq05f44Y /j6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h78si2927500pfj.70.2019.03.06.16.55.34; Wed, 06 Mar 2019 16:55:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726186AbfCGAzL (ORCPT + 99 others); Wed, 6 Mar 2019 19:55:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbfCGAzL (ORCPT ); Wed, 6 Mar 2019 19:55:11 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E541681DE9; Thu, 7 Mar 2019 00:55:10 +0000 (UTC) Received: from jsavitz.bos.com (dhcp-17-166.bos.redhat.com [10.18.17.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id F38A060C1B; Thu, 7 Mar 2019 00:55:09 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Li Zefan , cgroups@vger.kernel.org Subject: [PATCH] cpuset: restore sanity to cpuset_cpus_allowed_fallback() Date: Wed, 6 Mar 2019 19:54:48 -0500 Message-Id: <1551920088-30685-1-git-send-email-jsavitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Mar 2019 00:55:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a process is limited by taskset (i.e. cpuset) to only be allowed to run on cpu N, and then cpu N is offlined via hotplug, the process will be assigned the current value of its cpuset cgroup's effective_cpus field in a call to do_set_cpus_allowed() in cpuset_cpus_allowed_fallback(). This argument's value does not makes sense for this case, because task_cs(tsk)->effective_cpus is modified by cpuset_hotplug_workfn() to reflect the new value of cpu_active_mask after cpu N is removed from the mask. While this may make sense for the cgroup affinity mask, it does not make sense on a per-task basis, as a task that was previously limited to only be run on cpu N will be limited to every cpu _except_ for cpu N after it is offlined/onlined via hotplug. Pre-patch behavior: $ grep Cpus /proc/$$/status Cpus_allowed: ff Cpus_allowed_list: 0-7 $ taskset -p 4 $$ pid 19202's current affinity mask: f pid 19202's new affinity mask: 4 $ grep Cpus /proc/self/status Cpus_allowed: 04 Cpus_allowed_list: 2 # echo off > /sys/devices/system/cpu/cpu2/online $ grep Cpus /proc/$$/status Cpus_allowed: 0b Cpus_allowed_list: 0-1,3 # echo on > /sys/devices/system/cpu/cpu2/online $ grep Cpus /proc/$$/status Cpus_allowed: 0b Cpus_allowed_list: 0-1,3 On a patched system, the final grep produces the following output instead: $ grep Cpus /proc/$$/status Cpus_allowed: ff Cpus_allowed_list: 0-7 This patch changes the above behavior by instead simply resetting the mask to cpu_possible_mask. Signed-off-by: Joel Savitz --- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 479743db6c37..5f65a2167bdf 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3243,7 +3243,7 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask) void cpuset_cpus_allowed_fallback(struct task_struct *tsk) { rcu_read_lock(); - do_set_cpus_allowed(tsk, task_cs(tsk)->effective_cpus); + do_set_cpus_allowed(tsk, cpu_possible_mask); rcu_read_unlock(); /* -- 2.20.1