Received: by 2002:a05:7412:8d08:b0:f9:2d0a:d759 with SMTP id bj8csp247124rdb; Sun, 17 Dec 2023 09:58:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGe6ywXDBtDd+k7ImBs2Gl2Bv2AKyds3LPz/TWmWXWs2nonr0ab1wphA9Zi6xStxhEonfE3 X-Received: by 2002:a05:6214:212c:b0:67f:28d6:711f with SMTP id r12-20020a056214212c00b0067f28d6711fmr5638036qvc.48.1702835923842; Sun, 17 Dec 2023 09:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702835923; cv=none; d=google.com; s=arc-20160816; b=qiCnFUWMDWwpnwtiT1Kx3ewRUd+3NGtPQzhZTpENZE7tqGdKMb81dOkpBsysUfZKig ARZ6NdxzyFT8MpYf2G8JJgrJl5Mg1FRwYoBaHBcTFmenOHScLdEEDQmAMs7GeBQI1vLs VSyxedU02bgkyC8VCWT3oB//KJB9my/d5jUkIGuScXt00eBhfP0bmBOpnEYlEsSCkxLZ hlYYhIzdzRek3knmHOp6A5QdGvYMBcRqsTpQJtTkc8aYKFegDermIk9T9BFMfzeBAeqx XNtE/GyEbPpbu97Zw27OO7LTGKWdb/SONXs626p4vgwm+8tN7xD2PjQuOl4sjPKPhdBk t1mg== ARC-Message-Signature: i=1; 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=zjSwC3QXCT9m5wbkVuevhDt7iqPHObPwr4PaZ7/DBvg=; fh=SxHhTsAdJqr/LLyiPt/hO9HGS2MvCviLtaUdSWFtlDw=; b=DfL9VdC0VYuTXei4D93W0LlAvtIYUeDrdCj98BXx9uL6AsrIK3AnVp1spwQhAjuNRd v/gSAwMeA3Z9S4FK7PIGiuE+TRuQjq1OF5JoZcZcntA1StfdBLOVoh3YU5rg0yJg2oRz OMb2T4Ma9JZUxIufah0Pa/QRdG9LPO+/jDY9rK7PXu6t5PeDOKWNTywhs5vkp26tUdaC 3DgKXV6uRt4DyfZgrbrk0Sz29BH02DUWZcL6aGgHAtJANublPROXEJFG50c05xf6yxkS z7omGNWUI+uK2ZSr28y6wWB1ffhw0Iyk04F8So7aBNCCR1CjiFZ6E1+dP/wx0Dz1YgWq tbfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=Xb29EMtd; spf=pass (google.com: domain of linux-kernel+bounces-2761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2761-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f20-20020a0caa94000000b0067ec646d75csi2124623qvb.344.2023.12.17.09.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 09:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2761-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=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=Xb29EMtd; spf=pass (google.com: domain of linux-kernel+bounces-2761-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2761-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 979321C20D71 for ; Sun, 17 Dec 2023 17:58:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A99E047A66; Sun, 17 Dec 2023 17:58:34 +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="Xb29EMtd" X-Original-To: linux-kernel@vger.kernel.org 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 67BB847A52 for ; Sun, 17 Dec 2023 17:58:32 +0000 (UTC) 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-40c2308faedso28508715e9.1 for ; Sun, 17 Dec 2023 09:58:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1702835911; x=1703440711; 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=zjSwC3QXCT9m5wbkVuevhDt7iqPHObPwr4PaZ7/DBvg=; b=Xb29EMtdbGMF/h516UcwPoHjzWU7nv81dZL+7k3HWPDIrVrBkrFOyzT1AcMbpkCbzK k0YbbZIPUGn+M3w3MeGaQ+9CAjXuzkeywngdoyCviYCmFZv4SF5D5Kisx8rdXQhmKNMJ mhZGeR96XcCEbZhNAmMHcTU/Q4KFkaU7RKH/87Tl12i6iOZzTtqjcw32f/tvCVi3Ix9T ObtRMG6AvVbXiq3BpAB1iTqnl/mdRd/lOUyin44mqgkDsvtyBUJii/nevJ3v9oXJ7Xk1 6x30y0R1QRXXYKAL+Do0hwXHt1Yx1l1tUiB+OjMwbjUR22GMdQcCdq7EmVYxm0MhjULF 65OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702835911; x=1703440711; 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=zjSwC3QXCT9m5wbkVuevhDt7iqPHObPwr4PaZ7/DBvg=; b=OGHcA+EI2+2MZcTgzbC5osMKzrrLJq/nncY2uYvNW7t05Ko7k8Qf55uN1ixBYgGYL3 UYrLAsN0OHcl8yIoVHa+ReWT+zNZNOp56vcE1korbDlWasfpZzCp4zV/qmso3JApfaDb xww3e9y9BNrrxzRTHYeoxLCOi5dHENC4OtndyPNRLvEcYWC0VV5jGzJ95DtcW2xX5xlH 6kxkVvR7SsPARRfWInikohBloX+LAgb6D42yu39mF7ACFiJF2OviyaTQehCtl0Dy31+n zXjCuZUJX7U3CK+JLuPBvSqZZLWUsDYBcBKcUl9yo9UqLcxyQXQt1+65SN8mWNBD2Nm5 R4SA== X-Gm-Message-State: AOJu0YxowZCQxqsgFLgdqhCv97HbY+K29fi6KlgmjecyjrtWqnJyxjN5 LMRKclwkL/Uex7rQu/WqNkPJqw== X-Received: by 2002:a05:600c:350c:b0:40c:2990:45c7 with SMTP id h12-20020a05600c350c00b0040c299045c7mr8164302wmq.86.1702835910479; Sun, 17 Dec 2023 09:58:30 -0800 (PST) Received: from airbuntu (host86-135-101-43.range86-135.btcentralplus.com. [86.135.101.43]) by smtp.gmail.com with ESMTPSA id q12-20020a05600c46cc00b0040b4c59f133sm38711691wmo.1.2023.12.17.09.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 09:58:30 -0800 (PST) Date: Sun, 17 Dec 2023 17:58:29 +0000 From: Qais Yousef To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, wvw@google.com Subject: Re: [PATCH v5 03/23] PM: EM: Find first CPU active while updating OPP efficiency Message-ID: <20231217175829.a6hqz7mqlvrujsvs@airbuntu> References: <20231129110853.94344-1-lukasz.luba@arm.com> <20231129110853.94344-4-lukasz.luba@arm.com> 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: <20231129110853.94344-4-lukasz.luba@arm.com> On 11/29/23 11:08, Lukasz Luba wrote: > The Energy Model might be updated at runtime and the energy efficiency > for each OPP may change. Thus, there is a need to update also the > cpufreq framework and make it aligned to the new values. In order to > do that, use a first active CPU from the Performance Domain. This is > needed since the first CPU in the cpumask might be offline when we > run this code path. I didn't understand the problem here. It seems you're fixing a race, but the description is not clear to me what the race is. > > Signed-off-by: Lukasz Luba > --- > kernel/power/energy_model.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > index 42486674b834..aa7c89f9e115 100644 > --- a/kernel/power/energy_model.c > +++ b/kernel/power/energy_model.c > @@ -243,12 +243,19 @@ em_cpufreq_update_efficiencies(struct device *dev, struct em_perf_state *table) > struct em_perf_domain *pd = dev->em_pd; > struct cpufreq_policy *policy; > int found = 0; > - int i; > + int i, cpu; > > if (!_is_cpu_device(dev) || !pd) > return; > > - policy = cpufreq_cpu_get(cpumask_first(em_span_cpus(pd))); > + /* Try to get a CPU which is active and in this PD */ > + cpu = cpumask_first_and(em_span_cpus(pd), cpu_active_mask); > + if (cpu >= nr_cpu_ids) { > + dev_warn(dev, "EM: No online CPU for CPUFreq policy\n"); > + return; > + } > + > + policy = cpufreq_cpu_get(cpu); Shouldn't policy be NULL here if all policy->realted_cpus were offlined? Cheers -- Qais Yousef > if (!policy) { > dev_warn(dev, "EM: Access to CPUFreq policy failed\n"); > return; > -- > 2.25.1 >