Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16941110rwd; Mon, 26 Jun 2023 18:02:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+m4UfuGsS1LnULDDIPTvzD9u50bphbDFvyZ+siICcvY7e15inlx19d7ca+O77wiIwFO6+ X-Received: by 2002:a05:6358:e814:b0:131:4d41:c05 with SMTP id gi20-20020a056358e81400b001314d410c05mr13371902rwb.15.1687827725964; Mon, 26 Jun 2023 18:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687827725; cv=none; d=google.com; s=arc-20160816; b=CQkU8qiEJHhDHyU+UJ8/iftBP8nX/s9SCH0EdRl1eXtvzr37ow7RykCSJcyvCDguYl ougInHFbnQ4B/WxycDExylqGXFNIMufh0DX/5J/0M5DgAnaiwLAtzVzfN4u8L5oZLXBD 8lepPDafDNmB2u4C0bpJmKcD3ZrrnVWVAFnjfifbdO3TM3e4FEB2JRKhIMw7gHYk+1Sw aE1iyu+EWPCidAFgUpp9SE1ULyuujGnukW1eexfV2JC5WoPaYAz21y3379i2iLqWEs05 WUB2IqxmRXQ8kGseXUAico7/rTxXMwHiL7WIxBQBGewYvxzJhmkuO9tBfOOSBudElQp9 yvlw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HxXXRG19n9JIA9MH1iFO6LWghYV5obKh5ig/aXiH0Xo=; fh=e85PI7WvowV/CVl68S8nEijXq1ovh2xW2v/QK0gu/Hc=; b=ZoSSZ/tEF+rMIEPzR6Q7pKHI9ZpK/YdMdJq65R6rsBFR4MnnST1cQXOBPNdeLvVzbv BqC3vVsx+6vgyh+wW5/I5PemUpZhH6AG8YXIg1wycSAygQ4fktsGBVjlG5v4dC9bCV26 5EnkkLNGtibSKRFP+nl7tUJs7mrickmjN2KYA+a0O1yih0x4l6n9xDihHDMKdlGL6ZOK ybs08CqjS7jpPN3ot6JFHiDHDcvt+YTpqVZxUF72NR+Tw3cplFSU93hr4zI285SrzSNM z+SIjQb/T3MzytYrIxc98ujelcUJPrk5FAfLSwOkBHt/j5MZyoOV6unMFJJOD7PoZN4W XNkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TTodNMIK; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a656842000000b0053b928deb7asi5880544pgt.344.2023.06.26.18.01.53; Mon, 26 Jun 2023 18:02:05 -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=@redhat.com header.s=mimecast20190719 header.b=TTodNMIK; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229481AbjF0A4s (ORCPT + 99 others); Mon, 26 Jun 2023 20:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjF0A4r (ORCPT ); Mon, 26 Jun 2023 20:56:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21979173C for ; Mon, 26 Jun 2023 17:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687827363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HxXXRG19n9JIA9MH1iFO6LWghYV5obKh5ig/aXiH0Xo=; b=TTodNMIKV6O23wbmOjlaOMxKBk9RTa7oQwHQtig309ih9/P9f0C7dcZT8O3Ty5N1Oxt9a5 JNv3wg0NIYLuNZfkqIDiUSq5spmViFrUzVxaC4HfuTy91blozIRGKOLpdvRQnVB/9Xu/Ai OKwBxiNGMzyjZoRn1Zj+MXSgC1tNxUI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-hAcb0zztPFekXAwJrYR7eQ-1; Mon, 26 Jun 2023 20:55:59 -0400 X-MC-Unique: hAcb0zztPFekXAwJrYR7eQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3857D8C7C21; Tue, 27 Jun 2023 00:55:59 +0000 (UTC) Received: from llong.com (unknown [10.22.33.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6982C2166B25; Tue, 27 Jun 2023 00:55:58 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Juri Lelli , Valentin Schneider , Frederic Weisbecker , Mrunal Patel , Ryan Phillips , Brent Rowsell , Peter Hunt , Phil Auld , Waiman Long Subject: [PATCH v3 1/9] cgroup/cpuset: Inherit parent's load balance state in v2 Date: Mon, 26 Jun 2023 20:55:21 -0400 Message-Id: <20230627005529.1564984-2-longman@redhat.com> In-Reply-To: <20230627005529.1564984-1-longman@redhat.com> References: <20230627005529.1564984-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Since commit f28e22441f35 ("cgroup/cpuset: Add a new isolated cpus.partition type"), the CS_SCHED_LOAD_BALANCE bit of a v2 cpuset can be on or off. The child cpusets of a partition root must have the same setting as its parent or it may screw up the rebuilding of sched domains. Fix this problem by making sure the a child v2 cpuset will follows its parent cpuset load balance state unless the child cpuset is a new partition root itself. Fixes: f28e22441f35 ("cgroup/cpuset: Add a new isolated cpus.partition type") Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 58e6f18f01c1..170e342b07e3 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1588,11 +1588,16 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, } /* - * Skip the whole subtree if the cpumask remains the same - * and has no partition root state and force flag not set. + * Skip the whole subtree if + * 1) the cpumask remains the same, + * 2) has no partition root state, + * 3) force flag not set, and + * 4) for v2 load balance state same as its parent. */ if (!cp->partition_root_state && !force && - cpumask_equal(tmp->new_cpus, cp->effective_cpus)) { + cpumask_equal(tmp->new_cpus, cp->effective_cpus) && + (!cgroup_subsys_on_dfl(cpuset_cgrp_subsys) || + (is_sched_load_balance(parent) == is_sched_load_balance(cp)))) { pos_css = css_rightmost_descendant(pos_css); continue; } @@ -1675,6 +1680,20 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp, update_tasks_cpumask(cp, tmp->new_cpus); + /* + * On default hierarchy, inherit the CS_SCHED_LOAD_BALANCE + * from parent if current cpuset isn't a valid partition root + * and their load balance states differ. + */ + if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys) && + !is_partition_valid(cp) && + (is_sched_load_balance(parent) != is_sched_load_balance(cp))) { + if (is_sched_load_balance(parent)) + set_bit(CS_SCHED_LOAD_BALANCE, &cp->flags); + else + clear_bit(CS_SCHED_LOAD_BALANCE, &cp->flags); + } + /* * On legacy hierarchy, if the effective cpumask of any non- * empty cpuset is changed, we need to rebuild sched domains. @@ -3222,6 +3241,14 @@ static int cpuset_css_online(struct cgroup_subsys_state *css) cs->use_parent_ecpus = true; parent->child_ecpus_count++; } + + /* + * For v2, clear CS_SCHED_LOAD_BALANCE if parent is isolated + */ + if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys) && + !is_sched_load_balance(parent)) + clear_bit(CS_SCHED_LOAD_BALANCE, &cs->flags); + spin_unlock_irq(&callback_lock); if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags)) -- 2.31.1