From patchwork Mon Oct 24 11:31:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9638 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp532641wru; Mon, 24 Oct 2022 09:08:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7011KRKbLj+/ExG/DgxltuERQZZzhSggH1WEN7oZ/rPknUDsS781j3Z78mLiM1S/doK1O8 X-Received: by 2002:a17:907:6d84:b0:78d:f2b0:14c8 with SMTP id sb4-20020a1709076d8400b0078df2b014c8mr27321662ejc.749.1666627700636; Mon, 24 Oct 2022 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627700; cv=none; d=google.com; s=arc-20160816; b=XkrvTsJNlNeYgWoOz9HNaKAC9k+uyg7q98hSLGtI+8wHoBgIujgOMIlMV/txsHxTKI UEuB/gL19884BhwJMbdLH81TOOqIEzLU3HaQObPeKOeby/jRGNU1LPPA5wuUInSOaPpM fI6VMvaWMN9dxhd2sBPnRYwjEGy/aPApGsjhkfXA3jnqbX0+gM8pC8SVi4XprKrmfFjI 8yrHys+fOo1a6wogJg94ia7Z8IT9P8bKDwSEUq3ZxdFTlxrECfFhXQF8PcNMNHX5WIgv FwFMe+Zv/lEu6HfinsadxmNyHi2+mXgBttrX0zhQpGD4o0ZbT9KCEleICd5li1M7FTgE J16w== 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=7Y+w4tfSYLpFYrzpfNhkYsR/jp8zrZeIK8/gXU3N/W0=; b=earhhC9zW8jz14+eEdt4DAS+3gxhAYyTc/HDVOKMaI3bzbgjo1um/dKpXhQ9zfCq+8 Ep2xt6iZICX2twFV8Ia7xUUg6j+Gw5//rmKkL8cHv7BZ+mOjXjzj9zPBJbEH2U/k/naV 5dfUj1K+rjvUmeV0hJIZbWc1qoD3D7el9t57qw0ulO/UrbORlqFIU4dfAhyTTyBzy7xH SJP3VBmSICL7dY9rRHrPYLbOhWC8Y/IqwE0GPx4RbPeFpbAL/TgYc4XDUSjYTVZL8k81 BR3NLbrW7t+pSl3JSVJ8f2s3KsM5IsZmBfAJNKkMMhlsoBZhB4l0VITWtFMkhcP/0785 IjQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jh9LGlkc; 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 ga39-20020a1709070c2700b007835897050asi190770ejc.83.2022.10.24.09.07.55; Mon, 24 Oct 2022 09:08:20 -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=jh9LGlkc; 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 S233256AbiJXQHR (ORCPT + 99 others); Mon, 24 Oct 2022 12:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233099AbiJXQEO (ORCPT ); Mon, 24 Oct 2022 12:04:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C43C48C91; Mon, 24 Oct 2022 07:56:27 -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 ams.source.kernel.org (Postfix) with ESMTPS id 12AD5B811BE; Mon, 24 Oct 2022 12:27:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62653C433C1; Mon, 24 Oct 2022 12:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614473; bh=TSjoHx9SAKNV0MMEJApepwgZRfRkoPzmJXeQfO9jPJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jh9LGlkc5xR5ChduVwXveTuJ+PXgGMnqLp2Auqg+sM1ZOCkPbO7SCosegAGznxnJZ aMNmE01vl+gVXhoMLSCu2mcAfM/ExOVJ8jTeTGem5I9601vU6dcSRRJH2ROJEGkucq 8RcC4KQcJ7qH4NG7Gu90FDklcTOIjAa5XdaecOGA= 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.10 274/390] cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset Date: Mon, 24 Oct 2022 13:31:11 +0200 Message-Id: <20221024113034.598799027@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747585807896863737?= X-GMAIL-MSGID: =?utf-8?q?1747585807896863737?= 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 b7830f1f1f3a..43270b07b2e0 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1059,10 +1060,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); } @@ -2016,12 +2025,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);