Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5050767imb; Thu, 7 Mar 2019 06:43:55 -0800 (PST) X-Google-Smtp-Source: APXvYqx6fp+8v4XF8KxVRwzEKHrr1b/U3Qd9YjlAZRMGWBgIYZPfeDInbFk/rRjOth7OIIhcq450 X-Received: by 2002:a17:902:82cc:: with SMTP id u12mr13406468plz.189.1551969835236; Thu, 07 Mar 2019 06:43:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551969835; cv=none; d=google.com; s=arc-20160816; b=niLpXhA3wsUak6XCZAN1CD/6xSDPq5g5XvzJxP9WxLf+iNTUwbxm7HK+LYR+PUWC0V lX9SuG+SV9YYg/so83p5YmYVQvplfb5xb+g6XgbLc1U/txIFgbG4IFe0d+4rTo9bP8NP XfdDrzbt8nxxsLzlCxewevsfjson8QuM7EBggOMPc9TVcF8LBMmzHrrQX5z8vAx8P6rx PkyiQxV5iuZ1qmpi/qQmaIqvdHPROQDUTugJ56+b19o4bjjJyqctYJigo++Iw6+SBBQ3 dn6g6xfXbd0A9tGgx5fB+lOuddhyLcUXtfXEu1t9R0vwAi0Tjf0zYML3UY7vQL1aLlA5 PfHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=9BNOU1eQnXvarrJnoSbHAXXCUv+Lt1cs6Wfh7qz4T8Q=; b=0ntfiXiWM3TnqwLnpTsKz2MNmhyQCQr+vlRH+kLCca51AQmFJl96UGrOCSIOU38szu WV8N3fNQ0T6WwMSZGv1cnjLHYHPP8KDm9w7u2wzT6mD0063+XRn6y/FZbfOYYT7OBX1X Y0K7jWLT8PLkTAcLoXXBM76ZxtlaC+wnkS2b7KarmU7M/p27KNMeanEfsgQdSnOWzTMI w90vvi80t1BCXGdqmVzsdhPeXCr9Zs1+Vmyx9YBuhllD0wzxtWyW1BeRayJ2rq7F8NtK DYSvPocK5wSIutsUxkdt3zEjl5vdqhari6fIe74GKU2c0P3qXVTE8O5MAjK6ywBlc5tH Ne4w== 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 j2si4659412pfb.268.2019.03.07.06.43.39; Thu, 07 Mar 2019 06:43:55 -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 S1726233AbfCGOnL (ORCPT + 99 others); Thu, 7 Mar 2019 09:43:11 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:35809 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbfCGOnK (ORCPT ); Thu, 7 Mar 2019 09:43:10 -0500 Received: by mail-vs1-f68.google.com with SMTP id e81so4601109vsd.2 for ; Thu, 07 Mar 2019 06:43:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9BNOU1eQnXvarrJnoSbHAXXCUv+Lt1cs6Wfh7qz4T8Q=; b=mLX9u+Rulq1LEEzu2wtTXHNcIiQjcAKsG4+ZCopcStBSktEBnT0ZLersV8hwe1FPnt f23L0uO2w5OlnPvYb36vVThwozyLSnLgcxnIxgFQ+e0JBAE0QmYnvJWNCSoqVpm3h8Vb Q/WoI0MPlk1hc+zU59R5Lz340lGEV30eOQhrg5NaVilPGPtX/zLH/PkIVyPYqGgKvFiZ BM3cibrncdVQcUvsQ4X88KaH9fXBKYW3JA6GbIclgUwXmyGrW6Sg/YJsSWVzVUcDrSm5 3l/CYnXSmgkES7B07wTMVJ/RbQjoA/ht4N+t3WcGdoSVxqrE2/mIFhMZM35Q7VGdhb01 Msmg== X-Gm-Message-State: APjAAAU5V3NBGWXVfyrVtr8SB8KK7mUsMcqzJIE4FND8o7ObqlmBYvWB Cb7e6bmg7BXlBZzAjPKMwQDvBXts+2pg9ryRvzmplfMLt4c= X-Received: by 2002:a67:fc13:: with SMTP id o19mr7312628vsq.123.1551969789154; Thu, 07 Mar 2019 06:43:09 -0800 (PST) MIME-Version: 1.0 References: <1551920088-30685-1-git-send-email-jsavitz@redhat.com> In-Reply-To: <1551920088-30685-1-git-send-email-jsavitz@redhat.com> From: Joel Savitz Date: Thu, 7 Mar 2019 09:42:58 -0500 Message-ID: Subject: Re: [PATCH] cpuset: restore sanity to cpuset_cpus_allowed_fallback() To: linux-kernel@vger.kernel.org Cc: Li Zefan , cgroups@vger.kernel.org, Philip Auld Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 6, 2019 at 7:55 PM Joel Savitz wrote: > > 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 >