From patchwork Mon Oct 24 11:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp547357wru; Mon, 24 Oct 2022 09:38:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hPuDVrJCL+6DkYbG751dEPg+jX3DsCgxWOi9wubxvI5w3p8uNZR0mUfJEDchAXoyKKs8O X-Received: by 2002:a17:907:746:b0:741:4a1b:cb1f with SMTP id xc6-20020a170907074600b007414a1bcb1fmr27290266ejb.370.1666629529020; Mon, 24 Oct 2022 09:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629529; cv=none; d=google.com; s=arc-20160816; b=Nf7/JVij2kkH0P4AVP3qO0f7xudIssQmycOoy4AJazAjTPsBg2VNmTJiIcE+t3k2bR 8QyR0vcfhxFvh2oRtxMn1RzIZ1ZZF9WgKiK94ZHo3KTrn1lBrY6Tlx4mFTTi+2k/EVIE KMf0/gn+DZth9E/L28XsBirJg6txAZ46RUGrKr/IxEJBZ4vQp6Q8jMWOWscP+Gix5LaI lDpq5w/FVaFnIsez8MyqNAkR3whpPgtO5EXRPBnOMI+i9m1r2YRb5FfdYr1GIfPsVuNQ +f8LYFGJjyU9PW3IW6lNIkfBwD1lDPiPc9puyI/agDZ2wXIyi9QCHEDSiAGPgC3Hk6cB Skdg== 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=DLybBmSIWYVzduEu52oCMOYxlQmTQujiswox0dnBax4=; b=bj7C8xVxQO4EzdX3KFd6Ez0Mfx1b9m3Z6z/trVjVTTuxHKLJql8LJZ3u33xXGWIc2q zZQzxqJpMfxFUG4q0g3o0FCnp5cL2Wz2xFUR636fSjwz6G31gA9PXTVNLCZCxgCKRBbO uxpP6NQW+eam0P7s5Nb1qfpUloblHvPmNzzGyXfCod6J7eCo3+uQkKhgbSFPUAs5hsTC L8opCXW9RLFQikjAKJ4wl1gdf2sFFpgj1ZxbObArCTE0rMRV6javNi8I2txI9dxRh4wD lq+zxY0zWvtm8lj4VWLTEISxL6spldTUaEZt9eMBcHQJn9PvaXQ7EzJLtXN++XwLr7sk 3BJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XmUhT+/y"; 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 hv11-20020a17090760cb00b007824b85978asi190814ejc.81.2022.10.24.09.38.25; Mon, 24 Oct 2022 09:38:49 -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="XmUhT+/y"; 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 S231234AbiJXQ1F (ORCPT + 99 others); Mon, 24 Oct 2022 12:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbiJXQ0b (ORCPT ); Mon, 24 Oct 2022 12:26:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5740C2C126; Mon, 24 Oct 2022 08:13:13 -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 744EB612B7; Mon, 24 Oct 2022 12:49:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82573C433C1; Mon, 24 Oct 2022 12:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615779; bh=7ejy0d+KKwbbxyY1c34JDvM+tldrF2f56p9tbQ3YmFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XmUhT+/ySQPeu+d+vOCQRb6f65yy7x+RjxTeEa93+Jvo6DSnGaiM8k3QXylBMvIxa jjkYg6sDVPdKXglP4br1yIRHZRY23NT94uKtEO7vTzjNADDt4SJ9SHGIeTD5BUMZ1T HJnD6EpcO9mLGJxLcJdUmfIeFYchrFMRNehJRUWQ= 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.15 380/530] cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset Date: Mon, 24 Oct 2022 13:32:04 +0200 Message-Id: <20221024113102.248576394@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747587724989152636?= X-GMAIL-MSGID: =?utf-8?q?1747587724989152636?= 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 3213d3c8ea0a..428820bf141d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1087,10 +1088,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); } @@ -2052,12 +2061,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);