Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp997966rdb; Tue, 30 Jan 2024 05:15:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJQmTTPftV+oyeiUtl+KysS7iwYGHl1+SEUgFDUS62s/mJDx3JOdOvuPjanpEwV1rSN2HZ X-Received: by 2002:a05:620a:1345:b0:783:f6d5:b9bd with SMTP id c5-20020a05620a134500b00783f6d5b9bdmr4303966qkl.19.1706620500030; Tue, 30 Jan 2024 05:15:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706620500; cv=pass; d=google.com; s=arc-20160816; b=E+FlY3MQLXIvCRGg0dSn+AFT5P4Yqs9YtqPXKeKRcFrR0SHC82d4UOHnkGCaVQCaoZ W3fwe/wDanPwuinIZkQ+mgMQ8Wyrk1lF7EA1GHaxyHsRjQKh1VO9jrjKyCXD9+khKJSE /ohKRbXzwxlbxiSqjC71U5FmccA/oaoz8JmnkeVUqvhAPsfpxCdB4jFMpoPt0kr8AAPy 4CiZVLYdg66LAw6GQ7Npxtdr6xnnMHtaZwLoVPN/CNaubUl1FrjJhxWR0zs0gm1O+8CM h5mlySgZI7snAdQZ+sb3RaS6CP7UY6s4LD0DSrOicEivoSwZwPpZ++RiBWR/5lMfoAGH uyWA== 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=JqV4+TzQe8MTC0S2zUkHsxoC2ri3PuOVwTzg6Pgd4do=; fh=CH0OO+rsEMoKRW5HY96+2DQ466rE9ttKX9bm1c+/3Ro=; b=EBLPfHy79K1hX9UFJYK0MIMvssPHhw38lQbh1CTA5CGnQPlwjy80fVp8ZJ56tU/Jpk t9IASp19fANSVfZ92erwlv9W+qPZEGpH+Wz1x+Xx/ZEFODSDDKWTH2JJExexMlBXXPzH spvA10b3wFysDnpKQZ3KRzLcOFAi3bblqqAGwIl4ADe2ykWoI/ZPkLyPYYCX+jzLk2Wx +aD0tbgJvmmjeClOo1y4W5tlrtJEyxaUPweK9ZZohmBvPIP45ie/DUFSPrbJmXXuuMox rosvm8O0nTxxBd4AplY4/Xmt2/6Acv46613ZUJVi4WXGP/dKsFI/j+bvvXIpTwiEJ6Bh Ee+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JGMAktKI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-44684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44684-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pi6-20020a05620a378600b0078319e53b28si9713222qkn.590.2024.01.30.05.14.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 05:15:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JGMAktKI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-44684-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44684-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C41731C25BAA for ; Tue, 30 Jan 2024 13:14:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 822506DD06; Tue, 30 Jan 2024 13:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JGMAktKI" 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 AC8E26DCFC for ; Tue, 30 Jan 2024 13:14:26 +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=1706620466; cv=none; b=Fh+tjIvbUpit1/hcoFzl6qEQLDTQ0OJJENSy4DLVIGj8TChG3Q0r+FxcXpzp+qm+4bZpLmWH4FQv3rajGZqlKNn5POaWsh/CfJkIm9Ph2mGt9O7hsgYG1u7E1hSMbCGZ65r8WnbFUjKoLQ4FrZyPMwiSUfLt/P9QaPBGAP7f5tQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706620466; c=relaxed/simple; bh=FRfl9LrFeYMC1cDiZLWNe9rb4nE8aM3Q/PfT7DsOvNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tJR1qJ7Zeas6Of2nSgnt919XlxY3dHiKFpasxX+mi7d4MB1eiCtFcTbksSp6WVgzmogvIQB2se3JlIqgY2lJW4fPRJRv0T+OpX6lR7EaFF6/Eb+fjAtQVEHul3HKPGZb1pE93wAtX2w0fVuFiFrf3u+FON2cY5Z+DzCJ2ent3UE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JGMAktKI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D9E3C43390; Tue, 30 Jan 2024 13:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706620466; bh=FRfl9LrFeYMC1cDiZLWNe9rb4nE8aM3Q/PfT7DsOvNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JGMAktKIPWx+UA6lRmEHNpsiezEGpGSZhakC+xSZTNJezazZntNRd/UXfwH3wyJwT AJlyqQ237C2li/uyMCjkS9BHBWtrlMe70vUAmZR3nDzF6aam7rAG1dNwlL/4o+WBCe 6tq+HseJYkNtRsOmb2cbNVcD8GzLTQ3BjaPhZUn7JcYfh9XtFkM0v7Y1rtHwKCCb5N cmE2vXxa04zgMiet1Kcg2EjjOr5AFWWSH/fzypKROew8Sy8AXAwFPslyHc7EU1YXSt ljcLuQdgCw6Npaja2spDj3vElTzJwFkr3PYRpdlxF+csgON2Ml/pMJfqFX3SAgudTj +IxCh0y/DbI/Q== 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, sshegde@linux.ibm.com Cc: Alex Shi Subject: [PATCH v2 4/6] sched/fair: packing func sched_use_asym_prio/sched_asym_prefer Date: Tue, 30 Jan 2024 21:17:06 +0800 Message-ID: <20240130131708.429425-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130131708.429425-1-alexs@kernel.org> References: <20240130131708.429425-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 Packing the func sched_use_asym_prio/sched_asym_prefer into one, Using new func to simply code. No function change. Thanks Ricardo Neri for func rename and comments suggestion! Signed-off-by: Alex Shi To: Ricardo Neri To: Valentin Schneider To: Vincent Guittot To: Peter Zijlstra To: Ingo Molnar --- kernel/sched/fair.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ebd659af2d78..835dbe77b260 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9745,8 +9745,15 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) (sd->flags & SD_SHARE_CPUCAPACITY) || is_core_idle(cpu); } +static inline bool sched_asym(struct sched_domain *sd, int dst_cpu, int src_cpu) +{ + /* Check if asym balance applicable, then check priorities.*/ + 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 @@ -9766,22 +9773,15 @@ 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; - } - - return sched_asym_prefer(env->dst_cpu, group->asym_prefer_cpu); + return !(group->flags & SD_SHARE_CPUCAPACITY && + sgs->group_weight - sgs->idle_cpus != 1) && + 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 */ @@ -9937,7 +9937,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; } @@ -11036,8 +11036,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; @@ -11907,8 +11906,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