From patchwork Mon Oct 24 11:31:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp435924wru; Mon, 24 Oct 2022 05:55:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/275SthyoN/SvOqNigwY7ZLO5W057M1IeBp8ILec6gjN9t3fGfuU+JCB4wRtJthrJxm90 X-Received: by 2002:a65:408b:0:b0:42a:55fb:60b0 with SMTP id t11-20020a65408b000000b0042a55fb60b0mr28366039pgp.431.1666616153012; Mon, 24 Oct 2022 05:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616153; cv=none; d=google.com; s=arc-20160816; b=cu4IfEpKG2F4nTKLq7+MfDHfAowGe1gxUMkLDJTB7yec68Gpo4nt5WHa1RBPgEQ/hJ fboJEQvd6HIpXwaWz7EU+rzESArKXGFacyZkkHIYeZTrbiifNsn1g72flfl5Wx9yVlVj j/+28Mk/jtmJmSPmQZOPv98bQ5XaFnhJOhJJWF63S5TqH36tVNhUKbl3MrjfTLoK/ZIS q4SCZXJLcfGTmf5/0D1rPb1kOkmTxBQr9syfkZT0c2sytfNcH4ZDE8gO0xUNrm1XlPPE P9ZeKFpgSV1myFwPY1y4dH+w6Q1mO2Svaqi09sxIyGycf0UIJBg0KIg60sn5R5X3nxua 3TLQ== 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=Lto0GJlPW9WHUFjTt8CkafVqZyrGSwO8ZPX0Z5t5eVs=; b=Mfn6DGUdSXzv77Tfp22N60KizbRomwI+1vUm9epm+yKkrZ97TCJy8ib06kRjIXxqI1 MWrUmV/+ZB0hHNkPFO3G0SNAXUtkd3GG1tqMGpH14VAEcpZR4oMto+a2W13dGjFero6X dd7JNK2rKmmcxKcnN8RNCzkj12jYZ/6ALHn2kZe/2bJyKDp6kOg69C/2ITGEkrSy56K0 3unmzdoTMP0/Bdjnp4D4+YCHwVxOH4YfSQc0/JQpE100AlOtr30OE+4MMHebL7eegPSi 5GX8WSLeVbantilA83SWqTn7A6aUloSdbzXimQS3/rVdTNy5/GPfIp/idlm3ITl47145 wK8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N3dV3cMR; 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 t14-20020a63954e000000b0046ae2a8ea9csi35812855pgn.733.2022.10.24.05.55.38; Mon, 24 Oct 2022 05:55:53 -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=N3dV3cMR; 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 S230319AbiJXMy0 (ORCPT + 99 others); Mon, 24 Oct 2022 08:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234664AbiJXMwg (ORCPT ); Mon, 24 Oct 2022 08:52:36 -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 43D45101E1; Mon, 24 Oct 2022 05:14:09 -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 8170B6128E; Mon, 24 Oct 2022 12:12:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98031C433C1; Mon, 24 Oct 2022 12:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613545; bh=P930n1nSM3z63KMYHL4L/pCD1C+IPjaalcWZsoat+3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3dV3cMRgtThcS3ympUH0KXVUxDn/8eDZmbrvl4yovmx0vfAgRBs9Km0Cb6XWNeXh chUhkJVygkj3k8vj5InIqAy/rbIPIesMZyTVybyC2j53xnCxkKSgAb10eaJZXHscs2 j59DSxp9HjyzxvZHqqXnt2DjniSMHbY0/KEseZ9Q= 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.4 177/255] cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset Date: Mon, 24 Oct 2022 13:31:27 +0200 Message-Id: <20221024113008.721313707@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573699159630376?= X-GMAIL-MSGID: =?utf-8?q?1747573699159630376?= 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 9ba94a9a67aa..c7f4526ca64e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1057,10 +1058,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); } @@ -2014,12 +2023,7 @@ static int update_prstate(struct cpuset *cs, int val) 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, &tmp);