From patchwork Sat Oct 22 07:26:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1106050wrr; Sat, 22 Oct 2022 01:36:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wapF9do3ysepM90l3kC3c9CPr80jne5ouuAhr0/z4XdpMSlhTayyqS3n/o2WYWCaFM1p2 X-Received: by 2002:a17:90b:38c4:b0:20d:9dfa:4339 with SMTP id nn4-20020a17090b38c400b0020d9dfa4339mr59170281pjb.74.1666427806291; Sat, 22 Oct 2022 01:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427806; cv=none; d=google.com; s=arc-20160816; b=OU/wAu+Tiyux03+7/+y28ofW2/EkleedVTiuBuhg5MTU2ZspP5H8+Hiy8mO6JIPmpq 3jPktQZKi8/NwfO4BBf/q/bJ69XTgL84tLSbJTWw+fbyEN814GNVhfV1fhXWElPLQY1g tzQqCfyLLwFhDgo0KlB8TNMroXPOB1ntfQPcRCfy6dgQwvUSdAaZeidU/tlg4krZzYrt GydZtHZCN6+ojTFDt8Zfh4t9RYGc9gertVkCm/wqWpgI/GsOJ2vJl4Tjz3l1sRA47JIm XJDFE6oU3bUySmz/w2vjKa5SKYG1NynO4hc+NNUxRe96PsAb+9n/wGG0NFwSl4OjWNTL +iJQ== 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=bUKZY/ZhWx8y7/k7IccXZvCnFjr1Q+IkeDEZU1d7tlUfdj2IUytEKFlY9fMu+rjzw4 F0yvg1pPHt4X9SJoPx1mVNY2AQgV1bJn0SjXN2eyVfMN9EXvzcQzyz6L26OozUa08n8o UZoBsPM7C6SxW+uHEPgg8J4YR7DloK1Dgdcw2yMshw21dHj0eiBW9zvtd9DLdp5rhsYS p3EDO/iNJgpTv5ZNL2KMKT3cHNx8YUAPBvK5ChY1AW+pME79xGehKk7gm0k1T9S3QBq6 JoIQSuYzJM7uMk+6MCLIAQBw5hd5OLkeoyPr1N1jzPkziNkYgwVmjbHKV/0AN05djbLq jp9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Legf1VSb; 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 bk13-20020a056a02028d00b0046040a8c03bsi26390271pgb.660.2022.10.22.01.36.29; Sat, 22 Oct 2022 01:36:46 -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=Legf1VSb; 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 S230036AbiJVIVL (ORCPT + 99 others); Sat, 22 Oct 2022 04:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbiJVITo (ORCPT ); Sat, 22 Oct 2022 04:19:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFBE52B5B98; Sat, 22 Oct 2022 00:58:34 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BFE9660B95; Sat, 22 Oct 2022 07:58:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C38B7C433D6; Sat, 22 Oct 2022 07:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425482; bh=cWRamBsDNvVDBJ3mqQVRbJszxwtXNpzWGuAkpTyTjgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Legf1VSbfVzkMOqMWTxUx/ICNRQ+jqUjcX7j/JFGnWlGCa36UoCHFO+wsBiZRS/7K 7OwU8fX0SQBl7TULHE4mrBLPUzfgPtPdqpLWLKUyxS6q2J7WksfVqYdFwfP7qCUVx0 iztQU05V/Ae8H/MRvBIa7fGOyS5BO/LxzKbWU8mg= 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 5.19 515/717] cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset Date: Sat, 22 Oct 2022 09:26:34 +0200 Message-Id: <20221022072521.055933064@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376203338998527?= X-GMAIL-MSGID: =?utf-8?q?1747376203338998527?= 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);