Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4131394rwl; Tue, 28 Mar 2023 03:07:20 -0700 (PDT) X-Google-Smtp-Source: AKy350YHmIB7viGiTIYHMBacNSuWJPbwczTYXx09lzfKgLj8kOMec4Bf1mQR5v7wi2XnKGT/Xrs+ X-Received: by 2002:a17:907:8b8b:b0:93e:2289:ecc0 with SMTP id tb11-20020a1709078b8b00b0093e2289ecc0mr12627171ejc.42.1679998040451; Tue, 28 Mar 2023 03:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679998040; cv=none; d=google.com; s=arc-20160816; b=hC+QwmovRAJ8IKCGXqXC9sysFYMjeKQy7u/VqlB0GV0fU/gC9tpMa19/p+wZLQwcAZ RZ0WA5ZtmP14uOoykU+cRActojOYQu+hRyjgvIKVwYNld+TiCh+zjsACq9jWYWJMWFfV XbtzWMSDM3pqFwQle5Lyu62T09PP3ilen8TaYTT4TQr8XopmEceYPuwk2wqdaMKXPAIa qb4Y5B4OAyNVJF4LpoPU8jyQGKt7AnSBQ5MX2b3NoTBeJ3wN6axDO4NitS6JOSlp7GkG n8TeCTOrOaXhyytsAYEH0sBi617oTkY/8uaarOGaoYtkEz/1rlXG6wSA1XUrdDNrezMo plow== 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=KxWO7xZCpZy/QjDSfmiWAP83Yc5YWXIyhWWtxZPMVEw=; b=CLPcT5SHVyrztr7lRLuBt0KkqdlLUo3N+SFfgd/B9gvggoCN+2a8tQNMmlkU7/7PVu jRDhLqPUd876oHNb3gQXTJmCDhXXd1a1BOt40GtlE6Vr7jYZ5loc67n2of+mRU4Mtsj8 X+kLj0S6MxV6RkshD10bNNrv0TKu0cOfaxRPZJjH8MVcMwj3zcctUVYQwX36ksYIx85Y 4WJIJXhDxnWOaKTq//y72HTLwWassjOiASefL02SeIPL84PtFhpGSvHJD0EuE0bzP1n8 vSNkOiT4n2DBOb+Q/JhB1SQBIs1PRN9yr8wC+F6+PoLypFm876YMbNH59++E6G6Og2wA E6Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hN008miU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jz24-20020a17090775f800b008d518d4bf7dsi27917875ejc.562.2023.03.28.03.06.56; Tue, 28 Mar 2023 03:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hN008miU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229684AbjC1KEq (ORCPT + 99 others); Tue, 28 Mar 2023 06:04:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232922AbjC1KEY (ORCPT ); Tue, 28 Mar 2023 06:04:24 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 420D56A7D for ; Tue, 28 Mar 2023 03:04:10 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id o11so11165829ple.1 for ; Tue, 28 Mar 2023 03:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679997850; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KxWO7xZCpZy/QjDSfmiWAP83Yc5YWXIyhWWtxZPMVEw=; b=hN008miUyq4MP/sgibqJJlMmfh8gH3r8syzVXMiCVNpJu7bFv+86OoVc8hvtcrJq9l TgURfR0jeZOVO3+o0wxzcpEQN+V9QOtwDglhz8jZWBw+o+TmXtKp+JGTru3i1fPcajoJ xbGkAnHZiK57fucBmJwx1BMnwvU/cW2JC/SaqYeaMj6ixkpSa/MFlrcIfQ+rlptOxt33 CNQOyU5QyW0NWD/JtFg2wERWJVCKnTg8JGBAWilW+mHgaloVS9mPVnEosdtlrEQjOmQS ++BxlWRuy85Ulv4UPEvKXvL0Rk6K9N8bJgdFo1CJPCSX/rUAlgBs0/OzDDaVhL3H9/Z7 16eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679997850; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KxWO7xZCpZy/QjDSfmiWAP83Yc5YWXIyhWWtxZPMVEw=; b=cEBXrARfGF4BaR02fA5Fsegul9qCBM4arWhOwKr0XBSy84uRPGK5ysYqVD/C+PnI0d SeN9lhrHLlWqe/3yswDRYH1dkvU3/XFKHIbHJGH56zs2QkbLB3d9Oj2jqTzUX+AJWcsT ZtAOgbHngydM8xiS2L7pW0VSNHShRbp7ePu804bPgPxfTDu/5t2fQhW+TVFghYoeQryp HAVPm/7ICA5kHCW2dMo+jglS+hQUDsP+SNS6W0rUUmsXmxTx1PhLZX0kl79lTTOclfWa mNQrxrhBx/KYZAn0tUuGGnGLpvEQ++ta4i6taH6WVl1g2Gc0PAa58zpwd2ZHMWHHCk2B gF6w== X-Gm-Message-State: AAQBX9eRVXVMQqOVBhSEzFpS1zMpmf+HQ1E9Ss02AAulgKMiZvZDqjsX /7opL4eBZO2NpPwL94GK1X4dwhaQdmiZxWMEejtTZg== X-Received: by 2002:a17:902:9b88:b0:1a1:c523:a9bd with SMTP id y8-20020a1709029b8800b001a1c523a9bdmr5428987plp.0.1679997849712; Tue, 28 Mar 2023 03:04:09 -0700 (PDT) MIME-Version: 1.0 References: <20230207051105.11575-1-ricardo.neri-calderon@linux.intel.com> <20230207051105.11575-11-ricardo.neri-calderon@linux.intel.com> In-Reply-To: <20230207051105.11575-11-ricardo.neri-calderon@linux.intel.com> From: Vincent Guittot Date: Tue, 28 Mar 2023 12:03:58 +0200 Message-ID: Subject: Re: [PATCH v3 10/24] sched/fair: Use IPCC scores to select a busiest runqueue To: Ricardo Neri Cc: "Peter Zijlstra (Intel)" , Juri Lelli , Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , Lukasz Luba , Ionela Voinescu , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, "Tim C . Chen" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Feb 2023 at 06:01, Ricardo Neri wrote: > > For two runqueues of equal priority and equal number of running of tasks, > select the one whose current task would have the highest IPC class score > if placed on the destination CPU. You failed to explain why it make sense to compare current task score whereas we will most probably not pull this task at the end > > For now, use IPCC scores only for scheduling domains with the > SD_ASYM_PACKING flag. > > Cc: Ben Segall > Cc: Daniel Bristot de Oliveira > Cc: Dietmar Eggemann > Cc: Ionela Voinescu > Cc: Joel Fernandes (Google) > Cc: Len Brown > Cc: Lukasz Luba > Cc: Mel Gorman > Cc: Rafael J. Wysocki > Cc: Srinivas Pandruvada > Cc: Steven Rostedt > Cc: Tim C. Chen > Cc: Valentin Schneider > Cc: x86@kernel.org > Cc: linux-pm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Ricardo Neri > --- > Changes since v2: > * Only use IPCC scores to break ties if the sched domain uses > asym_packing. (Ionela) > * Handle errors of arch_get_ipcc_score(). (Ionela) > > Changes since v1: > * Fixed a bug when selecting a busiest runqueue: when comparing two > runqueues with equal nr_running, we must compute the IPCC score delta > of both. > * Renamed local variables to improve the layout of the code block. > (PeterZ) > * Used the new interface names. > --- > kernel/sched/fair.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 72d88270b320..d3c22dc145f7 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9399,6 +9399,37 @@ static bool sched_asym_ipcc_pick(struct sched_group *a, > return sched_asym_ipcc_prefer(a_stats, b_stats); > } > > +/** > + * ipcc_score_delta - Get the IPCC score delta wrt the load balance's dst_cpu > + * @p: A task > + * @env: Load balancing environment > + * > + * Returns: The IPCC score delta that @p would get if placed in the destination > + * CPU of @env. LONG_MIN to indicate that the delta should not be used. > + */ > +static long ipcc_score_delta(struct task_struct *p, struct lb_env *env) > +{ > + unsigned long score_src, score_dst; > + unsigned short ipcc = p->ipcc; > + > + if (!sched_ipcc_enabled()) > + return LONG_MIN; > + > + /* Only asym_packing uses IPCC scores at the moment. */ > + if (!(env->sd->flags & SD_ASYM_PACKING)) > + return LONG_MIN; > + > + score_dst = arch_get_ipcc_score(ipcc, env->dst_cpu); > + if (IS_ERR_VALUE(score_dst)) > + return LONG_MIN; > + > + score_src = arch_get_ipcc_score(ipcc, task_cpu(p)); > + if (IS_ERR_VALUE(score_src)) > + return LONG_MIN; > + > + return score_dst - score_src; > +} > + > #else /* CONFIG_IPC_CLASSES */ > static void update_sg_lb_ipcc_stats(int dst_cpu, struct sg_lb_stats *sgs, > struct rq *rq) > @@ -9429,6 +9460,11 @@ static bool sched_asym_ipcc_pick(struct sched_group *a, > return false; > } > > +static long ipcc_score_delta(struct task_struct *p, struct lb_env *env) > +{ > + return LONG_MIN; > +} > + > #endif /* CONFIG_IPC_CLASSES */ > > /** > @@ -10589,6 +10625,7 @@ static struct rq *find_busiest_queue(struct lb_env *env, > { > struct rq *busiest = NULL, *rq; > unsigned long busiest_util = 0, busiest_load = 0, busiest_capacity = 1; > + long busiest_ipcc_delta = LONG_MIN; > unsigned int busiest_nr = 0; > int i; > > @@ -10705,8 +10742,35 @@ static struct rq *find_busiest_queue(struct lb_env *env, > > case migrate_task: > if (busiest_nr < nr_running) { > + struct task_struct *curr; > + > busiest_nr = nr_running; > busiest = rq; > + > + /* > + * Remember the IPCC score delta of busiest::curr. > + * We may need it to break a tie with other queues > + * with equal nr_running. > + */ > + curr = rcu_dereference(busiest->curr); > + busiest_ipcc_delta = ipcc_score_delta(curr, env); Hmm, i don't like this at all Also, curr is the least probable task to be pulled which means that all this his useless > + /* > + * If rq and busiest have the same number of running > + * tasks and IPC classes are supported, pick rq if doing > + * so would give rq::curr a bigger IPC boost on dst_cpu. > + */ > + } else if (busiest_nr == nr_running) { > + struct task_struct *curr; > + long delta; > + > + curr = rcu_dereference(rq->curr); > + delta = ipcc_score_delta(curr, env); > + > + if (busiest_ipcc_delta < delta) { > + busiest_ipcc_delta = delta; > + busiest_nr = nr_running; > + busiest = rq; > + } > } > break; > > -- > 2.25.1 >