From nobody Sat Apr 18 17:25:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F318C433EF for ; Tue, 12 Jul 2022 08:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232310AbiGLIWS (ORCPT ); Tue, 12 Jul 2022 04:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232693AbiGLIVp (ORCPT ); Tue, 12 Jul 2022 04:21:45 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E073A2EF0 for ; Tue, 12 Jul 2022 01:21:14 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id z12-20020a17090a7b8c00b001ef84000b8bso10680460pjc.1 for ; Tue, 12 Jul 2022 01:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LByzoEIhL3E1KDbupc6kRL6RPMawgfjjXQqpSPrGKak=; b=n06J6es9DusA/tRgI3FHPicJ7/K3d+DWWrx7RuTB+dMN2cJ1vDGBmV4YT77mypbTG1 0LK6OgapHJCuJALBHMh8KWjiS9jESICaGKmaZCMeV862wqVvaE3IfkqR1D8zepI2ry4E J3+SXRJ78acadkbW2tKB8A3Txmq4UTNZo/pROpom55elGxLW0F3b4saMQghKtPsjH2g/ MOYM0+Y2gHqlIckkXLocwXPToQy44lwff7jBfeM/aF6f2IMi7l7WVYOiUWJrQAaQCipG zj59zxfRQQXbiCEHca0IjiOnOJxB+1hDCoqq4cMzCTxsKjVXxfEQT7ttmTYAy1yqnrk+ tnGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LByzoEIhL3E1KDbupc6kRL6RPMawgfjjXQqpSPrGKak=; b=olRGSQQdbarNIdWDgH5DMTb+VLH8w+9E/5IAH0i8yHDazK9n932biFtb1o65PGj7Sr 5UUsWjn6fG/VJ2ciRO5GjcZmMwopuAdJFZefeTTq9VQVdJqPeUZHdDQSZhtTzBCoM3SH 3uqBES3B16nLl4/j0zPcHhxxiBE1rVSLYlv+V2LZJboYv+yEsgMKgy50CqsKdttfyCRk RWXSAaVBGrSXxpIDbC56YeeTe9zt27j2CWLWqpz1TzSAxOcy0ZD82n2t8lIzXYRGDLCC QyL2P19TJ+GCIM0TSt/bGiOzD4MdatozrC3fpR026Vfe4YWph9lPZZ/Cq4Rs/6C4TZbw UBMQ== X-Gm-Message-State: AJIora+xQucLztYWmDzdh14PxCfUg+/2TL80rHiftQLZRo5AEDOrWSJh WM7TgJz1AJCyqWRjMkgZ4L5xBQ== X-Google-Smtp-Source: AGRyM1vhsGs5PI555Z0BVtI9scEFyLEWSgWkdPNZNwYX2lBvPiZSk4BismTnvRRbm/xndbGRQMvoWQ== X-Received: by 2002:a17:902:f652:b0:156:701b:9a2a with SMTP id m18-20020a170902f65200b00156701b9a2amr22523901plg.14.1657614073875; Tue, 12 Jul 2022 01:21:13 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:13 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 1/5] sched/fair: ignore SIS_UTIL when has idle core Date: Tue, 12 Jul 2022 16:20:32 +0800 Message-Id: <20220712082036.5130-2-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When SIS_UTIL is enabled, SIS domain scan will be skipped if the LLC is overloaded. Since the overloaded status is checked in the load balancing at LLC level, the interval is llc_size miliseconds. The duration might be long enough to affect the overall system throughput if idle cores are out of reach in SIS domain scan. Signed-off-by: Abel Wu Tested-by: Chen Yu --- kernel/sched/fair.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a78d2e3b9d49..cd758b3616bd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6392,16 +6392,19 @@ static int select_idle_cpu(struct task_struct *p, s= truct sched_domain *sd, bool struct sched_domain *this_sd; u64 time =3D 0; =20 - this_sd =3D rcu_dereference(*this_cpu_ptr(&sd_llc)); - if (!this_sd) - return -1; - cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); =20 - if (sched_feat(SIS_PROP) && !has_idle_core) { + if (has_idle_core) + goto scan; + + if (sched_feat(SIS_PROP)) { u64 avg_cost, avg_idle, span_avg; unsigned long now =3D jiffies; =20 + this_sd =3D rcu_dereference(*this_cpu_ptr(&sd_llc)); + if (!this_sd) + return -1; + /* * If we're busy, the assumption that the last idle period * predicts the future is flawed; age away the remaining @@ -6436,7 +6439,7 @@ static int select_idle_cpu(struct task_struct *p, str= uct sched_domain *sd, bool return -1; } } - +scan: for_each_cpu_wrap(cpu, cpus, target + 1) { if (has_idle_core) { i =3D select_idle_core(p, cpu, cpus, &idle_cpu); --=20 2.31.1 From nobody Sat Apr 18 17:25:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB686C43334 for ; Tue, 12 Jul 2022 08:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbiGLIWV (ORCPT ); Tue, 12 Jul 2022 04:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232349AbiGLIVw (ORCPT ); Tue, 12 Jul 2022 04:21:52 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0936FA2EFE for ; Tue, 12 Jul 2022 01:21:19 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id bh13so6927630pgb.4 for ; Tue, 12 Jul 2022 01:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0oHBDiwaFsGTBwRGBiV75qzptiCX6BQhcdK4hyouxqo=; b=JmFoNoaxkrmQg1VmI1FYollmz7uAzIk5FB7LmTNJZ3rj6zFPoPEnpvwvtjuVK0toVk EmjlqkHM1YmiubjPJx6Z78aVjnM4HdmK/C3Sa4z3cxVd80tcOQuCwH9VgaEGDc7BtXge 0oRTwhDY7heEYD2mNgtCUBn8Ynfmsba/x2jDLEDSNfNu27dfjRSt+FzMw8fU+mWtQGy/ 7E7198I3My97XR8j/a8whvC+b2oI3HgX7128TpCWF4Oc24R71HEkMXfhsQVjTEOFxoS6 hXylAIRBUh+yFvdHwObcXxmySKCwvaaohPUJjd9E/AJY0UeHmNINzG2t/aSCrFY53VUs IiBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0oHBDiwaFsGTBwRGBiV75qzptiCX6BQhcdK4hyouxqo=; b=Vt9u0ts6N89u8Xr5PD21i+0y7LECas/KylQKGsWGmynNTQr8Dmnjcn19u1mqilsib/ 7jjlqFMpO7SZLLqm26u4VYdoz9JmU8cAfiA++zQlWhm6Y/Kk4NRUM9K5E5C6yhof2j+c 2+2JGxJzKzuIj0/9yc7IIhGy2A6hUwMFGzGtTXY9zf5gT/jugKzTLtJQbX+mjlAAhs8a UhK5+3XR/740THT5KVbSrrZ9bkNU3PBLCBRMiAFroUKdbwiVJ7cO1A/i6FrqWXLwrAC3 J1cbFtKvctLJiZNTHQLHUqk9g5j992bJgiE5IrCv1vFBlsNgNpLhl/NJVdZ4tFcMIThJ OXJA== X-Gm-Message-State: AJIora9WLuSeTT83QeT9mASsLKDGL2bhfMBCPHyC2aApQZ/XYHBuSwL6 Q0XEcPFf1jbenbD8KMz5m/zWdg== X-Google-Smtp-Source: AGRyM1tkSxpLxdnW1Lbm7AuPRSZ6cGD2bAmDVG9cX1GHsRnbV6hBE/jqbXV8HCxa1fmQiPlWbtgM3A== X-Received: by 2002:a62:1cc8:0:b0:52a:ee9e:b735 with SMTP id c191-20020a621cc8000000b0052aee9eb735mr770805pfc.42.1657614078541; Tue, 12 Jul 2022 01:21:18 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:18 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 2/5] sched/fair: default to false in test_idle_cores Date: Tue, 12 Jul 2022 16:20:33 +0800 Message-Id: <20220712082036.5130-3-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It's uncertain whether idle cores exist or not if shared sched- domains are not ready, so returning "no idle cores" usually makes sense. While __update_idle_core() is an exception, it checks status of this core and set to shared sched-domain if necessary. So the whole logic depends on the existence of sds, and can bail out early if !sds. It's somehow a little tricky, and as Josh suggested that it should be transient while the domain isn't ready. So remove the self-defined default value to make things more clearer, while introduce little overhead in idle path. Signed-off-by: Abel Wu Reviewed-by: Josh Don Acked-by: Mel Gorman --- kernel/sched/fair.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index cd758b3616bd..c72093f282ec 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1592,11 +1592,11 @@ numa_type numa_classify(unsigned int imbalance_pct, =20 #ifdef CONFIG_SCHED_SMT /* Forward declarations of select_idle_sibling helpers */ -static inline bool test_idle_cores(int cpu, bool def); +static inline bool test_idle_cores(int cpu); static inline int numa_idle_core(int idle_core, int cpu) { if (!static_branch_likely(&sched_smt_present) || - idle_core >=3D 0 || !test_idle_cores(cpu, false)) + idle_core >=3D 0 || !test_idle_cores(cpu)) return idle_core; =20 /* @@ -6260,7 +6260,7 @@ static inline void set_idle_cores(int cpu, int val) WRITE_ONCE(sds->has_idle_cores, val); } =20 -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { struct sched_domain_shared *sds; =20 @@ -6268,7 +6268,7 @@ static inline bool test_idle_cores(int cpu, bool def) if (sds) return READ_ONCE(sds->has_idle_cores); =20 - return def; + return false; } =20 /* @@ -6284,7 +6284,7 @@ void __update_idle_core(struct rq *rq) int cpu; =20 rcu_read_lock(); - if (test_idle_cores(core, true)) + if (test_idle_cores(core)) goto unlock; =20 for_each_cpu(cpu, cpu_smt_mask(core)) { @@ -6360,9 +6360,9 @@ static inline void set_idle_cores(int cpu, int val) { } =20 -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { - return def; + return false; } =20 static inline int select_idle_core(struct task_struct *p, int core, struct= cpumask *cpus, int *idle_cpu) @@ -6604,7 +6604,7 @@ static int select_idle_sibling(struct task_struct *p,= int prev, int target) return target; =20 if (sched_smt_active()) { - has_idle_core =3D test_idle_cores(target, false); + has_idle_core =3D test_idle_cores(target); =20 if (!has_idle_core && cpus_share_cache(prev, target)) { i =3D select_idle_smt(p, sd, prev); --=20 2.31.1 From nobody Sat Apr 18 17:25:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F4C4C43334 for ; Tue, 12 Jul 2022 08:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232775AbiGLIW0 (ORCPT ); Tue, 12 Jul 2022 04:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbiGLIV4 (ORCPT ); Tue, 12 Jul 2022 04:21:56 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94F4AA4382 for ; Tue, 12 Jul 2022 01:21:23 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id p11so160005pgr.12 for ; Tue, 12 Jul 2022 01:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X/AmHtaoJN9cStmlDDuzEHtA59f9y41ieyctN/HPoTQ=; b=jgEQ5uhNQz9tCVVSvOkNk4YrqUylHK3wp1uDHToutGBzvvT1IgkWKk8ANT5KbTleHV 30/MDid4zVk1iYSQ4UaBd/TpCNyguZZOoiJz7Ga4b0eM1HXpbZ9mQ/Vs9Lp+heVIEUWp e7j+ZvxUlkuFHs/mo9ma2fR7a/ADbFBq3ad2qYZKuxPNX5U0jttFQ1sv5U4/3FC2FJTu roH3S7f6quxz2h0ZyT7pvWR/Ye9505qfPGAwqG9a4jVgoJbJONU9o3u1jWufS8GHoQJA q7L0qx1iLw/sGJYWkICuonzPcdBaIaMqE3pK1hqYWUFs7BptOzMiMBWwBK2Wweb0xc+f hwSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X/AmHtaoJN9cStmlDDuzEHtA59f9y41ieyctN/HPoTQ=; b=hGOivaVFJntC3NoQ3cMG/wHKYGx/PUD5u7Se6MxFkC76R0IaJ3gtSnzcRVauzPdXnO nsV3lQnZtSIZ5nKYuG7EAFatp2nT1+eQCcrF+FOeXplLjq+24TJndTPN9DdHwDM/nRtD kOwayf4/Td3jBLOgeQOFc4fQdVhId7SfNiI2gojsP7UAhvY9DZkir+Nc0IXzGZRa0mTT Rd0A66FDBWOGZjhuNb05+lKidxo5lZtK0EppGha7yWo8+ttcHHFq1bfQp+/PPIFW+GRT sKsmQXf1OuT3CHOoKlrC6KCuLOx9rTs+vHuZdEujBn3eXghCsPyRtCEKKhNJmtzn0gIg IV6w== X-Gm-Message-State: AJIora8AvisTEnPtwV/J5emFMl1oy64r+Lc49/oz+Mygnqo3sysYViKg 4iYAztKZqYgdVAdyEzOVLCb50g== X-Google-Smtp-Source: AGRyM1sRj7yQTDFa/JHdPgFYNqBD/fpW54n/sLLItrO12A92nmwPxi2LPUQz3frLSHs25wqPV7GRbg== X-Received: by 2002:a63:540d:0:b0:412:9fb2:4d4 with SMTP id i13-20020a63540d000000b004129fb204d4mr19528428pgb.475.1657614083050; Tue, 12 Jul 2022 01:21:23 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:22 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 3/5] sched/fair: remove redundant check in select_idle_smt Date: Tue, 12 Jul 2022 16:20:34 +0800 Message-Id: <20220712082036.5130-4-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If two cpus share LLC cache, then the two cores they belong to are also in the same LLC domain. Signed-off-by: Abel Wu Reviewed-by: Josh Don Acked-by: Mel Gorman --- kernel/sched/fair.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c72093f282ec..0d7e8555bcf9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6339,14 +6339,11 @@ static int select_idle_core(struct task_struct *p, = int core, struct cpumask *cpu /* * Scan the local SMT mask for idle CPUs. */ -static int select_idle_smt(struct task_struct *p, struct sched_domain *sd,= int target) +static int select_idle_smt(struct task_struct *p, int target) { int cpu; =20 - for_each_cpu(cpu, cpu_smt_mask(target)) { - if (!cpumask_test_cpu(cpu, p->cpus_ptr) || - !cpumask_test_cpu(cpu, sched_domain_span(sd))) - continue; + for_each_cpu_and(cpu, cpu_smt_mask(target), p->cpus_ptr) { if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) return cpu; } @@ -6370,7 +6367,7 @@ static inline int select_idle_core(struct task_struct= *p, int core, struct cpuma return __select_idle_cpu(core, p); } =20 -static inline int select_idle_smt(struct task_struct *p, struct sched_doma= in *sd, int target) +static inline int select_idle_smt(struct task_struct *p, int target) { return -1; } @@ -6607,7 +6604,7 @@ static int select_idle_sibling(struct task_struct *p,= int prev, int target) has_idle_core =3D test_idle_cores(target); =20 if (!has_idle_core && cpus_share_cache(prev, target)) { - i =3D select_idle_smt(p, sd, prev); + i =3D select_idle_smt(p, prev); if ((unsigned int)i < nr_cpumask_bits) return i; } --=20 2.31.1 From nobody Sat Apr 18 17:25:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC07DC433EF for ; Tue, 12 Jul 2022 08:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232346AbiGLIWe (ORCPT ); Tue, 12 Jul 2022 04:22:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232786AbiGLIV7 (ORCPT ); Tue, 12 Jul 2022 04:21:59 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A842EA5E41 for ; Tue, 12 Jul 2022 01:21:27 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so10678888pjo.3 for ; Tue, 12 Jul 2022 01:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tPCKm2gvds2lzYICLyS9Zh4eZd8vzB/7YXbaR5AiWlU=; b=UDYGJcUnyrLKSaNyp+xCZcL78T71vqVdok+I4gDUp2YoeH8l2Jy9VbsqZiNUqN3oG/ DC/URdM8RLJtJaiExWX1K1mvXC2FKtHenFA/Mn0QwTdKA/nrpA5Rfm+8ICHAXB6tfJKx +FXQcoX1GIf/iqNy6+LRuW2ySoNDTI+94dmiAzHH0UkLY/AIL9cqHBtbDWsCUYwn0npz NoESXMEIfQYWgotxBh7wc7UP9w0YtMInEcxvfBYL7rdOIWMll98b1FqaaEvt4xJ0zlJS s67mSkZsvNdWS99YeEjPIm/oxaXyScceiYokNnIbKybpRaV8jN2bmJ1Iur42bqet1Bjz C25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tPCKm2gvds2lzYICLyS9Zh4eZd8vzB/7YXbaR5AiWlU=; b=2+b6DBq5QEDo0l11s7nC5WaKAIH85jiRx8v+QQSpqBoiUXk/hom+JmTYKnPmoREEGt dAkYCeWlBk85CFWNIp1egti5wJXVJY8M6cbY6WE182lI3GrEuQgrYca9sauV4hMCfAuk PaCmRsIC9zGBcdRelMKe2BNiy77IYaQhY5kJwVi27YldfU6V/W9VEtApTod07CoXE9ER jUZYMQd9fHgU3n56igCOjPIaXHjBhze8PROJ9UEGrKZNSDLfEFHVfzRPynbzVc7o95gS PWPQHq5U4UUH58WjZjc0PVGuyUkYkLjbEeXd2CQ3MdSwsi9G+szBxXNEG6kX8d4R3hbE zTGQ== X-Gm-Message-State: AJIora9o9G1HwVy4XEz1eqphv1RhCP9c+R52YkyRIL2Uum2o0mjpBEul 0usnnj+qa8axyACzEAN5YYUM0g== X-Google-Smtp-Source: AGRyM1tz42o+WaTRfkEaUNwlnpnYrB+aHELcH4+k0om9CWtRYZ0yw5NlBrTUrmE96pex26mOLNVhhQ== X-Received: by 2002:a17:903:244c:b0:16c:594b:3f4a with SMTP id l12-20020a170903244c00b0016c594b3f4amr3429526pls.145.1657614087265; Tue, 12 Jul 2022 01:21:27 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:27 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 4/5] sched/fair: avoid double search on same cpu Date: Tue, 12 Jul 2022 16:20:35 +0800 Message-Id: <20220712082036.5130-5-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The prev cpu is checked at the beginning of SIS, and it's unlikely to be idle before the second check in select_idle_smt(). So we'd better focus on its SMT siblings. Signed-off-by: Abel Wu Reviewed-by: Josh Don Acked-by: Mel Gorman --- kernel/sched/fair.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0d7e8555bcf9..e4cf000604fc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6344,6 +6344,8 @@ static int select_idle_smt(struct task_struct *p, int= target) int cpu; =20 for_each_cpu_and(cpu, cpu_smt_mask(target), p->cpus_ptr) { + if (cpu =3D=3D target) + continue; if (available_idle_cpu(cpu) || sched_idle_cpu(cpu)) return cpu; } --=20 2.31.1 From nobody Sat Apr 18 17:25:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55B17C433EF for ; Tue, 12 Jul 2022 08:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232715AbiGLIWi (ORCPT ); Tue, 12 Jul 2022 04:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232712AbiGLIWH (ORCPT ); Tue, 12 Jul 2022 04:22:07 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27899A2E55 for ; Tue, 12 Jul 2022 01:21:32 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id o18so6911627pgu.9 for ; Tue, 12 Jul 2022 01:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9lB01uOqkHsSTj1k0Qc0PPFlLmv1AdfQPVQEj5smHQY=; b=aUeQeiOM9gP+inZESDjpYXky41b/FYuMawY7u01ip7ODzNTdV/t/vaE7YQ+se4eEWj EDmjLVcymmkJyeBpBJXNliBohJnftQO8AVgwK89XlIIke+liNhlV2KwMQHPN6RLBO4tI vq0IRzUE8p1dEMY9Ikok5YFnl6acVkb8v3B2/+4DVSMWeaeTu34VvClXfmv6rvtyuBA6 9zoHjSoydFBvkGiyXvkCNQEzYFzmpjCKgf3E0sDrD5gIIjfRAUSQRAAZyPrdxu5Ca6We 7i6fSNvEkdrOWjkcwtx9MDv55Oe0oxgktnn1Z382Uvoanm809EfiwlGzwFp6JpZ9UTWe 81sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9lB01uOqkHsSTj1k0Qc0PPFlLmv1AdfQPVQEj5smHQY=; b=NbcVO4Yqw60T5Da1ZqGyMF6ovJ3IPKjrdD9KJ/59xDpIdjOjX1hbQMJLqAGRbd40z2 r0J76DC83SaAClgJ7uk1H06nypG0HccQsisFKAeFtZkY3m/I6kG+Q1qWf/HLzSYXvQfT KGnkQkaNtgRNr+NbK5epOxNuiUjcGgoIsZEJkJ5DU5fi4uF4/yK05Uat7GFA8g/KOVtJ SZhaSlP74SQEx5bJf7VN4oCXcFvZVnrumC4jaNGhYOJd8zLclo67ycWcPrMPj2JpuvGl AHdniz/hSdIw3Oti8PnGdktHsXolKoeVdcruSZYPvc4ZVhofBezsfUNOQnwNSXzeM0GW pj9g== X-Gm-Message-State: AJIora/rbKDRshscY/0LmTMvp5SICoSZLLh+QIcnojcn6UO0pmb4puGG 03gNMH+bBMFHDeuz+RtUoH5xYw== X-Google-Smtp-Source: AGRyM1t/WDstJHyps+iSwM/OfNzCW8PKhA0zB1hnOIPeTR4rr5aLKL2XKMcXm8IRzxqQCjM9L2Cm5w== X-Received: by 2002:a05:6a00:993:b0:52a:dd93:f02d with SMTP id u19-20020a056a00099300b0052add93f02dmr5122263pfg.12.1657614091466; Tue, 12 Jul 2022 01:21:31 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:31 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 5/5] sched/fair: remove useless check in select_idle_core Date: Tue, 12 Jul 2022 16:20:36 +0800 Message-Id: <20220712082036.5130-6-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function only gets called when sds->has_idle_cores is true which can be possible only when sched_smt_present is enabled. This change also aligns select_idle_core with select_idle_smt that the caller do the check if necessary. Signed-off-by: Abel Wu Acked-by: Mel Gorman --- kernel/sched/fair.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e4cf000604fc..7c47621ccd40 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6310,9 +6310,6 @@ static int select_idle_core(struct task_struct *p, in= t core, struct cpumask *cpu bool idle =3D true; int cpu; =20 - if (!static_branch_likely(&sched_smt_present)) - return __select_idle_cpu(core, p); - for_each_cpu(cpu, cpu_smt_mask(core)) { if (!available_idle_cpu(cpu)) { idle =3D false; --=20 2.31.1