From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: [PATCH v10 1/8] cgroup/cpuset: Add top_cpuset check in update_tasks_cpumask() Date: Tue, 3 May 2022 12:21:42 -0400 Message-ID: <20220503162149.1764245-2-longman@redhat.com> References: <20220503162149.1764245-1-longman@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651594961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LdXD9yJFaOeo2pHNThXvtRNDE3czSMc0peQhxLvTF7o=; b=Pi/Lvj+2m14yNZaiiZcFxkExNvIRvr35Hg3PCzdGuGaZlJ//bpW50HdXcdE5IlF2QhECEQ 9A/vfxuBy2HA/c/b2ZYC06qZR5yZhU9XGX8SYR2WN1sUXFxtRKWTURfiCH/EKevO7UhS8c ZFaE8mDAU8kSUzYtgZ1WKpnpKIAKYZk= In-Reply-To: <20220503162149.1764245-1-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Shuah Khan Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kselftest-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton , Roman Gushchin , Phil Auld , Peter Zijlstra , Juri Lelli , Frederic Weisbecker , Marcelo Tosatti , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Waiman Long Right now, update_tasks_cpumask() is not supposed to be called with top cpuset. With cpuset partition that takes CPUs away from the top cpuset, we may want to consider adjusting the cpu_allows mask of the tasks in the top cpuset as well. However, we need more investigation to figure out a way to do that without breaking non-cgroup aware applications in the top cpuset. So move the top_cpuset check into update_tasks_cpumask() and add a comment about possible future work. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 9390bfd9f1cd..d90f33b068a3 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1128,6 +1128,14 @@ static void update_tasks_cpumask(struct cpuset *cs) struct css_task_iter it; struct task_struct *task; + /* + * TODO: With cpuset partition that takes CPUs away from the top + * cpuset, we may want to properly adjust the cpus_allowed mask of + * tasks in the top cpuset as well. + */ + if (cs == &top_cpuset) + return; + css_task_iter_start(&cs->css, 0, &it); while ((task = css_task_iter_next(&it))) set_cpus_allowed_ptr(task, cs->effective_cpus); @@ -2092,12 +2100,7 @@ static int update_prstate(struct cpuset *cs, int new_prs) update_flag(CS_CPU_EXCLUSIVE, cs, 0); } - /* - * Update cpumask of parent's tasks except when it is the top - * cpuset as some system daemons cannot be mapped to other CPUs. - */ - if (parent != &top_cpuset) - update_tasks_cpumask(parent); + update_tasks_cpumask(parent); if (parent->child_ecpus_count) update_sibling_cpumasks(parent, cs, &tmpmask); -- 2.27.0