Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp784823lqo; Fri, 17 May 2024 01:06:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAM99TruNSMy+4IClPSWEMtEm1NJXdUlj1mHDH2g8LDLVsw3qfMYFNlI1o0wELM+tdZ4OABS5sm7Yl++KYjU4d1cvqT/ymE3F32sOkGw== X-Google-Smtp-Source: AGHT+IFIOKE7z/aVb96Aj5Fm+QNyg+caZ/KTBcNvsWYYJpqxAPsIAKyGZKskMpU/E+3jeA7Sfgk1 X-Received: by 2002:a17:906:78b:b0:a59:ba2b:590e with SMTP id a640c23a62f3a-a5a2d65f27dmr1309733866b.48.1715933190002; Fri, 17 May 2024 01:06:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715933189; cv=pass; d=google.com; s=arc-20160816; b=MBTXDG1gyNHM460G4KWDDXFeDKI9PYqxcJvDiI6pFE4Frnu4GB4CTRk3jvuYJpc+y4 bo6PNnVfHB3TmUvWg46VTIMTg6WRma0t/CAktH5w7FClYWVSNfJwDD1E+GeerYJeExh1 Fp2zzi1K1JwHkFhpibtjkpC0Vfq1JCtZi8r1HcrgwrMgt05WVCLNfMGSyOgMgnb3hvzE HQOChV6yU9DRN8AheqFAIUTh2YUMBdCJ03Kq02ZXwh6N/HB2emm5f21RpDS9uK245g53 MkwNtiCNWkBgqV0bSkBNTpNqCxhzbhE4OdIqbxGqyDvPuUsNcIUrcXx7mXUD+crAXftV /LGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=RvspPlO30Dpgs5BRdySP249xAR6/Pg+jqZL6QxyeFOU=; fh=GoIWmwH/5G9/fMjmplMUomiw0tjjRJ1LOC5a269mYBo=; b=1HrExmlqccLIy1tiZHebJkE5mk7JTQuAJ7X++DY70CtiiCTIQs+yeFaFXkmChWhT8/ 1DQa4+8kTbeK+CUG2kQpUlzafVgz95Sc+t9ZwhhYfSCeDqvXYYDRw9htrIl/x1zgvBho t7pKvjRaChwH42jPkiuzvkXPvKIylYUak8ckprGApSg2QaYcqF1x/d6mstr2AuAqxAQc waFjKvUxmZpJKCWF+xUv9tR9xxihx4oM/VF4CY21beZ1g5P+EfXkIZ+OCJCXjNA5ygUj 1/eNfGr2IitVA3bLyaALijgL5LeFa2CVGFS8ZvLF5ylmLOuYi2Qd9XK8r1NQ0C+SGVrV iwhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WJamJ9ML; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-181852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17b21c30si1057530766b.433.2024.05.17.01.06.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 01:06:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WJamJ9ML; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-181852-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B7DFE1F22BB9 for ; Fri, 17 May 2024 08:06:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 013222561F; Fri, 17 May 2024 08:06:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WJamJ9ML"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="b0D/g/+c" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6A591A269; Fri, 17 May 2024 08:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715933174; cv=none; b=Ksb37vreEHUefxQ1AIidmQWZenMkcVQufMBVRmLHHaw4FArt/f8KyW9VmuMBsCIClsDysvxEUn0ctY4J0AgGaiQk24K8oOMV66xVzevc2wBEX8/nupwUoAxzH9fCfJ+qYBeCFeCHEZqYdyGFQvH/PWKsoIUWZNJtK3RFQqf32QA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715933174; c=relaxed/simple; bh=QMr/SPTgmh1haotnJyA6+vALv91yT0q8VT2NouVZ4dk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=OeaGRR9+jwW2rxxJo3E54fUqCT5T9z3179aa9gjWoKI+WYeXcBF2q5N4wgqu0H66e8BWFx9nUVwkfUPo82N4HSOT8uBXg/3i3lb4KYhe5do3Ct9YXDaZpSf9rOgyPY6euCQGHDIyRCVylrmrVWFgUwKOtA8QXo2Qr8zJpdjDTYA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WJamJ9ML; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=b0D/g/+c; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Fri, 17 May 2024 08:06:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1715933170; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RvspPlO30Dpgs5BRdySP249xAR6/Pg+jqZL6QxyeFOU=; b=WJamJ9MLvwL+L3+0hcVWtg/Z32m7m4t5Cgl5XrSPuSumvPPsgENHhLEm2wUSMGOfuT7UPi fJ78LarQpBzb+wmekXTQckwW5q2k4fS60URjSxCxBDur77w5/YMHL/hQKfo8j3g9uC2pNX tz5SFm5xQRFVvlYQxIOK8v+263TmPeyqHAaSjS90wCx2Y1uNkSsd861ZBxGS2Wp/gJdIk5 F8VFnLvDRETCM3nVPbqTAxtGJzhF1ICe4KE7jHgJFeC5D81vSoiyf4lUn8xw1dOK6Kj5Za Kjn6JhXvgSieezsrWDsKnNtMWGRy7V7tXhlNGav+Yan+Td2CLIC3Fnod3dHsFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1715933170; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RvspPlO30Dpgs5BRdySP249xAR6/Pg+jqZL6QxyeFOU=; b=b0D/g/+c/U0+x91a6/XfL5qOY4EiKzJezVlZgBMJeWhJzprY7n/G2wzsT64ISMkM54Iqe3 VZDHedjAXKpN+9Cg== From: "tip-bot2 for Dawei Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix initial util_avg calculation Cc: Dawei Li , Ingo Molnar , Vincent Guittot , Vishal Chourasia , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240315015916.21545-1-daweilics@gmail.com> References: <20240315015916.21545-1-daweilics@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171593317056.10875.16807671929410125258.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 72bffbf57c5247ac6146d1103ef42e9f8d094bc8 Gitweb: https://git.kernel.org/tip/72bffbf57c5247ac6146d1103ef42e9f8d094bc8 Author: Dawei Li AuthorDate: Thu, 14 Mar 2024 18:59:16 -07:00 Committer: Ingo Molnar CommitterDate: Fri, 17 May 2024 09:49:44 +02:00 sched/fair: Fix initial util_avg calculation Change se->load.weight to se_weight(se) in the calculation for the initial util_avg to avoid unnecessarily inflating the util_avg by 1024 times. The reason is that se->load.weight has the unit/scale as the scaled-up load, while cfs_rg->avg.load_avg has the unit/scale as the true task weight (as mapped directly from the task's nice/priority value). With CONFIG_32BIT, the scaled-up load is equal to the true task weight. With CONFIG_64BIT, the scaled-up load is 1024 times the true task weight. Thus, the current code may inflate the util_avg by 1024 times. The follow-up capping will not allow the util_avg value to go wild. But the calculation should have the correct logic. Signed-off-by: Dawei Li Signed-off-by: Ingo Molnar Reviewed-by: Vincent Guittot Reviewed-by: Vishal Chourasia Link: https://lore.kernel.org/r/20240315015916.21545-1-daweilics@gmail.com --- kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 146ecf9..9009787 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1031,7 +1031,8 @@ void init_entity_runnable_average(struct sched_entity *se) * With new tasks being created, their initial util_avgs are extrapolated * based on the cfs_rq's current util_avg: * - * util_avg = cfs_rq->util_avg / (cfs_rq->load_avg + 1) * se.load.weight + * util_avg = cfs_rq->avg.util_avg / (cfs_rq->avg.load_avg + 1) + * * se_weight(se) * * However, in many cases, the above util_avg does not give a desired * value. Moreover, the sum of the util_avgs may be divergent, such @@ -1078,7 +1079,7 @@ void post_init_entity_util_avg(struct task_struct *p) if (cap > 0) { if (cfs_rq->avg.util_avg != 0) { - sa->util_avg = cfs_rq->avg.util_avg * se->load.weight; + sa->util_avg = cfs_rq->avg.util_avg * se_weight(se); sa->util_avg /= (cfs_rq->avg.load_avg + 1); if (sa->util_avg > cap)