From nobody Sat Feb 7 19:08:09 2026 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 D1F8677F0D for ; Tue, 6 Feb 2024 04:39:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194370; cv=none; b=MMTGePwhn8qYmTpChAY241ttXOKMd+c9gHoSdkl3/6OSNEoJfrryipvi6XBgKQPSRpi1PopB9pJfZ02otWJA7X965TrkS4rApT0nWKmOY+b5yo1QERleKsxyeh803svAyuMUamZ05DRMkvmQh8C/hyhG8rbaVfXiOkmYeAymtdE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194370; c=relaxed/simple; bh=6mkJTp+YntfTBR22eAXEk5YJrTS3d/+TlyZSgog8VHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u+CjIog98GyG+OJAjQZxzFEe3FpaAfc2dfoQSbXm/1pZAM+cVNlQ15fYw6NQCUvZdQpk+625NI1orArIrzlWbvViO44iK5WobT45VF6/kPlIkVMhRLt/PpplZMbxdF6AtQl8HqQP3wj6KSHGz43ED7QCwCfOprDSAPy5jQSyYmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-42a31b90edcso28518721cf.0 for ; Mon, 05 Feb 2024 20:39:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707194367; x=1707799167; 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:message-id:reply-to; bh=fwyA0iOp0hGdi4UEoMdS/esY5ki+GqxLPXq+pqSYOeM=; b=eEeDYCzlFvfGcDcmZ/d2lmQuC1im7AiGHSTo+6zrGu4f8Z2HtiKRB8LfAckeafmavM U0siuZRXIOvM9/JZlUii0/8MvLbcWygwxEDhiU4l1pSmQQ0pySZqmfU9PdhaHUg+ByfZ C0UyKyLq5wAeEalSixkeu19yQhR7v8S6qtvtkWj9aOF6tD1WpWmZ442EXx7qCkGxgzs6 P34EU51h0FVEMJtRJcyCWmiW97TsbuNZ08C2ZrxUvat/6t4/JpALMGRt0OvtR+LzRd0G yZkQW0fZng2/9tmf7f9IhrbToTlnU9tYxGboqyly2fd3Xo5DYGLcwVjcnUjqXP2+flaH boyQ== X-Gm-Message-State: AOJu0Yw0zjKcSsTOEQu2f4dQJVRv7FD8ttmmfKAjD311m5aK/Gy/Z1sv j+RaH8/rPzU4KS9qj+5hyDD2Mcktw+Fe3XtJYIYgMfDYPgkWdCeYFWky3Ie5Fn2OGQ== X-Google-Smtp-Source: AGHT+IEugQDWzGlvkhd0W4cPjrhbDiarfz4oqwttbCzqSNwJqE+K/y9Pnqyj63gWLpW+jmwH7hVDng== X-Received: by 2002:a05:622a:1a92:b0:42a:a6ed:5440 with SMTP id s18-20020a05622a1a9200b0042aa6ed5440mr1915358qtc.3.1707194367154; Mon, 05 Feb 2024 20:39:27 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUQYkQrg1jQLkKhWe1/10W7B7YSHqfVYXEEYIvRxdpvHy25dCnd14XITuhu+gFuHGAxIsgcC6ZVdscA9v7wNU3xIQ00UQYpkUvi54s4VwYrEohSnnn9HyR0pHp5lVh396m/7yALTspVKEMFVbZewwGSUhhe22ATxjHzOvBbCWhBtVUN3ZeLJ4fL/PCc1H2lwdqg50cWOZHte/fggiX/1IDcGX1dEBYY9ARdKUmCWrKj3pBnOPqH7UaSz4vp5+lBY3MivKqKJ5Ox0eMJPddv3yzfROqvZoV2WfvyO9YTwLsSqbuILXI= Received: from localhost (c-24-1-27-177.hsd1.il.comcast.net. [24.1.27.177]) by smtp.gmail.com with ESMTPSA id j25-20020ac874d9000000b0042994b3c20dsm570517qtr.29.2024.02.05.20.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 20:39:26 -0800 (PST) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, kernel-team@meta.com Subject: [PATCH v3 1/3] sched/fair: Remove unnecessary goto in update_sd_lb_stats() Date: Mon, 5 Feb 2024 22:39:19 -0600 Message-ID: <20240206043921.850302-2-void@manifault.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206043921.850302-1-void@manifault.com> References: <20240206043921.850302-1-void@manifault.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In update_sd_lb_stats(), when we're iterating over the sched groups that comprise a sched domain, we're skipping the call to update_sd_pick_busiest() for the sched group that contains the local / destination CPU. We use a goto to skip the call, but we could just as easily check !local_group, as there's no other logic that we need to skip with the goto. Let's remove the goto, and check for !local_group in the if statement instead. Reviewed-by: Vincent Guittot Reviewed-by: Valentin Schneider Signed-off-by: David Vernet --- kernel/sched/fair.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b803030c3a03..e7519ea434b1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10578,16 +10578,11 @@ static inline void update_sd_lb_stats(struct lb_e= nv *env, struct sd_lb_stats *sd =20 update_sg_lb_stats(env, sds, sg, sgs, &sg_status); =20 - if (local_group) - goto next_group; - - - if (update_sd_pick_busiest(env, sds, sg, sgs)) { + if (!local_group && update_sd_pick_busiest(env, sds, sg, sgs)) { sds->busiest =3D sg; sds->busiest_stat =3D *sgs; } =20 -next_group: /* Now, start updating sd_lb_stats */ sds->total_load +=3D sgs->group_load; sds->total_capacity +=3D sgs->group_capacity; --=20 2.43.0 From nobody Sat Feb 7 19:08:09 2026 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 F1A8978B5B for ; Tue, 6 Feb 2024 04:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194371; cv=none; b=JeqMDT9e8G0/zIVVE5cDJrM6Lsf/V5HKsrpbkMyJq/5UHsSx4z4zT0kVeW5f5GiRMenWKIUnmR5UtGXY2F1bj7nsgDce7xLvAu0Mmg/JaDKYeUuMZPXKL7+4rIc/M4BYW+uSIB2jdKxsnOyo6bFGUp3apa2rzREwS8JogVsqluE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194371; c=relaxed/simple; bh=/yBd5sGe3byMVW8sDxeCS54/0Z37uF3CUIi/XstrLJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KNFeIEaFF1CGbCmfB+gkcLphhDk7UcYNlrLgKARIG6aNySiIs22VOaZ5o2KZLXpeSrTS+keFPXhzvOEfBx0VrMW8/0XJgnoB336yDS3xzWipxijiHPeiXBRgv7ji7h2HDK2t0XYZs4u1YVrKharmRw87dsuFefyaWIx0ALEdscA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-783d4b3a026so306313485a.1 for ; Mon, 05 Feb 2024 20:39:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707194368; x=1707799168; 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:message-id:reply-to; bh=TIX6iuoRN440ik6kRv9x9Dd8FfCsaf7euCk0kuQlv08=; b=JjMw7DZ/Zem8tGI1B287dMck9mLtWnBuqznI6w94CdMI5bm2Ve6GsP+ODJYCWRm40h m7UrxRWdc2BRR+dsH2Zxo+s09SJQzZ11zJxS0gPDGWG+ear9koUg2kuqrlI6vNpAwjS0 5Cd7JEts4H1ihCkTVsuGP0PvbQA8iIJPS2GnuIdhhNQsKHbacicCcxgSexlaLMWij0YB miJfbSD3djqTAQrkDj8Xb9rdMaqp6A/fcFfoHI6xSfid7iX+IyXuXuLxdFemr2a4MHjr wdjDXw1wZ0ID+xJjXCXSsmFQ9EdZpfp/nKFo5bcpYxd/6L0bmVlGCCSKanAa2tk2dinb wGhA== X-Gm-Message-State: AOJu0YzZ/kpp17aHjTWPsXF/l6qzTYa9gWm0r8eBTWiWx3FdmCm+M+k6 61FnaiLND3H7Z2csctWg3yJWD6qwnMo5iXRA27X/n1LDScNttdgU6uaE2GOZciqqZQ== X-Google-Smtp-Source: AGHT+IFse+cZLfWPvFEZN2GE4pbUvSAvzWnxUjKViyUDSmHNJaFAS53IslLuT+dTJgeQ/Eyq+tEn+Q== X-Received: by 2002:a05:620a:b8d:b0:77f:8a87:ebfd with SMTP id k13-20020a05620a0b8d00b0077f8a87ebfdmr1060218qkh.41.1707194368565; Mon, 05 Feb 2024 20:39:28 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUgawVg/8epGHYSQn5u9fEP0+FbcAkJEsMGMiA1exxndl2m3HCeu+0Oih2o/j9ee/jC741kzplIXOUSpbHhojMejoJN/wdRAPsrBnE0BhRMWwY9WAIbpg/mcuunBJezmBwiiiIdegzHULCnUpVuyDgqD1o3Vya+cd+Pj9EtXhQCTZEtil3/aMUha7uZ+NNpRbUhvB7aMfgpGP5Cjb/0gtNagl7pT1yLl0LrxYNs7V+F+TpQubS0KO91RDnCRHG0z6uoj6v56agPFuwkLBT2CoOJ9I6/rhHagU/k/oRTAXQ4fMM/q04= Received: from localhost (c-24-1-27-177.hsd1.il.comcast.net. [24.1.27.177]) by smtp.gmail.com with ESMTPSA id f6-20020a05620a15a600b00783749b0d2fsm577757qkk.94.2024.02.05.20.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 20:39:28 -0800 (PST) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, kernel-team@meta.com Subject: [PATCH v3 2/3] sched/fair: Do strict inequality check for busiest misfit task group Date: Mon, 5 Feb 2024 22:39:20 -0600 Message-ID: <20240206043921.850302-3-void@manifault.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206043921.850302-1-void@manifault.com> References: <20240206043921.850302-1-void@manifault.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In update_sd_pick_busiest(), when comparing two sched groups that are both of type group_misfit_task, we currently consider the new group as busier than the current busiest group even if the new group has the same misfit task load as the current busiest group. We can avoid some unnecessary writes if we instead only consider the newest group to be the busiest if it has a higher load than the current busiest. This matches the behavior of other group types where we compare load, such as two groups that are both overloaded. Let's update the group_misfit_task type comparison to also only update the busiest group in the event of strict inequality. Reviewed-by: Vincent Guittot Signed-off-by: David Vernet Reviewed-by: Valentin Schneider --- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e7519ea434b1..76d03106040d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10028,7 +10028,7 @@ static bool update_sd_pick_busiest(struct lb_env *e= nv, * If we have more than one misfit sg go with the biggest * misfit. */ - if (sgs->group_misfit_task_load < busiest->group_misfit_task_load) + if (sgs->group_misfit_task_load <=3D busiest->group_misfit_task_load) return false; break; =20 --=20 2.43.0 From nobody Sat Feb 7 19:08:09 2026 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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 E66E57C088 for ; Tue, 6 Feb 2024 04:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194373; cv=none; b=mkEjixLMhAbcVFtGPQ2bsia9spPaDbSDSPrt/Qt4VSHp7m2CFHJySM1ArHtFwvsfMJ0VmtrY8UmKLNmQOK42swHM4Kus4T6sdq58aoesZ1wMsLH1N/P1efltEZZ4ctS6zA/0HtbVa/qB9ldEqgkgFOOHtKdd2hpmR3mv86eZWfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707194373; c=relaxed/simple; bh=D0GWn07QSrQNKcLM0EZX6f62nVaGa9qePJ8JuBS0Phc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C2Xs6zTeFs2mCEuo6OfDCt3S2WH/yaDM5eEA6qzVrJlcdQvBCUkHglXS0nijE4jNvz6gLGrN6u7qHyE0LUB/ho12LJRxkChPqUJ2fkViG4/2Sux8FmKJO1Ub2jJ69KJG0RgMu1CRyXcVbPICfDBu2pkegCkDeV+luz//54wEcl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=manifault.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-68c794970d5so1499356d6.0 for ; Mon, 05 Feb 2024 20:39:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707194370; x=1707799170; 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:message-id:reply-to; bh=OweXHWUMGZlBLk7CQUqL8P+eAADd+iVa1P4u5q9wuCA=; b=s+34o9Lo7gaR+7862p3T4u3BguXCwUF/04Wk6Mhou61MyoBvbRRIlx9LuE51diomvv xwxIUyAFKXrwnNdEGcYz2QD7dJKaEoCQYzm6l7ahPIKWL/85D2xH+b9yCiQs8AsDDJLC TntNnbghvPpJIvwPx9yVxJQgd2e6qFSZN9xVKZeddPxa5h4mQElnl+So35l3uBABeLgs d+PPSZ81n8YzVwzU0pb9GONr7u9GcpheJAjVXdcsH33v0w2T7v7a+W2HG+QWL/SsELNp FHmDHNJQc/lv5ZIZ7gd5MXdLIW5r6cM/9iAMRrXq6L8ScDoPLfmK2sBiaAlZBVQRPQ0e eiHg== X-Gm-Message-State: AOJu0YzL/Yu9B+xSyWCZXdpw7VPov+65f/novCyigkSw7BWr12QR4PGY GGjCIalb5shxikLsN/q+aC+7LW/zGaVwYnO833SmkZwRge3QhzQF9YEMegqJbs9cLA== X-Google-Smtp-Source: AGHT+IF3mi+rmRAok/VSPYBZN3kyqm7aNnS3Pl97TIRUsLUB1I/FBvbY+HSN98zr17n4c5YaPBHZuw== X-Received: by 2002:a05:6214:1d28:b0:68c:8218:30a2 with SMTP id f8-20020a0562141d2800b0068c821830a2mr19466751qvd.0.1707194370393; Mon, 05 Feb 2024 20:39:30 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXB1wpEtOw8AUVfamqVIhtmaNPh6FPGwA2PmblCOucWpKiQRbP+BXxOBdLCHMdyOborem7tLZ57EHPgpRd+APgTYiK1ZS1vyrAusIYSyQIZO4ZFr7lKnovzUyv3r5MQJDSZ5YwZLPGUwKY7i2UQpN16Ki3eYT007ocCN2IXFCJlAxG51hf0RP03NoCPJrHEXBH5r3jSPe1++5ExseB+V141RZ5cYAbc4UZGhVXoMv3CguHKD1XX1FZhUT73xjaMByYlcYzGaoX+rcAkdyyzfIDkLzv1WGRqRiMUPzCi3vbIl74lkVc= Received: from localhost (c-24-1-27-177.hsd1.il.comcast.net. [24.1.27.177]) by smtp.gmail.com with ESMTPSA id f7-20020ad45587000000b0068c81299a2bsm671836qvx.15.2024.02.05.20.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 20:39:29 -0800 (PST) From: David Vernet To: linux-kernel@vger.kernel.org Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, kernel-team@meta.com Subject: [PATCH v3 3/3] sched/fair: Simplify some logic in update_sd_pick_busiest() Date: Mon, 5 Feb 2024 22:39:21 -0600 Message-ID: <20240206043921.850302-4-void@manifault.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206043921.850302-1-void@manifault.com> References: <20240206043921.850302-1-void@manifault.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 >=3D 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. 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 *e= nv, switch (sgs->group_type) { case group_overloaded: /* Select the overloaded group with highest avg_load. */ - if (sgs->avg_load <=3D busiest->avg_load) - return false; - break; + return sgs->avg_load > busiest->avg_load; =20 case group_imbalanced: /* @@ -10019,18 +10017,14 @@ static bool update_sd_pick_busiest(struct lb_env = *env, =20 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); =20 case group_misfit_task: /* * If we have more than one misfit sg go with the biggest * misfit. */ - if (sgs->group_misfit_task_load <=3D busiest->group_misfit_task_load) - return false; - break; + return sgs->group_misfit_task_load > busiest->group_misfit_task_load; =20 case group_smt_balance: /* --=20 2.43.0