From patchwork Wed Oct 19 08:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5467 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp332045wrs; Wed, 19 Oct 2022 06:38:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56of7poFnw4TTQyZLiaOlhqVA9ZIZen/ctPioD3oy8n7tvrZTLc8MHKAFSVZyKwT8zNNvM X-Received: by 2002:a17:902:e748:b0:180:b0d:7b43 with SMTP id p8-20020a170902e74800b001800b0d7b43mr8434191plf.12.1666186682786; Wed, 19 Oct 2022 06:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666186682; cv=none; d=google.com; s=arc-20160816; b=EZZYRuKzjKKxjDgbF6CkfMTJZYQWavS6daOBaEU81Wp6OX4XjDLKlDpCDXEPi65OSJ JMv+4tBLoTuddx0mPJlDDP0fT57H0Sg27bsOURHS6u9wXoH7n25fn3MtWKgw7ryCOkWU SGcbegpPEmL3dEhRSCY0o6T1Hw2l9+vxBBdSzbmZ78fJcDQ9xnvfZY+gQmGjYlySP0rs qpjVh0723l21KFlfUdEpjmjYqpidW1ewuVaaZhPbiBR4BvrIdAERs7JpMMOobeftKwCW vFlKGSGHgBpxv+7Hl3cgxpifPOlSIFeRy1wz3pCxbr36DOMO0XiDo97QOcF3SdlIQOUS wG3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zpv7QTHXImhI1udXCUjWDwKjVaTo65+gR5Rq4s7msoY=; b=yk9pvuFXSgNfVU7mpkB/3M6odU4oS2uNmdsx3zhbxwV3eGBPA9Gui2yZg5zIr629pz VxW/NxoAsF5go269jZjjv3/qSzaK98kBFHIqmK6m5kgQwvCLv1PMROpeiZY3hSMybgta 4ofYAiEXnBqwETHEk66M9iClz0ZY1ctBVFGQzftIwN5rNPLnXeE5VIGuUOmzMkvEifPr 8oVqqcjQFb1e2AWNivxJ2nqCjmEhwYvjzWsaRG0V/xL2C8g8VAytl8fyHeNqm2rPZM2w QFaZ/hn5+MEJIR3mnjJ3wm747dXLHbDePZlw1NT+mxuQIV4tKVk5O+vsknDNCYBQcBQm RbBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FPpydNgL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b00565de49c23dsi15771563pfb.105.2022.10.19.06.37.49; Wed, 19 Oct 2022 06:38:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FPpydNgL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbiJSNdo (ORCPT + 99 others); Wed, 19 Oct 2022 09:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbiJSNdb (ORCPT ); Wed, 19 Oct 2022 09:33:31 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFF318DAAA; Wed, 19 Oct 2022 06:21:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 452FDCE2180; Wed, 19 Oct 2022 09:06:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43972C433D7; Wed, 19 Oct 2022 09:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170382; bh=cWRamBsDNvVDBJ3mqQVRbJszxwtXNpzWGuAkpTyTjgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FPpydNgLf5yW54q/TgUcDrQ2uf7W5FiSxkNDEe0L/7jRs17ZqgC60VZUx3a1lUHxt Fl9iznih5SC5e/4SudnyMtwz7+atdMlEJ/eklAhe3vrD3JmP6ykFHzmXlhGi72657h Z8ud8QQqh2D05VutxGkMFIxsB1eTTPToQxW9mUb8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Tejun Heo , Sasha Levin Subject: [PATCH 6.0 633/862] cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset Date: Wed, 19 Oct 2022 10:32:00 +0200 Message-Id: <20221019083317.900394427@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123366808091344?= X-GMAIL-MSGID: =?utf-8?q?1747123366808091344?= From: Waiman Long [ Upstream commit ec5fbdfb99d18482619ac42605cb80fbb56068ee ] Previously, update_tasks_cpumask() is not supposed to be called with top cpuset. With cpuset partition that takes CPUs away from the top cpuset, adjusting the cpus_mask of the tasks in the top cpuset is necessary. Percpu kthreads, however, are ignored. Fixes: ee8dde0cd2ce ("cpuset: Add new v2 cpuset.sched.partition flag") Signed-off-by: Waiman Long Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/cpuset.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 1f3a55297f39..50bf837571ac 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1127,10 +1128,18 @@ static void update_tasks_cpumask(struct cpuset *cs) { struct css_task_iter it; struct task_struct *task; + bool top_cs = cs == &top_cpuset; css_task_iter_start(&cs->css, 0, &it); - while ((task = css_task_iter_next(&it))) + while ((task = css_task_iter_next(&it))) { + /* + * Percpu kthreads in top_cpuset are ignored + */ + if (top_cs && (task->flags & PF_KTHREAD) && + kthread_is_per_cpu(task)) + continue; set_cpus_allowed_ptr(task, cs->effective_cpus); + } css_task_iter_end(&it); } @@ -2092,12 +2101,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);