Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp72616rwl; Thu, 6 Apr 2023 13:23:43 -0700 (PDT) X-Google-Smtp-Source: AKy350Y0XuB7YA4QOKXcuKJJOe0hNqE3uQyiE0vHFmpUjMbTR6KCDXUJu0IAeY7eifAFAQDpm7kX X-Received: by 2002:aa7:d906:0:b0:502:23a2:6739 with SMTP id a6-20020aa7d906000000b0050223a26739mr582880edr.28.1680812622900; Thu, 06 Apr 2023 13:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680812622; cv=none; d=google.com; s=arc-20160816; b=0I6MB/0a5jL5WbxvCJ/a5FZLhMmqkw5hAMiV20qvh9vuc5D4DpzcKYo5JD8w/J/byv USFapAOd4YmSPFrUcusgy4Qa8p2J1IjpMsANnN0lLrcGvsV3pdPajQw6m0Aaxj3FnfuM NIVaXd+QyusW4/KdlpUYDTzphOmukYKL8Fzj/7vNB1FLKd/CMipTt0ISGFtteRqK3iv8 5uccdqYGakJl1grVrUOVBqbAkrc1elqTlVLM7mybi5894x+Zye269RmxBD+wrHtmfUZq HqagnxasyN2oFcpUp9/CfUPi3wP52NKyWlONw8HkgLq6Udu51LiAD+MUrfXiHSDPvzqC M3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=pTAObllznV9nqUY3/FOFM4vp72UAYNm6iK6EMCMEdEI=; b=u/Q4oVzCtku0uSPHKHSeH28ZLZ+13CrrrwWR1l+fehTVpV6QfKHsezYVzE10ta1Vi7 1CSmW8naku9CiD0bBSUZGlZgk88CqY72OGUJNeyLTN3J4E/pEMYZ0DFTn+ZWj4caTFES QzHqtwD3Q0k9nKPqhPonyksed8wP9Su6d8t8yML0ApbFb6BxuiEasuEmHdrtV642UIU6 d7WwGMInwCmPPoJGsMgFkEU5GUjucjWmbv0SVxTbFtTwczCFCByN1RSQmlwDDxeZ4pNQ ZLx+keVUuY/zX9kCQnM9cYN8SuAHQsXRxqaK1ytNR5dS6e1SXDXVPXSp47a+8UcYZEdi r2MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XszhB/p1"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a50fb0f000000b005021f0d575csi1727804edq.675.2023.04.06.13.23.16; Thu, 06 Apr 2023 13:23:42 -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=@intel.com header.s=Intel header.b="XszhB/p1"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239214AbjDFUV3 (ORCPT + 99 others); Thu, 6 Apr 2023 16:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238981AbjDFUVE (ORCPT ); Thu, 6 Apr 2023 16:21:04 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AD793D8 for ; Thu, 6 Apr 2023 13:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680812462; x=1712348462; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=kHnMH+5Ty9vpOYHxJB9coCCq990ixF1Ymwjs8OZoq8o=; b=XszhB/p1ihVVFu09cV1MpN5gVhbhCDzklnyT4oAhE+6sET8v3rmyeRb8 udbUAfSwD71gm72bs/fypaRHMH4+JQrecuwyx4gpjKxcW7i4rPoThcT8y j76DZ//nJJDtkfEhaDSxr4/4v8To2npoQEazub0zJC6JG1whTNlKgqM8O pLLG5PZx86g3d6KDhZswEhxWnxzukImYTALKTlK1SI2HwNNu3vr6HtbWg 5FkNsPBI9btxJa2GvHASvFGzTHUAbgk0OVz4hPZl5GE+lBpGveflkD5ou uj187HVApBxcivibLxoQKWe9uDR7sxF/yPB3VrWP9cnipq4yRCTkLwAIA w==; X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="407957784" X-IronPort-AV: E=Sophos;i="5.98,323,1673942400"; d="scan'208";a="407957784" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2023 13:21:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10672"; a="861529890" X-IronPort-AV: E=Sophos;i="5.98,323,1673942400"; d="scan'208";a="861529890" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga005.jf.intel.com with ESMTP; 06 Apr 2023 13:21:00 -0700 From: Ricardo Neri To: "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot Cc: Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , Ionela Voinescu , x86@kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [PATCH v4 08/12] sched/topology: Check SDF_SHARED_CHILD in highest_flag_domain() Date: Thu, 6 Apr 2023 13:31:44 -0700 Message-Id: <20230406203148.19182-9-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230406203148.19182-1-ricardo.neri-calderon@linux.intel.com> References: <20230406203148.19182-1-ricardo.neri-calderon@linux.intel.com> X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE 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 Do not assume that all the children of a scheduling domain have a given flag. Check whether it has the SDF_SHARED_CHILD meta flag. Cc: Ben Segall Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann Cc: Ionela Voinescu Cc: Len Brown Cc: Mel Gorman Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Steven Rostedt Cc: Tim C. Chen Cc: Valentin Schneider Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Suggested-by: Ionela Voinescu Signed-off-by: Ricardo Neri --- Changes since v3: * Introduced this patch. Changes since v2: * N/A Changes since v1: * N/A --- kernel/sched/sched.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 060616944d7a..70abce91b549 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1772,6 +1772,13 @@ queue_balance_callback(struct rq *rq, for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \ __sd; __sd = __sd->parent) +/* A mask of all the SD flags that have the SDF_SHARED_CHILD metaflag */ +#define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_SHARED_CHILD)) | +static const unsigned int SD_SHARED_CHILD_MASK = +#include +0; +#undef SD_FLAG + /** * highest_flag_domain - Return highest sched_domain containing flag. * @cpu: The CPU whose highest level of sched domain is to @@ -1779,16 +1786,25 @@ queue_balance_callback(struct rq *rq, * @flag: The flag to check for the highest sched_domain * for the given CPU. * - * Returns the highest sched_domain of a CPU which contains the given flag. + * Returns the highest sched_domain of a CPU which contains @flag. If @flag has + * the SDF_SHARED_CHILD metaflag, all the children domains also have @flag. */ static inline struct sched_domain *highest_flag_domain(int cpu, int flag) { struct sched_domain *sd, *hsd = NULL; for_each_domain(cpu, sd) { - if (!(sd->flags & flag)) + if (sd->flags & flag) { + hsd = sd; + continue; + } + + /* + * Stop the search if @flag is known to be shared at lower + * levels. It will not be found further up. + */ + if (flag & SD_SHARED_CHILD_MASK) break; - hsd = sd; } return hsd; -- 2.25.1