From patchwork Tue Jan 30 13:17:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 194172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1211413dyb; Tue, 30 Jan 2024 05:16:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IF44J7RQTSw9X02wmkoHlBpJuSFK9EV7K7VbtS4deHiZCw2kd1KU1bLMJjytM8ZHqUmFei6 X-Received: by 2002:ac8:7dc1:0:b0:42b:def7:771 with SMTP id c1-20020ac87dc1000000b0042bdef70771mr575765qte.80.1706620606663; Tue, 30 Jan 2024 05:16:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706620606; cv=pass; d=google.com; s=arc-20160816; b=vK76aojbtFX51+vntYii3u/+GFuFYSEoAky9HVceWuM2zvDEmBhhO8JTfjQBjz4thf tPR318EfqLxMYmf1dA5qb0Sc2YkHienxVscBEdl4S/vXXZMrAL7Ln1gtcuOCvaFflO0K 1ZP59B4JNgI/O59eoh9xWogs7GMW8mdRkP4X9UuB+iVzE5vUK6lHVjGflw8UpOeKl7hK wS5zM5f11W9Plf3F0m0ANYAcO/9Ar1jD5uvJU7J2poMo7x4zDUcbd1VVPR6cUrmsWGFF aIHDjBhXwLeAig8GogIbvCnoTn6vbTI+oGBk6Rli1feSnzKbX+o+WbobAOY7+QMY2MEb IGIQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44684-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b3-20020a05622a020300b0042a1c8ffe11si6982751qtx.35.2024.01.30.05.16.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 05:16:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44684-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44684-ouuuleilei=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 29DBF1C25969 for ; Tue, 30 Jan 2024 13:15:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 554A36DD17; Tue, 30 Jan 2024 13:14:29 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789521409286118989 X-GMAIL-MSGID: 1789521409286118989 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; }