Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp428280lqh; Tue, 7 May 2024 03:42:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkBL6tQjWb8EAjNJvgGdHIgPFt8bG6R8touD1Md1Tcdztt41rZrLMEMOnLJEobzpIMrgZ5zTlozmVxrbRE3CMYKWw1gONZnN43e+3vqA== X-Google-Smtp-Source: AGHT+IEdoOkl//kvZfbQTK86UkxxJ/mJ92Fyl5Jwd4i9qjFMWddHPagGcX9nLPulWOC3yigG9d2h X-Received: by 2002:a50:c316:0:b0:572:5bc3:3871 with SMTP id a22-20020a50c316000000b005725bc33871mr7980029edb.10.1715078540463; Tue, 07 May 2024 03:42:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715078540; cv=pass; d=google.com; s=arc-20160816; b=YyRueMyGM6pI9vGT/vYDGh+jB8shclvYDQsNuxE2IW4TsHeeiiBgiDo15ap7EvRTO6 SYe/so8l5xnrPAGVSaUpFES6DNB84MXADaeXF4iRX2M1rINb88kCywqSV/6ScPSX+Akc qC9uu66EOC6/u31F29Wcm4Slj01p3P3IzLnwl6L3x2cyUWMPoyQrqmh7g8v7gyzKLGmP qvBVyoRtUlfdzHE9EOjo4Wc2/bccOcYS7CcYnsh7BXJUB0mkAWbk0j2lJpNX2AbfJQCV hWqko1JLqAx+Ij6Bdj7xDq25P0PYkNUuUGiQn/fi7kLP21uAPW73q4uZGyqz3JXV7R3n c44w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tXzvyFG6l9gTH5dCnOcuMruwGnZepx9teig8QB5iF2w=; fh=j+KOu1oH5Y0hZInhStQCHBixEKSQBJO9nC4WJfzOOW8=; b=0bgoBjx4UhArKMzUutRwX7FTCp6LmT8sS7m/PBO3vI8SGZtl0usdtieCj49G0hEhTp Rmy1Jz3F+V64RrivHebgDr1HOpFdL77mXrDCRJcqSST5ZE5jIJK02wmT0r6DHmO8NI+q JKOJBadCCt/l37Ic8Xt09GJnvgBsfUGOZD0kbDAivE2tdErVgT20vN1tGGM+Tz5c8gwt Rn/H1s7VIFTECskjvgtKFB5VyaskPMZHHOEIazh92KWR/cCXFO9Wr5DDJHMLKZz+/Shj WasIFuAAW6gT8h0qn4dxU74cq8/orFj+PszqHLVL/9iMcVfqwFfhO/P5M2946opDm7Yp 7ZZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="E/o9YTuf"; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-171118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171118-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f18-20020a0564021e9200b00572d3aa597dsi5082634edf.65.2024.05.07.03.42.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:42:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171118-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; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b="E/o9YTuf"; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-171118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171118-linux.lists.archive=gmail.com@vger.kernel.org" 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 0B4DB1F2576B for ; Tue, 7 May 2024 10:42:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79E7514F9C3; Tue, 7 May 2024 10:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="E/o9YTuf" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 C664B14D430 for ; Tue, 7 May 2024 10:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715078530; cv=none; b=cqDtW70UHXzxnKH3iM3hIQxvVaW92W3qw+sf0UvsHDfyLtHSiST/2qPLkrj7euU0TV35aA6RsrZn0sGOQkt6/Bw3qAplcEWokYKk/4lSpB2NDdWiCHUQEHt0gjem8CpVyrBFNTt2YrphkT+OKoctbTgtTAfTtK52J8eaIzhCbOA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715078530; c=relaxed/simple; bh=U5VgfOOP6YcgNQcpBS/3Hv+gg9zIwZpEKcCDlvS0cGs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PsqbvZukP3cZI9FQCStxamH45ZpfHkPwaNBFsWp9BMaGsX3/inCFgwopO/Ac/bv1IyoDJbLGwZogbllTKgwclYPvsQIkZIwrUpkUegNQdY5R1V6mKGalfyBt2mnO4hC8JRp9/apW5E6RZ7JjEschfewnUjLKWhdP8fXgQwoFjv4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=E/o9YTuf; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-41b794510cdso24155795e9.2 for ; Tue, 07 May 2024 03:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1715078527; x=1715683327; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tXzvyFG6l9gTH5dCnOcuMruwGnZepx9teig8QB5iF2w=; b=E/o9YTufLkZ0xMxexdfkMsCaAjTTCHkOi1CIMx0E8a0u1tjv7jzICEttAxmDqyZ5z7 JbJQgIak1bgefKBe+MEniElFkQ/NVw7XEZZdAaqUOJI7niQd2gele80ghwHs9dLktpAX 4KG6hqahm3jOhP1uEewVwsYIaI+V3nKxfKjtqXNf3ibEhSj9cRPDFhKDcMvmtZYFExh6 mx9S5yWJxzuFXRZaoZZamZwBEQM5MJkxp6fvlg9z6JNqzUCUwGZjfF+bZ7OejeVw1GI7 obgVdt5tiZkRf1cjI6Lr0HFqWv/lytQ1iYltoLlxG1NaXTD4nm4Tzr0AozDDZyDiqVFN tgRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715078527; x=1715683327; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tXzvyFG6l9gTH5dCnOcuMruwGnZepx9teig8QB5iF2w=; b=Di1s1c5JlCT/dA3kxJnIV7n5I2Y0Fgoh1Uy41fqKiwNmBABpSZG6ssGcyIjgWz8Ult fjpd92fW+jq7tFCeU4BGAPCCmAdkLpWYbXuvKrrSZUJcBXKMRwXiGq5MxIeZG6lXRbrp Sc901lpIjDY16UwpBCnIOlIcNifc/iEbGIEgVA0TOWJuumOqI3KLcqy6pTDs9vXQGwKZ oHHWRgpZXfiqtL/JIaYhyZqlBqAdud/YjXXJEaayFKU2vapiUVoz4LKZthPYnUahEdEC UiouA3ryzvOfr5ohX/YiDHdRaTnV9ANMzjIGre2f1WQbXJe6+VDhW4QdmJmMMDF4w8IT 9xng== X-Forwarded-Encrypted: i=1; AJvYcCWMtDKnNQ5fXshu9gXbRj2BuQ5nbXi3HFisEXo1LO+pHgMEblDBfWJ7ReEn2AhSIyd7fGQ0v1jifAVgOXT7rMS4a58Py76Cn9xKGymM X-Gm-Message-State: AOJu0Yx36V5xwLj1xJGwuaz7SFK9OpBmn5wdE09+zjIKFJQRPXrbotvb pOnfSksybzkKWYhHBkvMAftOCeq5gcyqKAtS2Z4tjioxxP4l3aRrq27CzVzu25s= X-Received: by 2002:a05:600c:46ca:b0:41c:11fe:4de3 with SMTP id q10-20020a05600c46ca00b0041c11fe4de3mr10030220wmo.24.1715078527041; Tue, 07 May 2024 03:42:07 -0700 (PDT) Received: from airbuntu (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c469100b0041b083e16e2sm23107663wmo.2.2024.05.07.03.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 03:42:06 -0700 (PDT) Date: Tue, 7 May 2024 11:42:04 +0100 From: Qais Yousef To: Peter Zijlstra Cc: "Rafael J. Wysocki" , Viresh Kumar , Ingo Molnar , Vincent Guittot , Juri Lelli , Steven Rostedt , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Christian Loehle , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] sched: Consolidate cpufreq updates Message-ID: <20240507104204.ugnyrpwhrbtjkv7d@airbuntu> References: <20240505233103.168766-1-qyousef@layalina.io> <20240506100509.GL40213@noisy.programming.kicks-ass.net> <20240507005659.d4rzzaoq3isanndf@airbuntu> <20240507080230.GP40213@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240507080230.GP40213@noisy.programming.kicks-ass.net> On 05/07/24 10:02, Peter Zijlstra wrote: > On Tue, May 07, 2024 at 01:56:59AM +0100, Qais Yousef wrote: > > > Yes. How about this? Since stopper class appears as RT, we should still check > > for this class specifically. > > Much nicer! > > > static inline void update_cpufreq_ctx_switch(struct rq *rq, struct task_struct *prev) > > { > > #ifdef CONFIG_CPU_FREQ > > if (likely(fair_policy(current->policy))) { > > > > if (unlikely(current->in_iowait)) { > > cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT | SCHED_CPUFREQ_FORCE_UPDATE); > > return; > > } > > > > #ifdef CONFIG_SMP > > /* > > * Allow cpufreq updates once for every update_load_avg() decay. > > */ > > if (unlikely(rq->cfs.decayed)) { > > rq->cfs.decayed = false; > > cpufreq_update_util(rq, 0); > > return; > > } > > #endif > > return; > > } > > > > /* > > * RT and DL should always send a freq update. But we can do some > > * simple checks to avoid it when we know it's not necessary. > > */ > > if (task_is_realtime(current)) { > > if (dl_task(current) && current->dl.flags & SCHED_FLAG_SUGOV) { > > /* Ignore sugov kthreads, they're responding to our requests */ > > return; > > } > > > > if (rt_task(current) && rt_task(prev)) { > > doesn't task_is_realtime() impy rt_task() ? > > Also, this clause still includes DL tasks, is that okay? Ugh, yes. The earlier check for dl_task() is not good enough. I should send a patch to fix the definition of rt_task()! I think at this stage open coding the policy check with a switch statement is the best thing to do static inline void update_cpufreq_ctx_switch(struct rq *rq, struct task_struct *prev) { #ifdef CONFIG_CPU_FREQ /* * RT and DL should always send a freq update. But we can do some * simple checks to avoid it when we know it's not necessary. * * iowait_boost will always trigger a freq update too. * * Fair tasks will only trigger an update if the root cfs_rq has * decayed. * * Everything else should do nothing. */ switch (current->policy) { case SCHED_NORMAL: case SCHED_BATCH: if (unlikely(current->in_iowait)) { cpufreq_update_util(rq, SCHED_CPUFREQ_IOWAIT | SCHED_CPUFREQ_FORCE_UPDATE); return; } #ifdef CONFIG_SMP if (unlikely(rq->cfs.decayed)) { rq->cfs.decayed = false; cpufreq_update_util(rq, 0); return; } #endif return; case SCHED_FIFO: case SCHED_RR: if (rt_policy(prev)) { #ifdef CONFIG_UCLAMP_TASK unsigned long curr_uclamp_min = uclamp_eff_value(current, UCLAMP_MIN); unsigned long prev_uclamp_min = uclamp_eff_value(prev, UCLAMP_MIN); if (curr_uclamp_min == prev_uclamp_min) #endif return; } #ifdef CONFIG_SMP /* Stopper task masquerades as RT */ if (unlikely(current->sched_class == &stop_sched_class)) return; #endif cpufreq_update_util(rq, SCHED_CPUFREQ_FORCE_UPDATE); return; case SCHED_DEADLINE: if (current->dl.flags & SCHED_FLAG_SUGOV) { /* Ignore sugov kthreads, they're responding to our requests */ return; } cpufreq_update_util(rq, SCHED_CPUFREQ_FORCE_UPDATE); return; default: return; } #endif }