Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp914716lql; Tue, 12 Mar 2024 01:35:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWApssXLwd//nBsVXar5fleFpDqy/KrKuFVpYzqEl/YZeIvj8vVtnktz/K9ApwwF30thc9XKUB50K6uaZRwhrG6BL4kQxzRIu6cbcvPbQ== X-Google-Smtp-Source: AGHT+IH0EnCmvlIafME5pRd8fMNlRfAH4CUmE8QQUaGfe2ECQmT+a2QGqiM75NZewGrmYY2c+X/f X-Received: by 2002:a0c:c24a:0:b0:690:9e6d:efe9 with SMTP id w10-20020a0cc24a000000b006909e6defe9mr14635620qvh.27.1710232551092; Tue, 12 Mar 2024 01:35:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710232551; cv=pass; d=google.com; s=arc-20160816; b=DEKKpZ0BhBeC/A8dbYTs9A+nE/lWjpoDtueyQ2Pm6Uh8pj43AuGwS43fWkuI//bJ9k cB0lqoMyT4yz1wUZZnSgEwWbVsemJUykusrVxMHBuSqaJyQkRdhdanqc+LfWNc752i9O 3vcvrQhrkAMqaXvtAB3zDr/xJjt+RwJT5HbMgNIgGxjb9tH6jZSdijHALdlc18CLdYBj U3AhPtjtmGOuOZZUmhtrixIH32s55BMrb6aX08/6XS2GPoiH9J6Hmwm1YpZf3XJsxVAp PhyB0Fz9SSEutQsbMy99O9dH31ApCN3vQ006PONDg1aprZABHv492TWNl+zohE1X11dg EBXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=AS/Iaytr2bFuZXefyGDbblOhOhkI9OtqIuaM7jq/BSs=; fh=cyDp+t11qGExQGVvcee9BaXo/5kV7bnnsUJA2sJhI3s=; b=CGr4sLgt6DnySJMbTCFqsaatrlEJ3cMnIxPiRndpY7NoTfkOrLsBrqTJRAMpYhool6 0xpLoodcqx30pDHltbdnpMo8bwfSeqWvARSWpgrK/eXwe6UdfWxd7Q0QhfNcZhYHiXhc +0iCsmsNaPKNlGMkxeDGk/pgEVsW6d+diFMTq9mw98RiEMDDBjX5bC11cdTGDOdhjUHB EawjShurFcnfQFGsH478S/tPBuPVXBeq+dhwHk6D4Ziaa/yhwXr/Q9hRDGvBkac9xlzQ TXwuHHhnYFtbpR6oRtz3qay5K0S+u69YXgSCLqflup6m7VPOeByD1tuwwo8Xh4qcc+Cy 36Dw==; 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-99955-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99955-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jl13-20020ad45e8d000000b0068fcd6af30bsi7443283qvb.414.2024.03.12.01.35.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 01:35:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99955-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-99955-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99955-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AC7EA1C216DE for ; Tue, 12 Mar 2024 08:35:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E645878270; Tue, 12 Mar 2024 08:35:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC44377F2F for ; Tue, 12 Mar 2024 08:35:12 +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=1710232514; cv=none; b=l2lQ2F9udIDpM2o2azIcApy/wAA8olKJ8ETufvYuRBaSuw9Yb4OuBvs7XvzHvq8dUtHxHTSpj5SXenoSs/NQQbd4awF9F8sIuwMUSszYBIrCDUUv/RFgxRCufwJTxFdg1qMk8eQKVUmrIuupJM7bRzSgI2ESWbx81+9q1QlOAVY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710232514; c=relaxed/simple; bh=obNxM+jdCswBMQq3mcAD9vZ6SCw4b+ZDqGiuc200Y2s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CcH6zcOfGYDzq6ymC0rUVxonSuIG6WlJg3GAiFnU6BM9JDsxItNx1d2lN/CEwBpY7Yxql3tIk0JNAN6yvSdfRtOJbKck4ZwHFNUsXrFnrEr2MuI7REM4gyIus4DyEhD9GwvpBfDV7lvbWkaGWcXjrjIFnOWAPW0C8M8GedaoYV8= 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 2AE8515A1; Tue, 12 Mar 2024 01:35:49 -0700 (PDT) Received: from e125905.cambridge.arm.com (e125905.cambridge.arm.com [10.1.194.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 54A093F73F; Tue, 12 Mar 2024 01:35:10 -0700 (PDT) From: Beata Michalska To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ionela.voinescu@arm.com, vanshikonda@os.amperecomputing.com Cc: sudeep.holla@arm.com, will@kernel.org, catalin.marinas@arm.com, vincent.guittot@linaro.org, sumitg@nvidia.com, yang@os.amperecomputing.com, lihuisong@huawei.com Subject: [PATCH v3 3/3] arm64: Update AMU-based frequency scale factor on entering idle Date: Tue, 12 Mar 2024 08:34:31 +0000 Message-Id: <20240312083431.3239989-4-beata.michalska@arm.com> In-Reply-To: <20240312083431.3239989-1-beata.michalska@arm.com> References: <20240312083431.3239989-1-beata.michalska@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that the frequency scale factor has been activated for retrieving current frequency on a given CPU, trigger its update upon entering idle. This will, to an extent, allow querying last known frequency in a non-invasive way. It will also improve the frequency scale factor accuracy when a CPU entering idle did not receive a tick for a while. Suggested-by: Vanshidhar Konda Signed-off-by: Beata Michalska --- arch/arm64/kernel/topology.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 42cb19c31719..77c6ac577cef 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -215,6 +215,18 @@ static struct scale_freq_data amu_sfd = { .set_freq_scale = amu_scale_freq_tick, }; +void arch_cpu_idle_enter(void) +{ + unsigned int cpu = smp_processor_id(); + + if (!cpumask_test_cpu(cpu, amu_fie_cpus)) + return; + + /* Kick in AMU update but only if one has not happned already */ + if (time_is_before_jiffies(per_cpu(cpu_amu_samples.last_update, cpu))) + amu_scale_freq_tick(); +} + #define AMU_SAMPLE_EXP_MS 20 unsigned int arch_freq_get_on_cpu(int cpu) @@ -242,7 +254,8 @@ unsigned int arch_freq_get_on_cpu(int cpu) * try an alternative source for the counters (and thus freq scale), * if available for given policy */ - if (time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP_MS))) { + if (!idle_cpu(cpu) && + time_is_before_jiffies(last_update + msecs_to_jiffies(AMU_SAMPLE_EXP_MS))) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); int ref_cpu = nr_cpu_ids; -- 2.25.1