Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp67647rdh; Tue, 6 Feb 2024 19:56:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkc9NE0zzy/HmFusC6GhHEwPcQVrXt1tLmL7A1Lu3/F4HKw2gFBOIS9ehP9P75O9vMLRf9 X-Received: by 2002:a17:903:25ca:b0:1d7:3563:88e7 with SMTP id jc10-20020a17090325ca00b001d7356388e7mr3282303plb.58.1707278188366; Tue, 06 Feb 2024 19:56:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707278188; cv=pass; d=google.com; s=arc-20160816; b=CMUPJJ2HG+rDIwSEzcAlWvTT39f5266KpKuagf16F7UiRMI0pXJQPoQNxomUI7nA3j 6mUbzBmc6oakeJ6aIiNzMIW1x0plhjXPBv7af+VEQTaLfEaH9+NOPVpAtm2Kgpj9aopL Lw/5KUwWXOvN62FxmpiSLZSYhnP7jXeQifpWIm9AYbgVbGwI5whPChjX448i+0iQu7zs aoii0yrBXTklr4e0epmDKhgFVtXqcaup2kMqahmguJkvNyFEqlVQGpgkNO1+9hJRnR5g NDKh150eH7QV6rLJauHhk5AbO8fbkSD5CIavno4Nja8dPkabRQFsYxfoql4SNwCN9Xxf MONA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hoLgI6tgVplVDKK3BnwI+V8rgXQ9re+fu3yG12BK0Pg=; fh=WJhbkwtezEQG3OjaxbN1Sy/vaSxJ2EaMfEi2mCMoWAs=; b=P7oXwLaENt2dJhLBq1jziiqMn/f4mLdfT2wPVhLAp6dwDL3m4gQq7YhjasSMz+B3z7 jd60DnZ5BWXLbO5T/xIFoQkw+EQNTB2hO14Yf+tYoGDQD9pN/MGdGrJda256SWo1n/6A /E9+g8Dc+X0hXIgW/Bwc5qub0o8ceK5xDLobMfnX5APmTHEYGFmem9T45azCTUWcpdYp cjtCbtGkyM5Car/YG99oDcsvdn3dNncQm6Hkl5x9MDnTa04N7/zgBjP+4C2B3GVZA7Mh 5YPjd9xgVnkcGVR75Qe/2iNFY6SgltU+7WNRKu+7gbTfNbn5sk7MR4QurHMi/8T3wo7Z fKvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tSWUTl5M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXE0P54iN9BqVgTteuLG7C+YGq4IxiT0B9UnUdI8RDbd99hZAlQPqB3wx/QKNbFLmprhx7moZBdXxjbXAEcNO/fM48/TDuRAdEjBfEowg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 2-20020a170902c10200b001d8f07fa3c4si579762pli.76.2024.02.06.19.56.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 19:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tSWUTl5M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 895F0B25E89 for ; Wed, 7 Feb 2024 03:44:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBFE41CD1E; Wed, 7 Feb 2024 03:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tSWUTl5M" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E28AF1C694 for ; Wed, 7 Feb 2024 03:44:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707277458; cv=none; b=nnjTJCf3epIqzGhG685VMDY5zNBwOF/n/vq9KDS8qRIB4eQNG6rk/soP1VZb9aVef4qXs6VZyUpLnoGtoR4/r/QcdSkIAWd0IzOCW+fZKI89B4Z50Z08Tp4JJvI79lWFmLEBDQOJjKWmzUIrRz//gGcdeU13bCdUc1GEsm2UXb4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707277458; c=relaxed/simple; bh=ZBWabr/sl4BLAglGWdQysfp0ZTpL5iL55T/CdtsmPuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KSs/rvFp8VYsn62nmeFgY4eEVAjKYN0oU9ZVRthPIlPC5zUPteTR7BGP17ysPHhoV2j/3W1OQv5HotN5yPzOAUIxDRIJwSXOQmGsI732Hq0Za5dkoP2sMPVEQ0NtG8T8R3MzcSqeGVNWEWstHlYwe2ALYcmlI0n18U1c0hbPFso= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tSWUTl5M; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F2DC433F1; Wed, 7 Feb 2024 03:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707277457; bh=ZBWabr/sl4BLAglGWdQysfp0ZTpL5iL55T/CdtsmPuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tSWUTl5MrVR3aRqaLNPAk0UvumXyYjyTudHP0DvKUQpEUu8DiZdBWzjLL3F7C8MED JcjrVw3T/pkkEP/V/FSUU/hlGHNoNKKDoqC5ay/0S8uu8PGzom6PTfAzDgsq5PQN/X BmFs3agVrqKEKfVS7TAVYDB2KztXTTEgQSTc1EA3hjRWZVOZeXGi21cr+Hi9bKlsjL 1NhuATAg6EMERrch94F3xAUivLqTF9dCXFOn9eRs8idRL+0uvdkQouBqL5mtghLeQa CFYJo3eAVYuLP57L1h7rUcMlVMhqliBsYDtQfGEnLeFm46k1E53Ihf54MUq/VVPf+v LvD1Obi8r8odA== From: alexs@kernel.org To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org, ricardo.neri-calderon@linux.intel.com, yangyicong@hisilicon.com Cc: Alex Shi Subject: [PATCH v4 3/4] sched/fair: Rework sched_use_asym_prio() and sched_asym_prefer() Date: Wed, 7 Feb 2024 11:47:03 +0800 Message-ID: <20240207034704.935774-3-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207034704.935774-1-alexs@kernel.org> References: <20240207034704.935774-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Alex Shi sched_use_asym_prio() sched_asym_prefer() are used together in various places. Consolidate them into a single function sched_asym(). The existing sched_group_asym() is only used when collecting statistics of a scheduling group. Rename it as sched_group_asym(). This makes the code easier to read. No functional changes. Signed-off-by: Alex Shi To: Ricardo Neri To: Valentin Schneider To: Vincent Guittot To: Peter Zijlstra To: Ingo Molnar --- kernel/sched/fair.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 607dc310b355..942b6358f683 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9746,8 +9746,18 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) return sd->flags & SD_SHARE_CPUCAPACITY || is_core_idle(cpu); } +static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu) +{ + /* + * First check if @dst_cpu can do asym_packing load balance. Only do it + * if it has higher priority than @src_cpu. + */ + return sched_use_asym_prio(sd, dst_cpu) && + sched_asym_prefer(dst_cpu, src_cpu); +} + /** - * sched_asym - Check if the destination CPU can do asym_packing load balance + * sched_group_asym - Check if the destination CPU can do asym_packing balance * @env: The load balancing environment * @sgs: Load-balancing statistics of the candidate busiest group * @group: The candidate busiest group @@ -9767,22 +9777,17 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) * otherwise. */ static inline bool -sched_asym(struct lb_env *env, struct sg_lb_stats *sgs, struct sched_group *group) +sched_group_asym(struct lb_env *env, struct sg_lb_stats *sgs, struct sched_group *group) { - /* Ensure that the whole local core is idle, if applicable. */ - if (!sched_use_asym_prio(env->sd, env->dst_cpu)) - return false; - /* - * CPU priorities does not make sense for SMT cores with more than one + * CPU priorities do not make sense for SMT cores with more than one * busy sibling. */ - if (group->flags & SD_SHARE_CPUCAPACITY) { - if (sgs->group_weight - sgs->idle_cpus != 1) - return false; - } + if ((group->flags & SD_SHARE_CPUCAPACITY) && + (sgs->group_weight - sgs->idle_cpus != 1)) + return false; - return sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu); + return sched_asym(env->sd, env->dst_cpu, group->asym_prefer_cpu); } /* One group has more than one SMT CPU while the other group does not */ @@ -9938,7 +9943,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, /* Check if dst CPU is idle and preferred to this group */ if (!local_group && env->sd->flags & SD_ASYM_PACKING && env->idle != CPU_NOT_IDLE && sgs->sum_h_nr_running && - sched_asym(env, sgs, group)) { + sched_group_asym(env, sgs, group)) { sgs->group_asym_packing = 1; } @@ -11037,8 +11042,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, * SMT cores with more than one busy sibling. */ if ((env->sd->flags & SD_ASYM_PACKING) && - sched_use_asym_prio(env->sd, i) && - sched_asym_prefer(i, env->dst_cpu) && + sched_asym(env->sd, i, env->dst_cpu) && nr_running == 1) continue; @@ -11908,8 +11912,7 @@ static void nohz_balancer_kick(struct rq *rq) * preferred CPU must be idle. */ for_each_cpu_and(i, sched_domain_span(sd), nohz.idle_cpus_mask) { - if (sched_use_asym_prio(sd, i) && - sched_asym_prefer(i, cpu)) { + if (sched_asym(sd, i, cpu)) { flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK; goto unlock; } -- 2.43.0