Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7322442rwr; Wed, 10 May 2023 06:57:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7L4XvuuVtb3nbofRTVjPaevYnlyqn/ws9giXkeud1Z59BZgNmAh2v+ZbVQ9RF7iz6C7TZK X-Received: by 2002:a17:90a:fa85:b0:24d:eb38:bfa0 with SMTP id cu5-20020a17090afa8500b0024deb38bfa0mr18190169pjb.11.1683727037474; Wed, 10 May 2023 06:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683727037; cv=none; d=google.com; s=arc-20160816; b=u2f+xPM2dNgGRa0flxpCl4TFCS0RtU/bb0WKZTw8HzsTmg8lXLdgdQECwVVQUfrIna bRf6z/uYZPacmNla9h48Hnb16QEJnGxajQ70Esv8fPxV+ZvPWpdy+2mv8hwD1Va3IDzY fjI8mC2paF/ouV6CqQ0ZVod9VTYOvjimLiwjhFVu+5VigVeYE/Dt/1zkiwlpK2bxryiu hNmOYtuRgExgr5Qu6r0QmPHmJqui7XkJ8QHywk1AM4hCv4xGCbolk+uwiVhQ8fBfzjyp ROT2nOqRYQngz5h29eak+yM1dEhX9g69q0a8HnV/Z/lBCP6ffFHV7jiQJ08a73C6N1Ef r4Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=T5KWL8v0ixfY0NlNRBcOGPLg+m+d8q7mWOOfrcxNPlM=; b=SniPF6/WVuGYwcJ874GwuLIF3Mbq73TGyKlZJn7SkVreFd70qNW7VvZNKWr4bZfXdZ 8b3Y7mkeHbKuT1g7BFOgdFAO1hmQk1dH3iTCoHvQ5+pNApj95xOC/vTogELkzrUOHUvC tOYeG81vEuh52cgI9MVbL19ube8YuhzslSb8s3vmGUbkThybITsyLULsrEYxLqL/OENb BBCd05EIYhse9758JyfqBErQ//ocEKHglE63Wjey3rPBZDQPmTKq88kAV0Hv2YIDqwRA SKU9r9Hey/XwS0jmkAPnN4XXevP56z0MxifuZ7Z/atABhsGWGwxrkV2I4nbLo77c/kbT KIeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YDk4Xryi; dkim=neutral (no key) header.i=@linutronix.de header.b=LQ8YPMf5; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a17090a930800b00247ad6e4188si17331977pjo.51.2023.05.10.06.57.05; Wed, 10 May 2023 06:57:17 -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=@linutronix.de header.s=2020 header.b=YDk4Xryi; dkim=neutral (no key) header.i=@linutronix.de header.b=LQ8YPMf5; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237204AbjEJNuV (ORCPT + 99 others); Wed, 10 May 2023 09:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237259AbjEJNtY (ORCPT ); Wed, 10 May 2023 09:49:24 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0131C3C1D; Wed, 10 May 2023 06:49:20 -0700 (PDT) Date: Wed, 10 May 2023 13:49:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683726555; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T5KWL8v0ixfY0NlNRBcOGPLg+m+d8q7mWOOfrcxNPlM=; b=YDk4Xryi3YAgS+dcO/VnHPjM9uZem+ylCINzD5y3XjmMdre19QJBYLfs36IHn9rQbNYlI2 iHuPz53WkLlOFlxbtad6PESgH+VYbt2SV/LeYBFuhN6WwCbIP6/OsYtfnNem59Lthjhu8X EzGmH/rMLqe++TpbV5rXID1zmiPO/IjJXZ9njnE5mgOFIWEs0vEsjEImQideYLjbzuQnNW RVTDP8XpfHL+LxHnTRnioMf28ZNlx1yyo4QJ0zz+DaiMQwlQ2jwfQQxRnNcJ97X7LYtb9H xdX/nSLMrQM4qd8mUIOn6O+Vu+svQui5zX3BxdfyslxJXhgTtyvv8X3cmuiPdw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683726555; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T5KWL8v0ixfY0NlNRBcOGPLg+m+d8q7mWOOfrcxNPlM=; b=LQ8YPMf59YjtZpjNmQom3O34WjRfPT7VIjE6dUP+hIVxPreCnQcs5GbEW5wmQyliMl70bo nhJzfR+9oglkezBQ== From: "tip-bot2 for Ricardo Neri" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Simplify asym_packing logic for SMT cores Cc: Ricardo Neri , "Peter Zijlstra (Intel)" , Len Brown , Zhang Rui , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230406203148.19182-4-ricardo.neri-calderon@linux.intel.com> References: <20230406203148.19182-4-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Message-ID: <168372655464.404.14584349567074700892.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 The following commit has been merged into the sched/core branch of tip: Commit-ID: ef7657d4d2d6a8456aa624010de456c32a135fe9 Gitweb: https://git.kernel.org/tip/ef7657d4d2d6a8456aa624010de456c32a135fe9 Author: Ricardo Neri AuthorDate: Thu, 06 Apr 2023 13:31:39 -07:00 Committer: Peter Zijlstra CommitterDate: Mon, 08 May 2023 10:58:34 +02:00 sched/fair: Simplify asym_packing logic for SMT cores Callers of asym_smt_can_pull_tasks() check the idle state of the destination CPU and its SMT siblings, if any. No extra checks are needed in such function. Since SMT cores divide capacity among its siblings, priorities only really make sense if only one sibling is active. This is true for SMT2, SMT4, SMT8, etc. Do not use asym_packing load balance for this case. Instead, let find_busiest_group() handle imbalances. When balancing non-SMT cores or at higher scheduling domains (e.g., between MC scheduling groups), continue using priorities. Signed-off-by: Ricardo Neri Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Len Brown Tested-by: Zhang Rui Link: https://lore.kernel.org/r/20230406203148.19182-4-ricardo.neri-calderon@linux.intel.com --- kernel/sched/fair.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 713d03e..a8a02ae 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9366,12 +9366,9 @@ static bool sched_use_asym_prio(struct sched_domain *sd, int cpu) * the SMT siblings of @sg are busy. If only one CPU in @sg is busy, pull tasks * only if @dst_cpu has higher priority. * - * If both @dst_cpu and @sg have SMT siblings, and @sg has exactly one more - * busy CPU than @sds::local, let @dst_cpu pull tasks if it has higher priority. - * Bigger imbalances in the number of busy CPUs will be dealt with in - * update_sd_pick_busiest(). - * - * If @sg does not have SMT siblings, only pull tasks if @sg has lower priority. + * When dealing with SMT cores, only use priorities if the SMT core has exactly + * one busy sibling. find_busiest_group() will handle bigger imbalances in the + * number of busy CPUs. * * Return: true if @dst_cpu can pull tasks, false otherwise. */ @@ -9380,12 +9377,10 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, struct sched_group *sg) { #ifdef CONFIG_SCHED_SMT - bool local_is_smt, sg_is_smt; + bool local_is_smt; int sg_busy_cpus; local_is_smt = sds->local->flags & SD_SHARE_CPUCAPACITY; - sg_is_smt = sg->flags & SD_SHARE_CPUCAPACITY; - sg_busy_cpus = sgs->group_weight - sgs->idle_cpus; if (!local_is_smt) { @@ -9406,21 +9401,17 @@ static bool asym_smt_can_pull_tasks(int dst_cpu, struct sd_lb_stats *sds, return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); } - /* @dst_cpu has SMT siblings. */ - - if (sg_is_smt) { - int local_busy_cpus = sds->local->group_weight - - sds->local_stat.idle_cpus; - int busy_cpus_delta = sg_busy_cpus - local_busy_cpus; - - if (busy_cpus_delta == 1) - return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); - + /* + * If we are here @dst_cpu has SMT siblings and are also idle. + * + * CPU priorities does not make sense for SMT cores with more than one + * busy sibling. + */ + if (group->flags & SD_SHARE_CPUCAPACITY && sg_busy_cpus != 1) return false; - } - /* If we are here @dst_cpu has SMT siblings and are also idle. */ return sched_asym_prefer(dst_cpu, sg->asym_prefer_cpu); + #else /* Always return false so that callers deal with non-SMT cases. */ return false;