Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp944402lqt; Fri, 7 Jun 2024 03:38:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvbgkdnaOoDPXjjmPD76/SpUnFSEvhc0sS9LXfhJyJePek9JEsFxT71rZmiapW7SbNLcTVzVYU4psJOg2X2HkxdmqMjrlP2/weRBwZsQ== X-Google-Smtp-Source: AGHT+IGcYF6R3PHgrXNT3gWBmG5XN/na12URSoen+6RMLRYmGt1UIEtQEDPM3KPAn2t4H0J+EDfT X-Received: by 2002:a05:622a:34d:b0:43a:ecf9:c1c7 with SMTP id d75a77b69052e-44041cb9b0bmr21754381cf.51.1717756707518; Fri, 07 Jun 2024 03:38:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717756707; cv=pass; d=google.com; s=arc-20160816; b=LNhSHVgbqx2suW9Xxh5TGb86HUYPIFFzciTP5CIy/mYjfqUc5Gs8Z2feDr6jD8qHOd TdNAaYUJGnPZZjnNIHKZ0TXov5svQMbudDAAgXstaj8PMk2rjCQoTz3lh+b+GXlaPxKU 7nnz8hh//DD9D4CF0PoUTkZLD5Rh6hWz+46t3Yp706kXlWl1JypUMmrVL70F9zZzEeea efWcaBzGu3k43ZFbUPSranlUqF6fd1PELWkNrFbLMRTWsUjDMO3j+77KNy6sCq3WA91W 0IEhcib4stWkg2rgdpL1IFAUxcOzck7Ipw6iSQGe1FZsO99HIlGXBz2Y9TdG7cqD97NO jl1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=xaI0Q81ruSBQnGTreVhaznQdvACwrU3yk1vhgUHVUX8=; fh=aLxrh6pV1HsrZoXBt4sIqCxLyig9B3nkYdY48fFR+CQ=; b=sAuwtMqhdQqi31m88X3oGI0YoM4kWBy935Hl8LviDq10FI9YmaG9twegVYqqR9FKAR XQCgWHrRlSNcpfK/wW3zWMTP8fL2d24ZBUYdJZkUu1JScZHZ4bOfzHG8tZwiPEKbFz/t 7+NJlg9AjfI1Nzkpn9V/mKkp4qZZPQuDXAsdu2vklrY6PBgdSW8FSK/mzcTGRoMvziMx B5t8NvuO5rxg6m7Kt7lh84Ow7m56HhfYai8NUEnD75MwGHEUtSFWxnRX5crjSRda+03q dl5/f/aBNA3sFG417ZK4OXQs55HU0JN3LGbLXl1Z/35bh9zjF2VKJ+JemAnjDdNl0CIa LbRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mj+UTIgy; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-205840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44038b1808csi36786051cf.368.2024.06.07.03.38.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 03:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mj+UTIgy; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-205840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205840-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BA13D1C22B1F for ; Fri, 7 Jun 2024 10:38:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 099A617083E; Fri, 7 Jun 2024 10:38:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mj+UTIgy" Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 CE2FE15DBB7 for ; Fri, 7 Jun 2024 10:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717756690; cv=none; b=gsyPpHV5a+85GATAyrowgvj4Au4LjH9k4YDzl488t6rmki6APRNFgNsuhRC/bGCfInhjs9z/vDGJIgcE2PKcUIB05OSPW1EdDrWr3yI/ul7UmqrTrpX5m/2Y4LSo8DOt5vl9lZPMNQkvr91p9eO+zWUspX1USkeri3dGjlfBdRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717756690; c=relaxed/simple; bh=Z/mdWrkVlem1gY+MV04XH00y55hY9Gvc8F47rLQzxak=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=as5/E2TJpOQ+kLiv+SeLOLKQalDzxvaxDYGFkPdH1inHGkrmAfcFO8AXPKZgsNviP4bYgsMhdIPnMeVX6gysKqyxx2q+r27Z0dpqGjp1XxJJ0hn0KonYcvIs28Ug2jaILLDobFF5OWRwA6YRhQlSLUwnYebQqX2GVfcybX6gU+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mj+UTIgy; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3d20c0fe970so818355b6e.0 for ; Fri, 07 Jun 2024 03:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717756688; x=1718361488; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xaI0Q81ruSBQnGTreVhaznQdvACwrU3yk1vhgUHVUX8=; b=mj+UTIgyh82SfEFrWGG6D/ZaDNa4rQoWrRtwUbfUm/mOoqB+eaQRsT/NDZhEdMTKn6 aTi53nOeSMRjmd6yOq5eZ312CYSpOV9H1SznShH6pDrH5SDBF7nBe6imOp7MOKO2TPqX ht3WGFIpu5kc8pQLpJ6W9qW10EapXaXJF3XzkXnQM9dWUnUC3TuBhYc9FPb5Rj8tHIwn HVJSjSD6hOA0nB8TS/gXvqfg7DLAhpeU/QOjhRIiL3mMAeM7p9reTj3U5iBiZtpnZrSm /oVAxEWBzlh+2o0fNnFUBWr9sXiKYyXR/Ogt9zNcEyMZB5prAdwRGx0SSXRYpUxe2KWA RFoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717756688; x=1718361488; h=content-transfer-encoding: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=xaI0Q81ruSBQnGTreVhaznQdvACwrU3yk1vhgUHVUX8=; b=wL0hInr89iywNYMFOk/HRnG4Gm4WKCvatEajuphMKT8J6lv9ztlFqr5XoBW/vtPVKZ d6Idj/yWg22KybaTt3r2MozI9O+9nJebYBQENEI26qxrLWHj/6CqwqEsfCvLDgTfvvAY fr1S1o2mUYxlflliGydtm0lF7UUqFSMyXTbAZRDieAH1QIWIMCCGh27elveUnIHdzJLS VVMM3KPJcPYu964y6As9OgQMPThtMwdmFCtm46dxNL38c0zsbtx75vB80z0lCBFZqr82 SyQhA9VIddFNcRwEO3A0bcEuoFeUEM3ZB4Kk2obSARpP93Y7/CyeChfAGSS8TikO0aU8 D8xQ== X-Forwarded-Encrypted: i=1; AJvYcCVgCextKk7pvjRve/62hqewKLh3qNdggtOCUi5sVKk94ZtXeicfbyA43FPnIyHrVIb/D0ZHO/Kn6okvtYMPqfIpSnvIol0fhtMCJINh X-Gm-Message-State: AOJu0YzpNniwpO+T5Bli4jAM7TsRdh6+e0AjT0JQD/9BbtVdhpFU7GhF RSJxwICHGHSUovZ3BITSdP6+RXd4LbtrJpgQ9LrHpWpMKz5GsIvQsAFc5de++dNd2CKUhLW5BDy oa5ZXwX3yqui7y48FPSIKOMTRohhwRhn1 X-Received: by 2002:a05:6808:14c2:b0:3d2:178b:3332 with SMTP id 5614622812f47-3d2178b3407mr382541b6e.49.1717756686333; Fri, 07 Jun 2024 03:38:06 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240606070645.3295-1-xuewen.yan@unisoc.com> <0763f870-e30c-46cf-aefa-b879f2ebdba4@arm.com> <64115627-c6c7-416b-99f9-0df22cbdca6b@arm.com> In-Reply-To: <64115627-c6c7-416b-99f9-0df22cbdca6b@arm.com> From: Xuewen Yan Date: Fri, 7 Jun 2024 18:37:54 +0800 Message-ID: Subject: Re: [PATCH] sched/fair: Prevent cpu_busy_time from exceeding actual_cpu_capacity To: Dietmar Eggemann Cc: Xuewen Yan , vincent.guittot@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, vincent.donnefort@arm.com, qyousef@layalina.io, ke.wang@unisoc.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 7, 2024 at 6:30=E2=80=AFPM Dietmar Eggemann wrote: > > On 07/06/2024 10:20, Xuewen Yan wrote: > > Hi Dietmar > > > > On Fri, Jun 7, 2024 at 3:19=E2=80=AFPM Dietmar Eggemann > > wrote: > >> > >> On 06/06/2024 09:06, Xuewen Yan wrote: > >>> Because the effective_cpu_util() would return a util which > >>> maybe bigger than the actual_cpu_capacity, this could cause > >>> the pd_busy_time calculation errors. > >> > >> Doesn't return effective_cpu_util() either scale or min(scale, util) > >> with scale =3D arch_scale_cpu_capacity(cpu)? So the util sum over the = PD > >> cannot exceed eenv->cpu_cap? > > > > In effective_cpu_util, the scale =3D arch_scale_cpu_capacity(cpu); > > Although there is the clamp of eenv->pd_cap, but let us consider the > > following simple scenario: > > The pd cpus are 4-7, and the arch_scale_capacity is 1024, and because > > of cpufreq-limit, > > Ah, this is due to: > > find_energy_efficient_cpu() > > ... > for (; pd; pd =3D pd->next) > ... > cpu_actual_cap =3D get_actual_cpu_capacity(cpu) > > for_each_cpu(cpu, cpus) > ... > eenv.pd_cap +=3D cpu_actual_cap > > and: > > get_actual_cpu_capacity() > > ... > capacity =3D arch_scale_cpu_capacity(cpu) > > capacity -=3D max(hw_load_avg(cpu_rq(cpu)), cpufreq_get_pressure(cpu)) > > which got introduced by f1f8d0a22422 ("sched/cpufreq: Take cpufreq > feedback into account"). I don't think it was introduced by f1f8d0a22422, because f1f8d0a22422 just replaced the cpu_thermal_cap with get_actual_cpu_capacity(cpu). The eenv.cpu_cap was introduced by 3e8c6c9aac42 ("sched/fair: Remove task_util from effective utilization in feec()"). BR --- xuewen > > [...]