From nobody Mon Apr 6 12:33:20 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 536ECC38145 for ; Wed, 7 Sep 2022 11:20:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229738AbiIGLUb (ORCPT ); Wed, 7 Sep 2022 07:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbiIGLUX (ORCPT ); Wed, 7 Sep 2022 07:20:23 -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 5C65783BC6 for ; Wed, 7 Sep 2022 04:20:22 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id n65-20020a17090a5ac700b001fbb4fad865so14423656pji.1 for ; Wed, 07 Sep 2022 04:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1+Agwc67cdmFUqKrKuUk9pQZaioY9SDdZ0DErnLUR7I=; b=jdsRL2VLr6BOeCk85a//yWe+laFiC5io9+vVfRcqwFsMNk/Dk2db54IZzXKtjk0xFy Ph8VkA2AT80oR5mLzBOUkxN9oVi6rmj9p/kbaKkzoG7nv4OHLwnTKT3u3GvT2kDgpugA bmu7yWys15S0ot8To5p/1FRZsHKtGN6krFaU2bXCDUbVg22UxnJKuHcnKfaBdEmU0jJn NopP0zanOgxBlCMRseZFFG3DPwq2PJIBKUa/KfhRim2Qsyy9t9fz0Ojh4sEk49YEz445 vjlbUU9v3wRlFsvGum7WV+KdxmDlGKYRnnTzVzEGV/CSTL0Z34+WhR7n+zesu030EXb2 MaOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=1+Agwc67cdmFUqKrKuUk9pQZaioY9SDdZ0DErnLUR7I=; b=iltLM+P8QMerLIlo2f760Js4o4JkOBxASD56a7K2aLFMfphcpUadCtyLpZTu6hM0TK p+RHes7Mwn58odGfSSZrqh31y+4lidB/0W5GXILns2YojITMusOH9U/RWW79yBGaibw+ 8WHyO9cmAWm/3JyUYsV9l9d1UX9EmLrYDQsi5jWRAEelMCKLnRhk4i79wasMjSgvUu1s DGeWPfe3rRU7GNqDnj+uckY/OZTKSSCZvS86YEROSmz7Yvj+3vyerusJ76VVhs/HEANQ tyr2J8g29EePYbLv1KYCUz2l9QBIz+z0v4jm9IZweu08llsNMea69SFUcOGtDIDHo5pv cTww== X-Gm-Message-State: ACgBeo0+jPdjzkbyF8cz4wTuVtcNDd6WMT/Z86bcKyJtkUs4FJ3zbp8l pZnKSkNsirjR3Vr4uXTHbuVF9g== X-Google-Smtp-Source: AA6agR6NzATHYK/Urr4ZT/bAY6RPDO7NsWA1EsZuDgIn/RzJ6HC+II5bVQ1gUsGfLPsegK3B08MTfg== X-Received: by 2002:a17:90a:318f:b0:1fa:a374:f565 with SMTP id j15-20020a17090a318f00b001faa374f565mr30069387pjb.146.1662549621545; Wed, 07 Sep 2022 04:20:21 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id d12-20020a63f24c000000b0042ba0a822cbsm10334731pgk.8.2022.09.07.04.20.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2022 04:20:21 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org, Abel Wu , Mel Gorman Subject: [PATCH v4 1/5] sched/fair: Remove redundant check in select_idle_smt() Date: Wed, 7 Sep 2022 19:19:56 +0800 Message-Id: <20220907112000.1854-2-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907112000.1854-1-wuyun.abel@bytedance.com> References: <20220907112000.1854-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 efceb670e755..9657c7de5f57 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6350,14 +6350,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; } @@ -6381,7 +6378,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; } @@ -6615,7 +6612,7 @@ static int select_idle_sibling(struct task_struct *p,= int prev, int target) has_idle_core =3D test_idle_cores(target, false); =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.37.3 From nobody Mon Apr 6 12:33:20 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 EA5C5C54EE9 for ; Wed, 7 Sep 2022 11:20:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbiIGLUh (ORCPT ); Wed, 7 Sep 2022 07:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbiIGLU1 (ORCPT ); Wed, 7 Sep 2022 07:20:27 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02A8F83BC0 for ; Wed, 7 Sep 2022 04:20:26 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id iw17so7543928plb.0 for ; Wed, 07 Sep 2022 04:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=75oh6xQWlTnSSymHGyItVY3zWSzkWl5meciwNnzeuy0=; b=PdxzqPPzNxrao+KcCVwt2ythahQZX8MMyQBWw2fuFSGEHMrh6N/zQO/9BwzPDL6cQ5 fcSu/krE12h5g7NkLUoQnzrIrPFOzyVjYTce5N4zhFJ7zUgcbd22dO/x0W69vsmb0yiq vN3kn6NjF5Qm460FtxPADuHzw5e7pnOBOlakfT+xXDR54tp59bcYDYLPa3S06q1XXoVi uZnnirxkh+tklpOVjtip5mu1eR92LpsXkF3IYzWfQJQVTJ1pnpPf7HJa1BMhnvRtJ5ni gw4oc1LzlPuS3NyO197z6LhaG5A7wE/rh19p2yUYsNdsuH8mmKa5wl/moNchiSwEnbiS kdLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=75oh6xQWlTnSSymHGyItVY3zWSzkWl5meciwNnzeuy0=; b=RuVFr7inTJfYCbVIz9CZxd+yO5RMq4XNs+wxLCnDo2+2CWU046m1iHKSIKDZodJpT2 ttdRhZ2jIULv0muhErkEIfz+JNs0EislSylbXbUHO/xzGCKWiOQwEiQlwM1c9RdZdbG3 bVUotLDo+IzjAh7rAu2RfRAK/2t8IU9UkvxkpQ+WuEFN1r2QweN60Luze33poawQaeL5 +0beNABGYaTiR5aWZfegoqllFKmJEDk+u9KHaho6apVp6uKf+gQKLblV1temWwdyuBxd YA7L3iG69XgTyo54pKyjXMGVKZJerCHr1DhSb/A0/UQhyy+uCGxCOITOeyY/83scgbIU LeRA== X-Gm-Message-State: ACgBeo2o2YyATKv+ROPqWwfLFnHlK+cJqaQGyw5tVD2hkm4trIDqwmit TJ/e6lUyw230dWHWWgsL40f5VA== X-Google-Smtp-Source: AA6agR4GX94IaU6dQoeitqb7LX4chBXmrXy90EVoZ0eQdBctRNpyeB6hnT7s/7zVCpyVOHFUH6Xg8Q== X-Received: by 2002:a17:902:bc84:b0:174:505b:2d67 with SMTP id bb4-20020a170902bc8400b00174505b2d67mr3393134plb.33.1662549625548; Wed, 07 Sep 2022 04:20:25 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id d12-20020a63f24c000000b0042ba0a822cbsm10334731pgk.8.2022.09.07.04.20.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2022 04:20:25 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org, Abel Wu , Mel Gorman Subject: [PATCH v4 2/5] sched/fair: Avoid double search on same cpu Date: Wed, 7 Sep 2022 19:19:57 +0800 Message-Id: <20220907112000.1854-3-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907112000.1854-1-wuyun.abel@bytedance.com> References: <20220907112000.1854-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 9657c7de5f57..1ad79aaaaf93 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6355,6 +6355,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.37.3 From nobody Mon Apr 6 12:33:20 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 8FE4EC38145 for ; Wed, 7 Sep 2022 11:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbiIGLUn (ORCPT ); Wed, 7 Sep 2022 07:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiIGLUd (ORCPT ); Wed, 7 Sep 2022 07:20:33 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF3889822 for ; Wed, 7 Sep 2022 04:20:30 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d12so14186320plr.6 for ; Wed, 07 Sep 2022 04:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Stmo/b+IFMKFH7NQQb7Kt0yurZmKvJLuzBGo1PCIQOA=; b=mZORR5nnp1KIcje6ldMVRn1db1BpmUJJmyvhw/8+SGCmBWLlmYit2p+4VNmS9vBEB8 epf3wm2sF8HX84dV6SE2vz61xe08SxQ2AiL0VuZl6doERpTRPn7oMWCTd2rb/rPOD7bV CYytTdocYXdEWk2NqpHYinqSQobGT5IiorRzDWyUgjDD2nGsmsya1wiMZEbhOfALpQ2Q 6qz82yd4yST5HJKB9bWc2qZMMtya1P8oW7ba/2T8M7EEggy4LrfNLq9oW56C1g9mMqMx eZ0A5SvZd8+EHEkCuT2+lZrj0bsF3oVWC5uvB4FYxMFeNO+dymV1iCM1rDElT4rJf5r4 j5lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Stmo/b+IFMKFH7NQQb7Kt0yurZmKvJLuzBGo1PCIQOA=; b=zn/zi6IucK2o+PhMz83XLZx9ZfJekUdw0485RxYyAxg/VtQ+fkcEGQsJdUwOtOE9ml wcwjFRYBjQgUkBJbHXJDATpQWIB6XGApJgoB0L+3R4+VmDwzJd2t6MJSQEJ0ux4FrM2K uZOGgZUP8crkEr4hv8QFQiy3KY7xTrGsbvFnJ6kvWMh/laUr7j+qoD+08G+/me4bVix4 0LbjPAW7wf/yR07kguBxlBM5Vvwb2WcNO6AfPzcZTzl8cEvNhR7nJrZ/yF4AZ/6EsAXf NOWXw8/IPOz8ydMpFwNjxHk5Z3yG+l+UR0C1u8UuB/nPeiPs5Ktt+TcnMcLmsmHCaNqU VRvw== X-Gm-Message-State: ACgBeo3bmQJ8zxRuoCdRkIHppzE6fhQKQXdhtInL1HehbyMmhzItnEtS ZUy3Y7Pp1Jb4rzURjmQ/D27BMA== X-Google-Smtp-Source: AA6agR6ALcPUImzbs5VWlBJNpidlt9nyHKGmW2mYKaMSecNwNgFLbKRHmLbj10tMLZZ2YhdeSnjgsA== X-Received: by 2002:a17:902:b484:b0:170:a2d8:80f6 with SMTP id y4-20020a170902b48400b00170a2d880f6mr3233963plr.97.1662549629552; Wed, 07 Sep 2022 04:20:29 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id d12-20020a63f24c000000b0042ba0a822cbsm10334731pgk.8.2022.09.07.04.20.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2022 04:20:29 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org, Abel Wu , Mel Gorman Subject: [PATCH v4 3/5] sched/fair: Remove useless check in select_idle_core() Date: Wed, 7 Sep 2022 19:19:58 +0800 Message-Id: <20220907112000.1854-4-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907112000.1854-1-wuyun.abel@bytedance.com> References: <20220907112000.1854-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 select_idle_core() only gets called when 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() in the way 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 1ad79aaaaf93..03ce65068333 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6321,9 +6321,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.37.3 From nobody Mon Apr 6 12:33:20 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 64429C54EE9 for ; Wed, 7 Sep 2022 11:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbiIGLUz (ORCPT ); Wed, 7 Sep 2022 07:20:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbiIGLUh (ORCPT ); Wed, 7 Sep 2022 07:20:37 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C629C509 for ; Wed, 7 Sep 2022 04:20:34 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id b144so9505131pfb.7 for ; Wed, 07 Sep 2022 04:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zgNdNFVnyT3RvVPbn2/w87CgJ8L2KSpB08/IQc4YsQE=; b=XR+dyQcfBvYRAdbviqvY3HgN8jfgFlTfznz1Ftjck+AzAjWQ3ELl+8Uvsj/UTjDF2C kaBRXGs4LpF55ccn/o4UsgVZ+1u11vPysBLmd3ptaoYjUUNVfR44kv4+elRvVzjN6jb0 AFRdUmGmAneNeaTyWubR6kmIFjcfYmaNE7t/x7EeeFdQQl1IaFjlPUvYNUrv2w1Ssuzj etcuIqNwGsHT0u8EG4pMuO/JBgVkA8EbYUPRxhOecDbZGWDN/P2ioMamaNZ5NwF85Ee8 BqQEUsPgx/m80fuIm/0X4Qtrgsz1RRTxTM23LbhHLWX+hMVEyRbrp2UHTu5XSfidICh8 YKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=zgNdNFVnyT3RvVPbn2/w87CgJ8L2KSpB08/IQc4YsQE=; b=wbJ4ypxz4IddPsiZvhFyMlkGkBdW+poaVRtFN/EeAP3gytKfk7pTNHExropyC9lwxw ickjZ/9P59oNi1/BVExAK+T//9uQ7+SX1QkKx/bCTLRFfl47/yxnVVMQeHZevVB6CUvw wpZ2EiZun5a0V7dwwjvpIp+ZjGAZLWWZk3fn3jJEHqhdonGGT9OkI7sJ24qhAPGjOrSQ tGQm3ndIec+BW6xhSUe6jzH1V+3ItX1e+lw2RCXy4G3nK8M4EfmkLf8eF/N3dzm2gV3t CRc3IgeoNGItRqqUMFRB+JDwqv/uZZau6VqXCToaCn4x7JgTBC+hw8oMEA3WzRM1BGVU xl/A== X-Gm-Message-State: ACgBeo2laOp5Ze9UncMRHbyVC1A9Edshm88a4Ud1RW7QImUKnuGlmSpK f7K6Aoe1AsEFTsZrJNRbFXF8oQ== X-Google-Smtp-Source: AA6agR6GyoYZk7c6Nnffk9vHlWOkHTJSB5mjnEosrMB01rPpaslj2Wtnu1jM1A2ZeoFMdR7jk+yTiQ== X-Received: by 2002:a63:5658:0:b0:42a:1663:b965 with SMTP id g24-20020a635658000000b0042a1663b965mr2958745pgm.486.1662549633605; Wed, 07 Sep 2022 04:20:33 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id d12-20020a63f24c000000b0042ba0a822cbsm10334731pgk.8.2022.09.07.04.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2022 04:20:33 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org, Abel Wu , Mel Gorman Subject: [PATCH v4 4/5] sched/fair: Default to false in test_idle_cores() Date: Wed, 7 Sep 2022 19:19:59 +0800 Message-Id: <20220907112000.1854-5-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907112000.1854-1-wuyun.abel@bytedance.com> References: <20220907112000.1854-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 hint to shared sched-domain if necessary. So the whole logic of this function depends on the existence of shared sched-domain, and can certainly bail out early if it is not available. 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. 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 03ce65068333..23b020c3d3a0 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1588,11 +1588,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 /* @@ -6271,7 +6271,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 @@ -6279,7 +6279,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 /* @@ -6295,7 +6295,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)) { @@ -6367,9 +6367,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) @@ -6608,7 +6608,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, prev); --=20 2.37.3 From nobody Mon Apr 6 12:33:20 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 8D833C54EE9 for ; Wed, 7 Sep 2022 11:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbiIGLU7 (ORCPT ); Wed, 7 Sep 2022 07:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbiIGLUt (ORCPT ); Wed, 7 Sep 2022 07:20:49 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDB986B4B for ; Wed, 7 Sep 2022 04:20:37 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id iw17so7544405plb.0 for ; Wed, 07 Sep 2022 04:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=aDniB8hJUxb/LoNqhQjiZRSUOVFgsRjJ2v0euL0XhpM=; b=B3KZs+fMUKHDSVYXzQBLMPYQfcMKpZy2VsEdFjggSkPKS6mg2CCks+Dt4+HJSB9jjo WnRiObuTk+sC3U4oZnwbSO6nEQKZlZFgOZaukkn4rS+GHjiyvJ2JFE9+MnavIMYZ58rf 3OtB8mWnNWmTog7QWeuNMoh21hIPwRpW4FAgkghVj+1iq2MDXZ7d5N2Vo03v24W3ekbj 5dac+ZvUxCkRVoZTDSpbJr8eBQaCESm5pBDP6ND695M68rVVsPnBT3Hdmt8JYE+vInS3 8q7z1O02qGn3AhPPl/XAVntVSc+ECNLOUuyDGE6HzHKgNgP0KQkvidXbyA3K8vFZiMpS cc+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=aDniB8hJUxb/LoNqhQjiZRSUOVFgsRjJ2v0euL0XhpM=; b=AlZP20fZyrC85Obkeg+1DVrQZ/hkIScnGiBIWg2+XHT6rk2nDm7ipsFkRm42vZfBWG lbt7md+pA4AmFEhD8s+H/QuZZRC393B4y5iCkHpskax2g5oqOtn6HlqPmbIJ0p0I3JSy SUgn6DEdlmmlVymHVdMoUVLBgn6sfuHgnqMgsUcTS+W4BircBWFrNsh78YwYtmOANVA5 SwgTFt+pIURsb8+/7T+urtnotw59a0swN0xA5+Z44lsnHmSk/x0Ej1mOxU0yQqzcqn4q k2Kz54F9bin+6oameU4Tz/1dCHoZD09TpzJExj6OL6IrxNtEVCPoBqdN4552/NUoA5mz Payg== X-Gm-Message-State: ACgBeo3VYtpjZz617uzbG6pu6FFxQA4aphBvmUbCa2//MEz71pvlYNhr HDtLMPgnnofzVZwOoNHfsbyHRQ== X-Google-Smtp-Source: AA6agR5C7KOVsKCuIqYGN5BWgkxBIsdBaOWkm0jQu98JwoSuyDpfaPmU/9X6BS3Lnd5CFo1KYYcStg== X-Received: by 2002:a17:903:22cf:b0:174:a5cd:31e0 with SMTP id y15-20020a17090322cf00b00174a5cd31e0mr3285343plg.23.1662549637312; Wed, 07 Sep 2022 04:20:37 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id d12-20020a63f24c000000b0042ba0a822cbsm10334731pgk.8.2022.09.07.04.20.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2022 04:20:37 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , Yicong Yang , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH v4 5/5] sched/fair: Cleanup for SIS_PROP Date: Wed, 7 Sep 2022 19:20:00 +0800 Message-Id: <20220907112000.1854-6-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907112000.1854-1-wuyun.abel@bytedance.com> References: <20220907112000.1854-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 sched-domain of this cpu is only used for some heuristics when SIS_PROP is enabled, and it should be irrelevant whether the local sd_llc is valid or not, since all we care about is target sd_llc if !SIS_PROP. Access the local domain only when there is a need. Signed-off-by: Abel Wu Acked-by: Mel Gorman --- kernel/sched/fair.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 23b020c3d3a0..7bad641faef9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6396,19 +6396,19 @@ static int select_idle_cpu(struct task_struct *p, s= truct sched_domain *sd, bool struct sched_domain_shared *sd_share; struct rq *this_rq =3D this_rq(); int this =3D smp_processor_id(); - struct sched_domain *this_sd; + struct sched_domain *this_sd =3D NULL; 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) { 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 @@ -6462,7 +6462,7 @@ static int select_idle_cpu(struct task_struct *p, str= uct sched_domain *sd, bool if (has_idle_core) set_idle_cores(target, false); =20 - if (sched_feat(SIS_PROP) && !has_idle_core) { + if (sched_feat(SIS_PROP) && this_sd && !has_idle_core) { time =3D cpu_clock(this) - time; =20 /* --=20 2.37.3