Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp918147lql; Tue, 12 Mar 2024 01:45:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhhsTg1yaRgjtFZbzPMQKdkGoKFtjjVmVHgQMw4QGO/p21mpILSCLzF+UEgyssr4w2U762Uq11fCkRjYSzYshBn0iB1wblzaLLDiXDKA== X-Google-Smtp-Source: AGHT+IFVgcXJ9PV97iP+cKpVQQ1PZ1kRKPJOjSTcejjDWoZthL4Eid0XPiK+j8HnIB+fmt3JTh/V X-Received: by 2002:a05:6808:2013:b0:3c2:50c3:9c85 with SMTP id q19-20020a056808201300b003c250c39c85mr4178217oiw.3.1710233149977; Tue, 12 Mar 2024 01:45:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710233149; cv=pass; d=google.com; s=arc-20160816; b=c4VyzYxltnc1lsE862QM1b5+DJO0wIpT4jSZ6QZO3dWlhuV4XWc2bFnxao6tcqxym2 0zDnl3TrbGR5igs/tbt1GY77DqMTItQKqpOzqh3J2XoRfoYCscJACa3g74p3p30N00Pu ePB6LL8qeJf/yROC9vRdan3O6XjLThjzTqeo62ceXaQqSH0dD2m85Kznmb6e/oqr8p1O gV9x6dg3Z3bA6E1IbwYm3GH2F5ZHPGLLfXGuzIIbFD/0eM2Sp3h3R7kSFec9MHEQ4XGD YLQL5XCEOzTgRnQC+kMm/S6FKNMiJvNVWHy13QKW0vkJLdJgi2ODRQp6+uQSWgjetNy+ i9Ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=MXhgks/2GbIu9RcHXZSQaIt/5SC3W102WA1ZtFrvjuM=; fh=LW+OfeNDQjezAS4DPQuG01kkkO7811u6of5q8gYgh08=; b=vCoJCesyeZmbGtGt7aIX2kmGua4ow42zD6WV1NTs+hGFIR+WrBYRzwHOOCiHPm0ZPr Niwq75+tiTZtTSZb62bBMesvLWVtJktGrTa9tbACvE9+1gMLS7X2hWoemopBSObvNI3b A0h4Kh+Blc9OWY14bf17mPobhUozmdTwblRG0stEnLCbi9AI3ysQWujTIak1hsMjokbU 2dyxfOkHJDMsAUh4zOGPUQ2qm4L4IO2hcSF+8OZYJMPDPs729g0yt/kuYl8Z5UeUNqlt FZZucW6wI65UsGFGhchAVGKSBli4VM+DCSVREVl8U8FKQe0rbesshZ2hyjfBnVTdRZho wLlw==; 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-99963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99963-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay16-20020a056a00301000b006e68c846481si4166072pfb.393.2024.03.12.01.45.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 01:45:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-99963-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99963-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A0B3C281A83 for ; Tue, 12 Mar 2024 08:45:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5282E77F1C; Tue, 12 Mar 2024 08:45:40 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0918577A0E; Tue, 12 Mar 2024 08:45:37 +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=1710233139; cv=none; b=UD/dMQTAjEikFviFALDA1o78TYK+Izhn981Vf49vH55R+XBVFhZKf+JriZNkzNPNfhOVCA3L/4xoYkEQf6UATgdF5648NpEN4sZRJgXxr42hNVx5b3sYiLaRaYnV1sxvMoIgyUul56du5gIL3UXHn0tgXuLDgs6eBnUVmnsYIH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710233139; c=relaxed/simple; bh=sh38yJG3tCaBIyKt3Moq30fT1P7GQyX2mpE8GaX4Wzo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ntfx0MeqHSgr3tJt7BbEk2mVbXFWFBHv0w0Qap38YW0rPybeCCp6Kp/msP/FjRI6aYz2IoW3gMk+YcgUe+vXVUhRv/qUMHS9nnKlDBbTnXhd1dclt7wd4MDgcNeWKG8DXbOJuatfvY9a1TySW5BPYfAVNPyauGhr1rfOl6Pxkc8= 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 772891007; Tue, 12 Mar 2024 01:46:14 -0700 (PDT) Received: from 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 BC9F73F73F; Tue, 12 Mar 2024 01:45:33 -0700 (PDT) Date: Tue, 12 Mar 2024 09:44:52 +0100 From: Beata Michalska To: Vanshidhar Konda Cc: "lihuisong (C)" , Ionela Voinescu , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rafael@kernel.org, sumitg@nvidia.com, zengheng4@huawei.com, yang@os.amperecomputing.com, will@kernel.org, sudeep.holla@arm.com, liuyonglong@huawei.com, zhanjie9@hisilicon.com, linux-acpi@vger.kernel.org Subject: Re: Re: [PATCH v1 2/3] arm64: idle: Cache AMU counters before entering idle Message-ID: References: <20240229162520.970986-1-vanshikonda@os.amperecomputing.com> <20240229162520.970986-3-vanshikonda@os.amperecomputing.com> <3ed907bf-9526-3a46-41b9-8a0c747122f1@huawei.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 Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Mar 11, 2024 at 11:27:27AM -0700, Vanshidhar Konda wrote: > On Thu, Mar 07, 2024 at 11:17:26AM +0800, lihuisong (C) wrote: > > > > 在 2024/3/1 0:25, Vanshidhar Konda 写道: > > > AMU counters do not increment while a CPU is in idle. Saving the value > > > of the core and constant counters prior to invoking WFI allows FIE to > > > compute the frequency of a CPU that is idle. > > > > > > Signed-off-by: Vanshidhar Konda > > > --- > > > arch/arm64/kernel/idle.c | 10 ++++++++++ > > > arch/arm64/kernel/topology.c | 14 ++++++++------ > > > 2 files changed, 18 insertions(+), 6 deletions(-) > > > > > > diff --git a/arch/arm64/kernel/idle.c b/arch/arm64/kernel/idle.c > > > index 05cfb347ec26..5ed2e57188a8 100644 > > > --- a/arch/arm64/kernel/idle.c > > > +++ b/arch/arm64/kernel/idle.c > > > @@ -26,6 +26,16 @@ void __cpuidle cpu_do_idle(void) > > > arm_cpuidle_save_irq_context(&context); > > > +#ifdef CONFIG_ARM64_AMU_EXTN > > > + /* Update the AMU counters before entering WFI. The cached AMU counter > > > + * value is used to determine CPU frequency while the CPU is idle > > > + * without needing to wake up the CPU. > > > + */ > > > + > > > + if (cpu_has_amu_feat(smp_processor_id())) > > > + update_freq_counters_refs(); > > > +#endif > > The below point I has mentioned in [1]. > > This is just for the WFI state. > > What about other deeper idle states, like retention and power down? > > The path to enter idle state is different for them. We should do this > > for all idle states. > > > > Yes. That makes sense. I'll account for them in the next version of the > patch. I'll work on the next version of the patch based on the updated > patch from @Beata. > This should now be covered by [1] --- [1]https://lore.kernel.org/all/20240312083431.3239989-4-beata.michalska@arm.com/ --- BR Beata > Thanks, > Vanshi > > > > + > > > dsb(sy); > > > wfi(); > > > diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c > > > index db8d14525cf4..8905eb0c681f 100644 > > > --- a/arch/arm64/kernel/topology.c > > > +++ b/arch/arm64/kernel/topology.c > > > @@ -240,13 +240,15 @@ unsigned int arch_freq_get_on_cpu(int cpu) > > > } while (read_seqcount_retry(&cpu_sample->seq, seq)); > > > /* > > > - * Bail on invalid count and when the last update was too long ago, > > > - * which covers idle and NOHZ full CPUs. > > > + * Bail on invalid count and when the last update was too long ago. > > > + * This covers idle, NOHZ full and isolated CPUs. > > > + * > > > + * Idle CPUs don't need to be measured because AMU counters stop > > > + * incrementing during WFI/WFE. > > > */ > > > - if (!delta_const_cnt || ((jiffies - last) > MAX_SAMPLE_AGE)) { > > > - if (!(housekeeping_cpu(cpu, HK_TYPE_TICK) && idle_cpu(cpu))) > > > - goto fallback; > > > - } > > > + if (!delta_const_cnt || > > > + ((jiffies - last) > MAX_SAMPLE_AGE && !idle_cpu(cpu))) > > > + goto fallback; > > > /* > > > * CPU frequency = reference perf (in Hz) * (/\ delivered) / (/\ reference) > > [1] https://lore.kernel.org/linux-arm-kernel/20231212072617.14756-1-lihuisong@huawei.com/ > >