Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2794699rwe; Sun, 28 Aug 2022 23:25:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR57+cTPEKO3BiSc56jrb7liZEakIAK5jgToBHeA91UAevw4n5XO8iGwP9mGc96gxBaPOznD X-Received: by 2002:a05:6402:510:b0:448:1649:1f2c with SMTP id m16-20020a056402051000b0044816491f2cmr8155074edv.139.1661754349962; Sun, 28 Aug 2022 23:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661754349; cv=none; d=google.com; s=arc-20160816; b=ZEinz0wbjj9wtZ540wGvtEo3h6bdPegKtAl2NUdIUcUR1qqeJd184yowhgpG59GEzd 5edMkXupnamUueHgaefCmpVakIVAlk3mZjZElYdjWwiuquRbI/gUV069vXYD7rnKo8Tr 5BqCo3sMF7SaaffAj0CFZobUOvLT+nRri06dYJdRlCP7AJ8MNGATobh9BMY1c4/CbwfB uU9lxfeWXPDDuwSnVaw23Sa0tSVw6dJdD1YWAUyofI5Yd3lAy8EtnFqB/+ap0cMwUFPi CD8ponlE1b1Gq5fqppxrRmaRxfFum9j82aFAjdHjt1IINIyCLYDHpy8G0MPFivrun1yR 30NQ== 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=WZ6TjENXPcFxGKPcsTfKI2qt69J0eQFxTuLVt8fTXVI=; b=x2IPluUEIVszuDSFGKqFo+0BOuXlzhA5RaAGI6A2DCOJVEWGlTc+/L2U+Pao7aUxUI sJDb9T97r3D6R9T7CQObO6txv7d+GmzMHDgUcuvP+A8Ue4L/AYncgXpxLhpE7pq7kvvP 8wQuPa5mEQOsE8mM0/Rd42R9XeR4k9xQqxoQCl1u2BMxqLTF5wZ7eBIVrW9KKtB2mmDS yMUVIIVs5GGEPg5UOsHaUDbsRfULffJCgQzuaGe9m+enPOXucQyxxQ6RwzZ3KttFBlzE XHLSUAUWOCxEdFtVfC45qQKAgSah6ZunIqQ8Ccjwil6g/sGU+ELxT+Fs/y5OYvbb+RVG LHhw== 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 u16-20020a170906125000b0073d68e6a8a8si4970577eja.422.2022.08.28.23.25.24; Sun, 28 Aug 2022 23:25:49 -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 S229618AbiH2F4N (ORCPT + 99 others); Mon, 29 Aug 2022 01:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbiH2Fz5 (ORCPT ); Mon, 29 Aug 2022 01:55:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7EBD23162 for ; Sun, 28 Aug 2022 22:55:17 -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 2E42723A; Sun, 28 Aug 2022 22:55:23 -0700 (PDT) Received: from e125579.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BB97C3F766; Sun, 28 Aug 2022 22:55:43 -0700 (PDT) From: Dietmar Eggemann To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Morten Rasmussen , Vincent Donnefort Cc: Quentin Perret , Patrick Bellasi , Abhijeet Dharmapurikar , Jian-Min , Qais Yousef , linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/1] sched/pelt: Change PELT halflife at runtime Date: Mon, 29 Aug 2022 07:54:49 +0200 Message-Id: <20220829055450.1703092-1-dietmar.eggemann@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, 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 Many of the Android devices still prefer to run PELT with a shorter halflife than the hardcoded value of 32ms in mainline. The Android folks claim better response time of display pipeline tasks (higher min and avg fps for 60, 90 or 120Hz refresh rate). Some of the benchmarks like PCmark web-browsing show higher scores when running with 16ms or 8ms PELT halflife. The gain in response time and performance is considered to outweigh the increase of energy consumption in these cases. The original idea of introducing a PELT halflife compile time option for 32, 16, 8ms from Patrick Bellasi in 2018 https://lkml.kernel.org/r/20180409165134.707-1-patrick.bellasi@arm.com wasn't integrated into mainline mainly because of breaking the PELT stability requirement (see (1) below). We have been experimenting with a new idea from Morten Rasmussen to instead introduce an additional clock between task and pelt clock. This way the effect of a shorter PELT halflife of 8ms or 16ms can be achieved by left-shifting the elapsed time. This is similar to the use of time shifting of the pelt clock to achieve scale invariance in PELT. The implementation is from Vincent Donnefort with some minor modifications to align with current tip sched/core. --- Known potential issues: (1) PELT stability requirement PELT halflife has to be larger than or equal to the scheduling period. The sched_period (sysctl_sched_latency) of a typical mobile device with 8 CPUs with the default logarithmical tuning is 24ms so only the 32 ms PELT halflife met this. Shorter halflife of 16ms or even 8ms would break this. It looks like that this problem might not exist anymore because of the PELT rewrite in 2015, i.e. with commit 9d89c257dfb9 ("sched/fair: Rewrite runnable load and utilization average tracking"). Since then sched entities (task & task groups) and cfs_rq's are independently maintained rather than each entity update maintains the cfs_rq at the same time. This seems to mitigate the issue that the cfs_rq signal is not correct when there are not all runnable entities able ot do a self update during a PELT halflife window. That said, I'm not entirely sure whether the entity-cfs_rq synchronization is the only issue behind this PELT stability requirement. (2) PELT utilization versus util_est (estimated utilization) The PELT signal of a periodic task oscillates with higher peak amplitude when using smaller halflife. For a typical periodic task of the display pipeline with a runtime/period of 8ms/16ms the peak amplitude is at ~40 for 32ms, at ~80 for 16ms and at ~160 for 8ms. Util_est stores the util_avg peak as util_est.enqueued per task. With an additional exponential weighted moving average (ewma) to smooth task utilization decreases, util_est values of the runnable tasks are aggregated on the root cfs_rq. CPU and task utilization for CPU frequency selection and task placement is the max value out of util_est and util_avg. I.e. because of how util_est is implemented higher CPU Operating Performance Points and more capable CPUs are already chosen when using smaller PELT halflife. (3) Wrong PELT history when switching PELT multiplier The PELT history becomes stale the moment the PELT multiplier is changed during runtime. So all decisions based on PELT are skewed for the time interval to produce LOAD_MAX_AVG (the sum of the infinite geometric series) which value is ~345ms for halflife=32ms (smaller for 8ms or 16ms). Rate limiting the PELT multiplier change to this value is not solving the issue here. So the user would have to live with possible incorrect discussions during these PELT multiplier transition times. --- It looks like that individual task boosting e.g. via uclamp_min, possibly abstracted by middleware frameworks like Android Dynamic Performance Framework (ADPF) would be the way to go here but until this is fully available and adopted some Android folks will still prefer the overall system boosting they achieve by running with a shorter PELT halflife. Vincent Donnefort (1): sched/pelt: Introduce PELT multiplier kernel/sched/core.c | 2 +- kernel/sched/pelt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ kernel/sched/pelt.h | 42 ++++++++++++++++++++++++++++--- kernel/sched/sched.h | 1 + 4 files changed, 100 insertions(+), 5 deletions(-) -- 2.25.1