Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2458790pxu; Mon, 7 Dec 2020 07:10:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlO8Ln9n04pVzHUkAsyHz14+tynqlLv22YRm1UioemVAZQHN+vCjUnvqPaYfjpf6b8Sg8N X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr18520578edu.2.1607353846583; Mon, 07 Dec 2020 07:10:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607353846; cv=none; d=google.com; s=arc-20160816; b=UPF5gOrm3EO9oMh4H2fWSnOnesyfu79TUoIWuu2J427INN50fZzLLMb8deMDi8cdxP inR/M9A45aT3K30QD/5AErMuzqgt5CEAQoyU3ukj/4+sgexrm4co1vXJER+7qglTBPkt j6nNUgDFQv10X1WITO1XFVhO1I6wjBdURokzFBvkIn/5WgC6JJeF+erw+VrKSrz8XngA /8vnryxFa61uqJj2XKVB6FsuMpe01zYIcZv0rJJ4FzmecvEBcQbV6cvYSGfC9cY0lfGr 4nS+/gF5a3d6LwXbY3UPW7IuYzSOH1J8Nh+gLYW052BSXh4ui/jT7l7C5KEHPFVdz5hm ufCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6EHGNTCOqzQDyDF6Ur2z/ZJXaKN5/flAOrEQJLIGkas=; b=i68rvo9XAf6wUGwnhYOaZ8aOmyFCzX/W45ILN2kaEgMeuaAAZ2tCr9SThfaXwrjHVt ba+oOJLmUudg/IvWCCrhn91XOM0Ed8mIAkaW3w/6PODb6Ijibu2bL9Y3ZlvwoKLF7A9m 1iFu5y96/jOJkBYTSFvGY73iw0nhBWiOY9o7tyIdK0sn0BToIsGBN7gaQ/txVPUjzqd+ 6TZkKOgT0aZ8BpC5h5N2y/JNjzCnHrtzP+AtFBY0RQ6bWTqE8A9q5t3dmQl3Mdno9r+8 /iXPzoNVtwXM1Jf6g47nS30jonDMedVU4Wpb3gy2IDdK1A4fZQnZ9vjXE8SwkOAUC6Dc 5dzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOdm47wr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si7734066eds.206.2020.12.07.07.10.20; Mon, 07 Dec 2020 07:10:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOdm47wr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726880AbgLGPHm (ORCPT + 99 others); Mon, 7 Dec 2020 10:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgLGPHl (ORCPT ); Mon, 7 Dec 2020 10:07:41 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884F4C061749 for ; Mon, 7 Dec 2020 07:06:55 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id 23so5538180lfg.10 for ; Mon, 07 Dec 2020 07:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6EHGNTCOqzQDyDF6Ur2z/ZJXaKN5/flAOrEQJLIGkas=; b=dOdm47wrW/xk1WQytScoi3uZ/jXVg/t3v4NQrzedMCfdC1qhjLI/DLllqCSNcXIGwn UxpzdAZx3CnDdyjvoW0AEeoCGz96MphzHymNzH93l2C7EDsoQzOYiIg9ujnfndBJvGEF 2sb1HbMRbKApf6cdV0EhBPl57Z11L4rRWaUPHQLUHlV1KdFwW6CLg5h0/q6Wou31Ec4h grFaYOU741QAx7NGheIQDANcoR3C1IWXA+HBdhMzFqEKd2FkTMkDP459YmljQejUmy1F eOlqsg0nJaIPfseK0souZK7N/p7pzIt5jGpXBcQxY3+ScVmmii78v8xuIMNS/tOnjoZ7 6SLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6EHGNTCOqzQDyDF6Ur2z/ZJXaKN5/flAOrEQJLIGkas=; b=E6uF3HmbRwG4mJy0GKJv14x/BA23NpMbOH1EP4JJqf2e85tPafy+DNFD+iRZvEpqr+ brL0bcmE+X60ciG9YPcGTW8r+g6KGK3PvVxqYBcE4nDlC2vRknL8gCENh9zcGQC0juDB n3daCiglba8inHUd3TNXwQP0S6XE1eEtdcwPs5SQqxdoC8NQ5Jgl79z3nwvByU7WMvIP HQ82mmgSwegRvjkxEJPvQPx9BpsjojmoHZGyciZoxTE1lpLLRLZBpM78QV2SvbTkUE72 aBhh2C7u3mWmOWO1vQ7ya/h69oEaB60KH0c6fXPQsPIRMLKv0GswJdBy78W3gmMW/N6q Fy8g== X-Gm-Message-State: AOAM531zl3ga7+wmxdS/SOPHgi7LqFGnC/Yp8gSzQtNoSnojrcVwznOc IHlEzfJSFaX1THGESsLVF681BSbMJMqu2BSD4iAIbQ== X-Received: by 2002:ac2:43b1:: with SMTP id t17mr8669565lfl.385.1607353614005; Mon, 07 Dec 2020 07:06:54 -0800 (PST) MIME-Version: 1.0 References: <20201207091516.24683-1-mgorman@techsingularity.net> <20201207091516.24683-4-mgorman@techsingularity.net> In-Reply-To: <20201207091516.24683-4-mgorman@techsingularity.net> From: Vincent Guittot Date: Mon, 7 Dec 2020 16:06:42 +0100 Message-ID: Subject: Re: [PATCH 3/4] sched/fair: Return an idle cpu if one is found after a failed search for an idle core To: Mel Gorman Cc: LKML , Aubrey Li , Barry Song , Ingo Molnar , Peter Ziljstra , Juri Lelli , Valentin Schneider , Linux-ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Dec 2020 at 10:15, Mel Gorman wrote: > > select_idle_core is called when SMT is active and there is likely a free > core available. It may find idle CPUs but this information is simply > discarded and the scan starts over again with select_idle_cpu. > > This patch caches information on idle CPUs found during the search for > a core and uses one if no core is found. This is a tradeoff. There may > be a slight impact when utilisation is low and an idle core can be > found quickly. It provides improvements as the number of busy CPUs > approaches 50% of the domain size when SMT is enabled. > > With tbench on a 2-socket CascadeLake machine, 80 logical CPUs, HT enabled > > 5.10.0-rc6 5.10.0-rc6 > schedstat idlecandidate > Hmean 1 500.06 ( 0.00%) 505.67 * 1.12%* > Hmean 2 975.90 ( 0.00%) 974.06 * -0.19%* > Hmean 4 1902.95 ( 0.00%) 1904.43 * 0.08%* > Hmean 8 3761.73 ( 0.00%) 3721.02 * -1.08%* > Hmean 16 6713.93 ( 0.00%) 6769.17 * 0.82%* > Hmean 32 10435.31 ( 0.00%) 10312.58 * -1.18%* > Hmean 64 12325.51 ( 0.00%) 13792.01 * 11.90%* > Hmean 128 21225.21 ( 0.00%) 20963.44 * -1.23%* > Hmean 256 20532.83 ( 0.00%) 20335.62 * -0.96%* > Hmean 320 20334.81 ( 0.00%) 20147.25 * -0.92%* > > Note that there is a significant corner case. As the SMT scan may be > terminated early, not all CPUs have been visited and select_idle_cpu() > is still called for a full scan. This case is handled in the next > patch. > > Signed-off-by: Mel Gorman Reviewed-by: Vincent Guittot > --- > kernel/sched/fair.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 01b38fc17bca..00c3b526a5bd 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6066,6 +6066,7 @@ void __update_idle_core(struct rq *rq) > */ > static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int target) > { > + int idle_candidate = -1; > struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask); > int core, cpu; > > @@ -6085,6 +6086,11 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int > idle = false; > break; > } > + > + if (idle_candidate == -1 && > + cpumask_test_cpu(cpu, p->cpus_ptr)) { > + idle_candidate = cpu; > + } > } > > if (idle) > @@ -6098,7 +6104,7 @@ static int select_idle_core(struct task_struct *p, struct sched_domain *sd, int > */ > set_idle_cores(target, 0); > > - return -1; > + return idle_candidate; > } > > /* > -- > 2.26.2 >