Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp389989yba; Fri, 5 Apr 2019 08:40:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhu0nirE7afduKbl8x/g8cwhWNwruNySGfllkDrBMpV4fGai9KT0lX+5KA11kmuPTFE0W8 X-Received: by 2002:a62:415d:: with SMTP id o90mr13230392pfa.236.1554478816986; Fri, 05 Apr 2019 08:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554478816; cv=none; d=google.com; s=arc-20160816; b=LqQxPcqluM++Mr56SDp9PTVS0IXMJW6vWbBhKCy8o9xhNmogC13xYD+UBqJ/asOvXM M3yPp+H5XBrPJex1uYDyRtZ5/Nzwp/rSpl9I+i6OG4VCXOfEBzTGCzs87bCqjw0Aafbv w4xY8NzRoMnklJYbn3IrUbL1Bwtn5BytdYdBXiUqPLE75yoTk6KPUc+bXd0tBZmVQKHu SRh0htJUOHoR/ZjYy34Z3V2E70TJvjoDgU8X2vAl+F2XSOOEtuycll8DbRkobxGUXK2h hjFXpzQCIVmvqZmqB25XRLfPbHJAhTsRGr+Vl9O4x6v8dYjpqoCfzgY3RZBCyys8/rCj jDPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Qqyktl9dpwCcjGJcKMTHlRd6muYfE+fK8iJlpavdGXI=; b=PYYocV1oNyX0slXT7KPCJJQim/4syGAnoCQwJMi5p0sU3PWAwaolb8Z7mxemYKoNm5 Rh1m2TcJ24q206b9qEMIJm/cCabwSM9QvJdDjUqHMWbOlxGS5DAGkoXN4Upe0Rp8Wogg gHUMkxss5JKB2Xm34/WLWPGdK05nsP7myiWeDW9bb0TDVijACnmfGDFMWip88iFUfp7i OYbntsmuSJsg29eJhm5SNH8EWpCB+Sg98AiZTsqcpBAP877nEBxLH7s5Z+hloPZmX9zW s9PaPMxzJghXZBO/MP8jqVsxH19z9xASTyI6wV+R+avKli7k4rrgnUuxSN1GpqjNqyTn yqpg== 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 i1si19411209pgb.322.2019.04.05.08.40.01; Fri, 05 Apr 2019 08:40:16 -0700 (PDT) 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 S1731247AbfDEPiB (ORCPT + 99 others); Fri, 5 Apr 2019 11:38:01 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:41551 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbfDEPiB (ORCPT ); Fri, 5 Apr 2019 11:38:01 -0400 Received: by mail-ot1-f68.google.com with SMTP id 64so6003204otb.8 for ; Fri, 05 Apr 2019 08:38:00 -0700 (PDT) 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; bh=Qqyktl9dpwCcjGJcKMTHlRd6muYfE+fK8iJlpavdGXI=; b=LXfdQxJ/b44SLzYrZeOJ3nl35fmNraBCPwVrT1ZG/tBWU/Ug/2RRA0/MaeYp/AEMf0 pXNfnTpdUhqV/8D2Nmn/WJaELm7e1ILm1qgvO6lqXHcksv/RbsHKJXv+lm8L8n7Fevcy 4r57icdqWaP6CvaUBuzzc54JvJI2BDj+2Q1e4+zwNi910vRj2rwb4zHbHvn4Gl5512Az Y7pdTjlr9hjJJ8pt8iWUal+bDo7XMinhh6yGlO4wP/KbZGsk13X8ZcOsviUKXy2P8wyV a2yS9IVgFTCCvg7qeqmp1w/RIqT4txYwevBMnn0GbfW2Tqc9/WyPlX3UkJr5WZDoTgm7 UYiw== X-Gm-Message-State: APjAAAUNwehN5YEXGbwFQpYHA3F6caOduuUAfjNpqGotz8xggDCSFWcS JsiFClWIkvIt1WxikpQ+A034cpGAXPWQzVCXmdWpWb6U X-Received: by 2002:a9d:5e15:: with SMTP id d21mr9335213oti.138.1554478680174; Fri, 05 Apr 2019 08:38:00 -0700 (PDT) MIME-Version: 1.0 References: <1554478619-12239-1-git-send-email-jsavitz@redhat.com> In-Reply-To: <1554478619-12239-1-git-send-email-jsavitz@redhat.com> From: Joel Savitz Date: Fri, 5 Apr 2019 11:37:49 -0400 Message-ID: Subject: Fwd: [RESEND PATCH] cpuset: restore sanity to cpuset_cpus_allowed_fallback() To: linux-kernel@vger.kernel.org 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 ---------- Forwarded message --------- From: Joel Savitz Date: Fri, Apr 5, 2019 at 11:37 AM Subject: [RESEND PATCH] cpuset: restore sanity to cpuset_cpus_allowed_fallback() To: Cc: Joel Savitz , Li Zefan , 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