From patchwork Wed Sep 13 13:11:23 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: 139319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp119193vqi; Wed, 13 Sep 2023 22:10:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9ALPGBMDt59/JkhCXlFPHEb5jtc9/u6WKTgGAqip4Ouj8KbZtngaA1C+9xJxooIwoflIL X-Received: by 2002:a05:6358:429f:b0:139:b4c0:94d with SMTP id s31-20020a056358429f00b00139b4c0094dmr5695109rwc.12.1694668253532; Wed, 13 Sep 2023 22:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694668253; cv=none; d=google.com; s=arc-20160816; b=izlHmdGhEPTF4z4DcfQxfoGOf+oLTcgM5haMqV9TW7QvkLH/9X/5MYhyaZ+lhgPUOM qTP1l+aw9v8OmHeHDSvl347h+U28yoaOIKDuj/wAVZzyHu7E71gSDzg2LVsVWMe1Rlf9 12mLuh0GpjZ3UItVLFtUCQv4jhHBXv+x5goSs72LJBOUDV+jijdr7VuzzbwUUNsjPCLV JTZ17p869mUYpjDpX2lL4QqPh7EEj7rnzNssvQEIxBK9EpTlkQAglzQhFZ1gI2uSsBkR xhrLqCEAwhxdZNBf61Cevd3nDd4ZJvjQVxGS75AQC0y1rBG2BUq2Hx5ZOwIG1PYoNk93 cfuA== 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=5Lbr+GREXFEIWdqi56FKOM82bPUrS1DfjkzuftxKpOU=; fh=vehe0GpTJx+MXmaTSgaWv6Rn3rQ4eu+wxIwJw73HoMg=; b=qZW7xuXgWr7uQfHzoSYR94wiYplI1cqYm93lLYpI4tpdwGypZy+pIJIv4v6w5+V51j jwiEUKXYg5tAm/WfI2iCPEJcJNLaq4uFpyZeFUCFwvmnk2TwfCCMR4aV9cgwLGvOtUrQ XKLCsiY+QMIdlJZvqqHRolpCX7+GIBvaySVNBaFRp69gbpxowluVszrqdjfJHTmsko9/ zE3fO1adNx74bLJC7xcQfNygD6b9ai8rX6iDj0Z/QfI/k9OVK7rRQVQfEQ8j7G8PLmUY jxHak/c3OJXzPvb9U4Q7RPYtkOQnIY0qHw6A7AvmDp0s8yXmlQjvl8PXCvN5HzbqPMMn +IUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bI4ynV4K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bZ0OadvV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l62-20020a639141000000b00565701e9a36si692492pge.752.2023.09.13.22.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 22:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bI4ynV4K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=bZ0OadvV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 525B38254A8E; Wed, 13 Sep 2023 06:12:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240923AbjIMNLp (ORCPT + 36 others); Wed, 13 Sep 2023 09:11:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240817AbjIMNLb (ORCPT ); Wed, 13 Sep 2023 09:11:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F19A11BD3; Wed, 13 Sep 2023 06:11:25 -0700 (PDT) Date: Wed, 13 Sep 2023 13:11:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694610684; 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=5Lbr+GREXFEIWdqi56FKOM82bPUrS1DfjkzuftxKpOU=; b=bI4ynV4KCRDLsAecFpDqPzz0YhKoNzcIhTNMOezL7aw/qy0EdAoDnEHEEE1X8JK0cEb7Rt WQXdeQM1jpx7mntwuo9n3fAtxlMUXqxxDEShPPRyVXMdewZ5rM2CwmmGquAZjjqbAU1NTy haLymHLPzftO3U2hBfv1j8ol9PePj4sbmFaZYufFJVSIjDSiPBhhcRnO1EiEPnZg/O2owT hDRXFqPjid1eAaLqg/QggqMdU2N+rtD5Q5o9bohT39rr6P8Eq+icYr2pG+rsMiQtwiapDo qUqwqmt6uNtpfRuXkndn1bhFaGpDUeI4iDheYE3jkFr8glgakuesEYbc015XCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694610684; 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=5Lbr+GREXFEIWdqi56FKOM82bPUrS1DfjkzuftxKpOU=; b=bZ0OadvV9qyxjH665056/IZzyjAwF117+HzrQCi2ftQBoc+vGd5VVkTWCWZOQs9gn1PBg+ n3ggAGYJHxvpjBDA== 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)" , Ingo Molnar , 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: <169461068361.27769.13031358982665213840.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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 06:12:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776842026444100078 X-GMAIL-MSGID: 1776988458308139352 The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 450e749707bc1755f22b505d9cd942d4869dc535 Gitweb: https://git.kernel.org/tip/450e749707bc1755f22b505d9cd942d4869dc535 Author: Tim Chen AuthorDate: Thu, 07 Sep 2023 10:42:21 -07:00 Committer: Ingo Molnar CommitterDate: Wed, 13 Sep 2023 15:03:06 +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) Signed-off-by: Ingo Molnar 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