Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp285817lqr; Wed, 5 Jun 2024 06:13:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0pvyfAcMWcj3rE1cMuPw3GZ0kdfKKLLMPDSX6bJGRkLdh2KwYdcB+LXowtkMNj0ryJpHXYVfMc9zFPQzshefkFH4bLeKoB0w4rj0fKg== X-Google-Smtp-Source: AGHT+IFbfdV5aKDKGDmoLPFBS6vw3LFDr0TH/SV6eXzBkhRj94jHBudJ+I50EQy9y3ON27JpkJ8r X-Received: by 2002:a17:907:bb99:b0:a68:b089:e27 with SMTP id a640c23a62f3a-a699f681b5amr163574166b.44.1717593204503; Wed, 05 Jun 2024 06:13:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717593204; cv=pass; d=google.com; s=arc-20160816; b=HKGKUML90GV+/KVTlEDyiNF9RcSW6GEMWf2NLfjs9DgQVc9fNV4s3Tzihg34JbJiEz bbIpYkTqTjzYuIaz41tWKfPfbFKmnV6ztFk4PRVI+QhmAKoLE/JR/0UytkY2KIqMWof1 oBHV2go3xste8HQSR10kg3ajDRNSbhs2OVehtE9vScbeJgPSRG/7SdYTSelRZxfAQ3rP BtgATA7/ebCCA6TDxOmqY2MBcc50+SuDMneNJ439pPI035TAsFpPDYFX+HGR9Z1N83KM RMctfsfZQL7V3SHjCR+mRKdcfznUTfuoEl/ncrYiYaUcd5PnxLOCQV8h3++q90I0spAZ /o5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=wQdKlIkzWBiCWBx1bRhWze/7+sjVhpoDp+f2+Pe8fVo=; fh=CM+liAnMJLaQk0IaNV8BM3aPTGcA8rfGJjjtDXUo8MM=; b=tw70E/wvt1ZMQz27xl2wZos9AYcnAGea6WAeXAnlT9NtP7nA/DZX2ovnsmsPQUWMHg d5zSfcP9C+uKMI73YWAZkjPslyWY3R0sAaB5+ah5I7nJAxktsqknKeZ4q2YHStY2UWgh PmMcro7h4k7g5gVD6vd7uO8ijCsTVzHLAXiYeIHPh2Lc23hLkXfBixgOEB8WSIVvmEUa BqmynQ5j/F9Qq6N6e6IHeb4/y263uRsKUUufLaTxvM4Pg1uJ6LAkybHs4BAlbIQoLHIO eb8TZkVFRWJw2XxQWRFlr8ThMY83r9DiCyE5UmQz0QX3LjUzySAQ0E2BuOm+lWs9T1IM bYSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-202597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6a7e2c62eesi60125366b.546.2024.06.05.06.13.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-202597-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D86591F28C19 for ; Wed, 5 Jun 2024 13:09:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DE0819AD4F; Wed, 5 Jun 2024 12:24:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00C4B19AD47; Wed, 5 Jun 2024 12:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717590251; cv=none; b=Bqf+zroYqFVuDbzEIW0laaJIXen2N5RYLucQ4ollRAEX0Hm+UbW58nKRuU21il7xKMzxrbmH1ns067rl8wLz2RtUMgzTsUtGAruUBYXVV8EoIvlFl+jrDRAzhWzumMHDBbWfwACnHywJ/NJ1zfca3UL5XqViXGZJmShheKf/oCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717590251; c=relaxed/simple; bh=n3ty1xTwxBm5dX7g7QjOm3hVgjJlDQb1B6sZe0BtFLY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=a6NriYWE8M1wfrHqM4vmZ+II5UZuHd3EM4j+U/egbkvSdRm3UkHOjXeX4+DRrlU6asvXlAL/JOS+8Q4TbJBcuVpTqqSBlLwkHFQwV3S3VmfUqBn2awlTkrEWJ7JfDBp0Yt8/1Gq1pCgVVMeejt0ut2muXBuWePRAgY3oVMt2m2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 A340C339; Wed, 5 Jun 2024 05:24:32 -0700 (PDT) Received: from [10.1.32.39] (e127648.arm.com [10.1.32.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D83583F762; Wed, 5 Jun 2024 05:24:04 -0700 (PDT) Message-ID: <1b44938c-9535-47e7-8cbc-2b844e5dfdff@arm.com> Date: Wed, 5 Jun 2024 13:24:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5] sched: Consolidate cpufreq updates To: Qais Yousef , "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli Cc: Steven Rostedt , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Hongyan Xia , John Stultz , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240530104653.1234004-1-qyousef@layalina.io> Content-Language: en-US From: Christian Loehle In-Reply-To: <20240530104653.1234004-1-qyousef@layalina.io> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/30/24 11:46, Qais Yousef wrote: > Improve the interaction with cpufreq governors by making the > cpufreq_update_util() calls more intentional. > > At the moment we send them when load is updated for CFS, bandwidth for > DL and at enqueue/dequeue for RT. But this can lead to too many updates > sent in a short period of time and potentially be ignored at a critical > moment due to the rate_limit_us in schedutil. > > For example, simultaneous task enqueue on the CPU where 2nd task is > bigger and requires higher freq. The trigger to cpufreq_update_util() by > the first task will lead to dropping the 2nd request until tick. Or > another CPU in the same policy triggers a freq update shortly after. > > Updates at enqueue for RT are not strictly required. Though they do help > to reduce the delay for switching the frequency and the potential > observation of lower frequency during this delay. But current logic > doesn't intentionally (at least to my understanding) try to speed up the > request. > > To help reduce the amount of cpufreq updates and make them more > purposeful, consolidate them into these locations: > > 1. context_switch() > 2. task_tick_fair() > 3. update_blocked_averages() > 4. on syscall that changes policy or uclamp values > > The update at context switch should help guarantee that DL and RT get > the right frequency straightaway when they're RUNNING. As mentioned > though the update will happen slightly after enqueue_task(); though in > an ideal world these tasks should be RUNNING ASAP and this additional > delay should be negligible. Do we care at all about PREEMPT_NONE (and voluntary) here? I assume no. Anyway one scenario that should regress when we don't update at RT enqueue: (Essentially means that util of higher prio dominates over lower, if higher is enqueued first.) System: OPP 0, cap: 102, 100MHz; OPP 1, cap: 1024, 1000MHz RT task A prio=0 runtime@OPP1=1ms, uclamp_min=0; RT task B prio=1 runtime@OPP1=1ms, uclamp_min=1024 rate_limit_us = freq transition delay = 1 (assume basically instant switch) Let's say CONFIG_HZ=100 for the tick to not get in the way, doesn't really matter. Before: t+0: Enqueue task A switch to OPP0 Running A at OPP 0 t+2us: Enqueue task B switch to OPP1 t+1000us: Task A done, switch to task B. t+2000us: Task B done Now: t+0: Enqueue task A switch to OPP0 Running A at OPP 0 t+2us: Enqueue task B t+10000us: Task A done, switch to task B and OPP1 t+11000us: Task B done Or am I missing something? Kind Regards, Christian > [snip]