From patchwork Tue Sep 12 10:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 138210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp443480vqx; Tue, 12 Sep 2023 07:23:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdl7iBYf1v4IHyqJpEpdXepeQbmrLGbJFO3l2yb+K1R9tfc3GhSxdWBdewVAOGUs8OaB4r X-Received: by 2002:a17:90a:9484:b0:26b:c5b:bb44 with SMTP id s4-20020a17090a948400b0026b0c5bbb44mr11909974pjo.13.1694528605136; Tue, 12 Sep 2023 07:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694528605; cv=none; d=google.com; s=arc-20160816; b=AljtGdR5wL0ajLLf0o3+CF/MM4wIcfQgKJZb+L6m5c5ub8HJcyiNHmItJgVOBoPkro 8V3TQhKrYS9oNhfnNzZwcSg35RYOiDkguGCzCJrBABV+i7w5h342beXu/6BzbBIDMzsq OSUTdel9mf2Yu2qcxGm2pruzFqGC1ZgyBT40yT4cM8jxSU23sS+mM5lhGPpkn8tnH3po DQj7Q3Rzn9BwJQA+MQqErloxaTp/zlpov4IO4hg2KnGCSAQDclDzNe0RhjpVTCBs0vAp kvCtlkihUygkcYqxyOa1WoYfMq3DPJsjxvtPx//5+wF1ED0Lkk/vePXd+WI/kOJ4HkZS yRLQ== 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=JxnwhY0eyqPXBZlkvRElJQmn5nzqSgjydnNqnLGzKks=; fh=UTZzougbIbUfCHlsKb2EdDtQqe5d5p6fb0Vk9vR4MDg=; b=X9R1puf3zYlgO8WIMCA/HkwN3hej7/Szwr4IHW7R9ySoAd7BjG7/2aNzj8nYTZdK7C DJEYvK2MNLjdkQ5PImZvAc0MD+1oqWK7u3zbIU3FpReAwqJSKEihxDhww4S/DxjVDA4U rzb/cDy2KJe8WPOcXXWWxPj9mQdApEW9jDfE8o0hAe5RX5wv/Jp0AQ/Qii6fIAoeWOhe dI6CY/SeEo8fd+9ZQS/6wMf9cDWFVUojSo348uqpf76QATNJyhTsbMkcJAHIJUIdKozq nvhCxhH/Ps27MV0HqGzuXlwfNFsRJ4RQ66P4kaG4EQ45MQKoMrP+wZDWi+CVN0WabocS nTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=btwVyddA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l12-20020a17090a49cc00b0026f9b5fe711si9584561pjm.108.2023.09.12.07.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:23:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=btwVyddA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3D04A822B75F; Tue, 12 Sep 2023 03:35:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234360AbjILKe7 (ORCPT + 37 others); Tue, 12 Sep 2023 06:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234410AbjILKal (ORCPT ); Tue, 12 Sep 2023 06:30:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5251F172B; Tue, 12 Sep 2023 03:29:11 -0700 (PDT) Date: Tue, 12 Sep 2023 10:29:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694514550; 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=JxnwhY0eyqPXBZlkvRElJQmn5nzqSgjydnNqnLGzKks=; b=btwVyddA5Tt13pov5v8CwQ6pM+T2ghCg7uwncJymLY8v223DxHezhW3BQhm+YK6wgq/Rxj xXBDlb4To0I/TS2SrD1DMywDWPBqF3PYOWdR6EoJkZyeO2iaZR9eajHJEBqnhAnlKQLnPI md8acF6j1Jp9cWnqzE2HVf8KoASl9EqWWE/e2bw00JfZVvy0EKXBZ7GrXRUoI3K6zB9wDv qfqKShn9Cy0lN7vREIEuHAWEZRn7XHN+LNI5kyDz5BoccJTnfe4/Nbb4Oac6qZmaqNAIJb bBx4bhTbydzqbzqQduu/Wgi6LuHbw2oU/gqeTm8E286j9vzOCO9JZ9+pnQnuhw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694514550; 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=JxnwhY0eyqPXBZlkvRElJQmn5nzqSgjydnNqnLGzKks=; b=j56G3AdoO287DEgIVxAfbjkp1nX8m4lRrCJm6Ft+vsz2DBiZld399UG1SEnyEbFRCP59Vg Qaqq99bXV6326aDQ== From: "tip-bot2 for Tim Chen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix SMT4 group_smt_balance handling Cc: Shrikanth Hegde , Tim Chen , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <6cd1633036bb6b651af575c32c2a9608a106702c.camel@linux.intel.com> References: <6cd1633036bb6b651af575c32c2a9608a106702c.camel@linux.intel.com> MIME-Version: 1.0 Message-ID: <169451454934.27769.5511295733807328036.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:35:12 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776842026444100078 X-GMAIL-MSGID: 1776842026444100078 The following commit has been merged into the sched/urgent branch of tip: Commit-ID: ad468232c3eb1dab163672f98a1ab2363be7981e Gitweb: https://git.kernel.org/tip/ad468232c3eb1dab163672f98a1ab2363be7981e Author: Tim Chen AuthorDate: Thu, 07 Sep 2023 10:42:21 -07:00 Committer: root CommitterDate: Sat, 09 Sep 2023 15:10:10 +02:00 sched/fair: Fix SMT4 group_smt_balance handling For SMT4, any group with more than 2 tasks will be marked as group_smt_balance. Retain the behaviour of group_has_spare by marking the busiest group as the group which has the least number of idle_cpus. Also, handle rounding effect of adding (ncores_local + ncores_busy) when the local is fully idle and busy group imbalance is less than 2 tasks. Local group should try to pull at least 1 task in this case so imbalance should be set to 2 instead. Fixes: fee1759e4f04 ("sched/fair: Determine active load balance for SMT sched groups") Acked-by: Shrikanth Hegde Signed-off-by: Tim Chen Signed-off-by: Peter Zijlstra (Intel) Link: http://lkml.kernel.org/r/6cd1633036bb6b651af575c32c2a9608a106702c.camel@linux.intel.com --- kernel/sched/fair.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 33a2b6b..cb22592 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9580,7 +9580,7 @@ static inline long sibling_imbalance(struct lb_env *env, imbalance /= ncores_local + ncores_busiest; /* Take advantage of resource in an empty sched group */ - if (imbalance == 0 && local->sum_nr_running == 0 && + if (imbalance <= 1 && local->sum_nr_running == 0 && busiest->sum_nr_running > 1) imbalance = 2; @@ -9768,6 +9768,15 @@ static bool update_sd_pick_busiest(struct lb_env *env, break; case group_smt_balance: + /* + * Check if we have spare CPUs on either SMT group to + * choose has spare or fully busy handling. + */ + if (sgs->idle_cpus != 0 || busiest->idle_cpus != 0) + goto has_spare; + + fallthrough; + case group_fully_busy: /* * Select the fully busy group with highest avg_load. In @@ -9807,6 +9816,7 @@ static bool update_sd_pick_busiest(struct lb_env *env, else return true; } +has_spare: /* * Select not overloaded group with lowest number of idle cpus