Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1839125rdb; Sun, 4 Feb 2024 03:48:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS2ZAsNvqNQm3lCGpo5NtL42OtK69b724oTpbQzwAgp4jEalHnKtdDLzNJMzd1YSG9Gayv X-Received: by 2002:a17:902:dac4:b0:1d7:4df:1998 with SMTP id q4-20020a170902dac400b001d704df1998mr9896079plx.53.1707047312427; Sun, 04 Feb 2024 03:48:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707047312; cv=pass; d=google.com; s=arc-20160816; b=LFQqOhQoaLr8YjRUn8BLYD2mDHQPXi4XneeHK53Lzw+1XETzuLDtNGMv1oEdPLvsws CV4PWRAr0jNhWu5htkiJREgiYdOK+Lr6T/2eHStZpNZ2uCmD69IdInhOKT6hkaUrgFpw WQYjNY9ZRXczUjHb9nuG3BY6fBdfKiUJKMW9B06sCv6yXU9ZSTXpUkTmLGe03fAHLlfB 3IH5QfstvmHZD3W8IVux8dFMG+3Ow20c0BqGs7Vhr5tpxOfSEAfaFKcRQWwho/RMknP/ chMEmxfXd5rvJy/QUMyHwyO9s4CFI3ML+AiEpyLBJp+FOBYQlxwCjF3Jc12PpoSEO650 W+wA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=iLWoLtoNTPqCxrIM8mN16L13n1zpFY2d5lyre0SQZo0=; fh=FQR+gw8BWbfuKF6Tn9bSxJbYrGmEro/mT2k101sQEJE=; b=uHoBkxt+g3rLV86f9DmKn3CMWDPpd+C/3MRGc2OpxAk5mCkJZ7VwmfcBUsd6aaoJaC 0ANcInx+cAjSiNWhGmG6VXTYt8nwygyFP9tUgrvd2SvuHklIFQ2P0lXqUO0f/tQSEGKq PyPJjQlkckhiqUyoeujENDTq0MRZacTtRjoF8kZ5pWhZGamksNUjnE96/63p5e5uqjIS QbgHKlp6Kk34i3WajX3dTSteVHrKX4W3WSBsMN5DjFPlPLQdl6GdJgVMRfC2I4uhtv44 Y6/3DNqaALTujyCKHncgNsXby20r3cscy23bYrgEXUS3Bihqw1uZ5Y7abyky0erdHfBo pIUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwpBX1bv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-51613-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51613-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCWnjp1xLsMgo8pJi+imKQFvxiZ8yrF9KMQphEqHE8cB6aI4Ckme4nP9NVhI2YRW2zkHLHPeDE4hy1Rc7ppVQ/+HHu/hx3AJkmiJofg7Uw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h6-20020a17090ac38600b00292a409e5b3si2849439pjt.55.2024.02.04.03.48.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 03:48:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51613-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jwpBX1bv; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-51613-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51613-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 19B9728266C for ; Sun, 4 Feb 2024 11:48:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C87812209F; Sun, 4 Feb 2024 11:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jwpBX1bv" Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D47221A0A for ; Sun, 4 Feb 2024 11:48:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707047304; cv=none; b=FpE27zXIqNxijTQe5TWJFPu3Am8f0EZ84tFSBJfc3gsaLx5dxS2ZMRfcGRuFRh94brI/jde/ZeolL7TTCyq/gI4/5CjhH7CAqMV/qjnnJlfVmBS8KNuAXZ05Pu1p/7ryHyhdhxbPteudLOsWXip/zSPGk7M6GzXGZ30GP0iCoNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707047304; c=relaxed/simple; bh=1DuL6dXCrknE23VcOSIz+lgVGVDMztlVCyPAUOOnS+g=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=cH960flYyHuUPOrCyoohkPIdB+I7pmqbRj1AJjcGmF5DyMPCdFHyj3W0qIAgrmkeFqYGw4kzQmMROQTAU7A2cxBVFJalRDYQinZoTZeeL/Sntfqx+2jnGydK5XDrOA7OvEP9mL9q4MwYGd861vJ16eA6Wc2oGlZQ7+7c02KXSWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jwpBX1bv; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-290d59df3f0so2871957a91.2 for ; Sun, 04 Feb 2024 03:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707047302; x=1707652102; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iLWoLtoNTPqCxrIM8mN16L13n1zpFY2d5lyre0SQZo0=; b=jwpBX1bvu2O+77BorHqyXEp8JoFLYo1Z7+zWf5hhwmuoRQ+j03TEzK8iyyaJTuTQzS XEMLvekwTdtpX/fjnxkYI/OQk98KyYmzRfXiO60FmFb34HlNwCQb14A30fLRAVMlpG8Z uWK5Gp5dexEDMO8u7V0/Jv88KjgDuFY/ee37X5iBCn90pyfXh9Kc/uN0iZuUVQtjL8UX PYknD2smuB0kEyaTty2PhUgEeyj0Mrlhevw3RgW+meDMmzOgoHCLN+GDm37MuCAJ+KEK TsZciUWd+frZb1zhvER2DpqUo3QH0mls2ELLauY+AKms8PjAQVUcsyu5VG3gfLjqZQyJ NyCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707047302; x=1707652102; 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=iLWoLtoNTPqCxrIM8mN16L13n1zpFY2d5lyre0SQZo0=; b=tbR/vcJLumB0csfpwO2hLyNqrnnaz9huPgmhCzi5mz676lsBKgbB5gBM/eehfbvzgB YAwIvl9PRHFK+bLtcos4Ngtbqwk/7Xse+j4kNXuz2CQyE8e45fw+KMntM07pwozICUAL BMGwozmXoQsdEVNUSPJm12xhM/Gj/vO0zbk/ZngRgeS1npkIGA5bUxyQk5VXd7P43pIF iN/Df6ImMQcJ/izWZmPV64YBjzs0IT5N1R3Pc+QohLU04rwOiAT1S+MA8Z1S2NCiJy5D DWxhfnlvJgIc7ePutrkkTDMCm0QrjrTpGYt+lDD7o7mVytZNJlF7tHM4EL4hPcW4SxGA IXjA== X-Gm-Message-State: AOJu0YwGekPz5Xuq7z8VuwY1cfXEeYYU7d+eME1xtEc9hMUw8WgvK/j+ szG4RILThtnXr6eBnCCHckWaQ50Ni/+oSBvyhJIKS0YQv/gd5JnIRD1yjZ3Yq/4GcZpdRx1jHM5 RHrj11O756wzm7SkLd9jsTm66+WJdfZyb8ylKcQ== X-Received: by 2002:a17:90b:387:b0:296:24cf:bae6 with SMTP id ga7-20020a17090b038700b0029624cfbae6mr6785135pjb.27.1707047302628; Sun, 04 Feb 2024 03:48:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240204044618.46100-1-void@manifault.com> <20240204044618.46100-4-void@manifault.com> In-Reply-To: <20240204044618.46100-4-void@manifault.com> From: Vincent Guittot Date: Sun, 4 Feb 2024 12:48:11 +0100 Message-ID: Subject: Re: [PATCH v2 3/3] sched/fair: Simplify some logic in update_sd_pick_busiest() To: David Vernet Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, kernel-team@meta.com Content-Type: text/plain; charset="UTF-8" On Sun, 4 Feb 2024 at 05:46, David Vernet wrote: > > When comparing the current struct sched_group with the yet-busiest > domain in update_sd_pick_busiest(), if the two groups have the same > group type, we're currently doing a bit of unnecessary work for any > group >= group_misfit_task. We're comparing the two groups, and then > returning only if false (the group in question is not the busiest). > Othewise, we break, do an extra unnecessary conditional check that's > vacuously false for any group type > group_fully_busy, and then always > return true. > > Let's just return directly in the switch statement instead. This doesn't > change the size of vmlinux with llvm 17 (not surprising given that all > of this is inlined in load_balance()), but it does shrink load_balance() > by 88 bytes on x86. Given that it also improves readability, this seems > worth doing. > > As a bonus, remove an unnecessary goto in update_sd_lb_stats(). The line above is not relevant to the content of the patch. Other than that Reviewed-by: Vincent Guittot > > Reviewed-by: Valentin Schneider > Signed-off-by: David Vernet > --- > kernel/sched/fair.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 76d03106040d..fa049f866461 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -10006,9 +10006,7 @@ static bool update_sd_pick_busiest(struct lb_env *env, > switch (sgs->group_type) { > case group_overloaded: > /* Select the overloaded group with highest avg_load. */ > - if (sgs->avg_load <= busiest->avg_load) > - return false; > - break; > + return sgs->avg_load > busiest->avg_load; > > case group_imbalanced: > /* > @@ -10019,18 +10017,14 @@ static bool update_sd_pick_busiest(struct lb_env *env, > > case group_asym_packing: > /* Prefer to move from lowest priority CPU's work */ > - if (sched_asym_prefer(sg->asym_prefer_cpu, sds->busiest->asym_prefer_cpu)) > - return false; > - break; > + return sched_asym_prefer(sds->busiest->asym_prefer_cpu, sg->asym_prefer_cpu); > > case group_misfit_task: > /* > * If we have more than one misfit sg go with the biggest > * misfit. > */ > - if (sgs->group_misfit_task_load <= busiest->group_misfit_task_load) > - return false; > - break; > + return sgs->group_misfit_task_load > busiest->group_misfit_task_load; > > case group_smt_balance: > /* > -- > 2.43.0 >