Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1071031rwr; Fri, 5 May 2023 08:44:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DS8LGO27nYnjrp+5T07x24M1rDfuU4kNrnG7kHNbkP9wt210gFgX3Md55mgonFXATUrNm X-Received: by 2002:a05:6a20:9385:b0:ee:bcf3:be0c with SMTP id x5-20020a056a20938500b000eebcf3be0cmr3563278pzh.0.1683301494767; Fri, 05 May 2023 08:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683301494; cv=none; d=google.com; s=arc-20160816; b=xaqUnzKvyDC9M9gnbp4S8YoeMbSBmDLyvCxOTE+Et6k8Dj6AJ4amNZ14Gudtzbw1Pl 8trCVQHDv7FLwfAHx+r3aS9ntYC3tKBAuVbfVY3sh1CJSfskRoVXweF14wFmEZLgERmx 4MUgZyWIlD7r6NTKdn1HkRWxXQeE7F38y4YiMb2I0bNtUTpI9ksafd+Q+Tkf+2QcZjSO ehgPbj+rX5TcnDDE09C4manAIJFI59A/Ou7Bb7UY6RfeCreyHXNU14upITkp70D8vaO+ VqLfoon5ayuczoJizBnTZ/9SI6TnyvFDSL/ngCPLzRFIwx9MeCp0dVtV2jFRk4gi/4rS v00Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8natiCZRZD4NcY4F4HQGSfEkKhN2Ua0oaXM7JEV0o8I=; b=GT41i24qRaR3LV9KWSeRx1magCNz8Ciz1kgszB9HbulH3cEueSNmBXkgLnSMmxzwHl fsKa4Aso2w6oNXKlMhUjIhcvQ/DfsPZUayl6KtgvRWCBfDJmcF28S7/PMq9+4ztP0FWD UtO0NlUzkB4PmoiHuyEA+2bnDuh9nbwsd7lmVwtZCegmL/QUtrKcq/+8GW63AVX6G7q+ 4SshzQCxSh20mRQkzLDTPS6VNbxn6lut+3nFOGk+pJRLckW7hsevPiTY+43bvB3v4ENS 7SLQvy9yNAdrQJYx3dNcBgjlG1i634KfhM8ExIU/dvPyFAhsju9xyUOxBvWB7aHBMMca DTCw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a6540cb000000b0051ace49ded1si2117304pgp.886.2023.05.05.08.44.42; Fri, 05 May 2023 08:44:54 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbjEEP0l (ORCPT + 99 others); Fri, 5 May 2023 11:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232955AbjEEP0Y (ORCPT ); Fri, 5 May 2023 11:26:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14C9E1A107; Fri, 5 May 2023 08:25:18 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 292E51FB; Fri, 5 May 2023 08:26:02 -0700 (PDT) Received: from e130256.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E80D13F5A1; Fri, 5 May 2023 08:25:16 -0700 (PDT) From: Hongyan Xia To: Jonathan Corbet Cc: Hongyan Xia , Qais Yousef , Vincent Guittot , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sched/documentation: elaborate on uclamp limitations Date: Fri, 5 May 2023 16:24:39 +0100 Message-Id: <20230505152440.142265-1-hongyan.xia2@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 The story in 5.2 about util_avg abruptly jumping from 300 when Fmax/Fmin == 3 to 1024 when Fmax/Fmin == 4 hides some details about how clock_pelt works behind the scenes. Explicitly mention it to make it easier for readers to follow. Signed-off-by: Hongyan Xia Cc: Qais Yousef Cc: Vincent Guittot --- Documentation/scheduler/sched-util-clamp.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/scheduler/sched-util-clamp.rst b/Documentation/scheduler/sched-util-clamp.rst index 74d5b7c6431d..524df07bceba 100644 --- a/Documentation/scheduler/sched-util-clamp.rst +++ b/Documentation/scheduler/sched-util-clamp.rst @@ -669,6 +669,19 @@ but not proportional to Fmax/Fmin. p0->util_avg = 300 + small_error +The reason why util_avg is around 300 even though it runs for 900 at Fmin is: +Although running at Fmin reduces the rate of rq_clock_pelt() to 1/3 thus +accumulates util_sum at 1/3 of the rate at Fmax, the clock period +(rq_clock_pelt() now minus previous rq_clock_pelt()) in: + +:: + + util_sum / clock period = util_avg + +does not shrink to 1/3, since rq->clock_pelt is periodically synchronized with +rq->clock_task as long as there's idle time. As a result, we get util_avg of +about 300, not 900. + Now if the ratio of Fmax/Fmin is 4, the maximum value becomes: :: @@ -682,6 +695,10 @@ this happens, then the _actual_ util_avg will become: p0->util_avg = 1024 +This is because rq->clock_pelt is no longer synchronized with the task clock. +The clock period therefore is proportionally shrunk by the same ratio of +(Fmax/Fmin), giving us a maximal util_avg of 1024. + If task p1 wakes up on this CPU, which have: :: -- 2.34.1