Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4610843ioa; Wed, 27 Apr 2022 07:27:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrXAxCggi8/wZtKwrlqOJWB6u9NQf3pFCSASSmvpXd2IiDY3nb2zgykpHAx97y/61iHMrY X-Received: by 2002:a17:903:32d2:b0:15d:57c7:9eef with SMTP id i18-20020a17090332d200b0015d57c79eefmr2667116plr.2.1651069636723; Wed, 27 Apr 2022 07:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651069636; cv=none; d=google.com; s=arc-20160816; b=AbF7PzAXabNRYNN3fI61r2Vmj5Qj2DUKxG9cb2p714mVQmNR9LtMj5oReF3zw/e5fQ e7hA5zZm45PpYC7Cmoow5CbnwpgYGAeGcJgo9GX0uqWz46rzoldYuoGxCjh9bwRaSEvd rpqdYlZGTLY5JOH4RVr8MiqgGe0agvGF+qWlaJm8SpXHP4/eKugzrxGOQ8r30wtnCzhl TcJqZjBu5gx6qkT2YKcXJn/y3/Ss2IeTHhHjKtF6znKX7gksvz7gCXdyIgu1VWzPvFg8 RSI9I+486bbnVlaPkPX39qJgXnSl2GhRMKRD5iegJYOWS7yJDy/VAa6ycqwBgJSEm2uf WAVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=nD7wqaAXOKu9sWXG9e3/EczN5MVFaW4VaMKCsF1lfYo=; b=t9bX1lt8WA/Ycz2vC6MagDwmYHvMeoX3qhxLmISh80JYZbWbdSLqTe0FMJ7i5ehO2i bvaEk8mhi8E8Ah8GWCz2vcN4S42ALsK6zNZhb7VntZC8cpOAZUatdNBHBM0GJO0dzGGR 88pR4SqaieVlRpIpiooytpJ+O3PFof5aVmw0Sc4tUV60cAgb7BA3WZesNtmXmQSc1Ksg 6IaIi48aroHxI82z2ec8dXI23QNg+S1TbDrDTZRK00rJIwVKkQtWlwZBWYXA8N2k9315 VR00G7kyRdW/WNqw24cDV2GwIPfa0hIZs/C2YaPkR0zqCoIvQNk3H5iHCwOJuSmocl3A 52mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HuTPEjIJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1vt+T052; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w5-20020a63b745000000b003c140043abdsi1734376pgt.90.2022.04.27.07.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 07:27:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HuTPEjIJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=1vt+T052; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A40CC42487; Wed, 27 Apr 2022 06:58:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237081AbiD0OAK (ORCPT + 99 others); Wed, 27 Apr 2022 10:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237028AbiD0N70 (ORCPT ); Wed, 27 Apr 2022 09:59:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD4963C737; Wed, 27 Apr 2022 06:56:13 -0700 (PDT) Date: Wed, 27 Apr 2022 13:56:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651067770; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nD7wqaAXOKu9sWXG9e3/EczN5MVFaW4VaMKCsF1lfYo=; b=HuTPEjIJY3Gy3HA/+2khsW5JSlYGP1mYCc4E4FcxZLky2sYUFUQBzMa0rmeROxR7YKkAT7 uRA9idZ/5QduqMoeO1gaF+pPif5RcwkgRxxbuHu/fKFutKfJkPzosNu6wRqM7grSy/ulXI qYlqs5GHVq9QKdcveBeIcB4uk9lQ/UdU+YnCn8vCMeSuzxAKc7/0djnEjDQJqQXfT4EbPg AtXVGXJt7dlB2aoRAkSmlzXCzgOWbE9TCCaAqjJR+wI+b3g2hzBzfyjDAlM/g2AE91jgFB ZcePY7qK8NvU2ULOxdkdSMhuyBk0KwwNvZWSnoZYuXeZqmsWwKfcDdunuUlq0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651067770; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nD7wqaAXOKu9sWXG9e3/EczN5MVFaW4VaMKCsF1lfYo=; b=1vt+T052p8w7ZnzI02Jdv7TqGjfT9GJVuL7AU9JUSZxuZ36+W6uzOGdo/baZiNXpesR2aD cyaZXjkf/vAgljCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cleanups] x86/aperfmperf: Restructure arch_scale_freq_tick() Cc: Thomas Gleixner , "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , "Paul E. McKenney" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220415161206.706185092@linutronix.de> References: <20220415161206.706185092@linutronix.de> MIME-Version: 1.0 Message-ID: <165106776964.4207.8880773870704437659.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/cleanups branch of tip: Commit-ID: 76225ca3666c5b05afb8dcc18a73f002b097af24 Gitweb: https://git.kernel.org/tip/76225ca3666c5b05afb8dcc18a73f002b097af24 Author: Thomas Gleixner AuthorDate: Fri, 15 Apr 2022 21:19:57 +02:00 Committer: Thomas Gleixner CommitterDate: Wed, 27 Apr 2022 15:51:08 +02:00 x86/aperfmperf: Restructure arch_scale_freq_tick() Preparation for sharing code with the CPU frequency portion of the aperf/mperf code. No functional change. Signed-off-by: Thomas Gleixner Reviewed-by: Rafael J. Wysocki Acked-by: Peter Zijlstra (Intel) Acked-by: Paul E. McKenney Link: https://lore.kernel.org/r/20220415161206.706185092@linutronix.de --- arch/x86/kernel/cpu/aperfmperf.c | 36 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c index 6922c77..6220503 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c @@ -477,22 +477,9 @@ static DECLARE_WORK(disable_freq_invariance_work, DEFINE_PER_CPU(unsigned long, arch_freq_scale) = SCHED_CAPACITY_SCALE; -void arch_scale_freq_tick(void) +static void scale_freq_tick(u64 acnt, u64 mcnt) { - struct aperfmperf *s = this_cpu_ptr(&cpu_samples); - u64 aperf, mperf, acnt, mcnt, freq_scale; - - if (!arch_scale_freq_invariant()) - return; - - rdmsrl(MSR_IA32_APERF, aperf); - rdmsrl(MSR_IA32_MPERF, mperf); - - acnt = aperf - s->aperf; - mcnt = mperf - s->mperf; - - s->aperf = aperf; - s->mperf = mperf; + u64 freq_scale; if (check_shl_overflow(acnt, 2*SCHED_CAPACITY_SHIFT, &acnt)) goto error; @@ -514,4 +501,23 @@ error: pr_warn("Scheduler frequency invariance went wobbly, disabling!\n"); schedule_work(&disable_freq_invariance_work); } + +void arch_scale_freq_tick(void) +{ + struct aperfmperf *s = this_cpu_ptr(&cpu_samples); + u64 acnt, mcnt, aperf, mperf; + + if (!arch_scale_freq_invariant()) + return; + + rdmsrl(MSR_IA32_APERF, aperf); + rdmsrl(MSR_IA32_MPERF, mperf); + acnt = aperf - s->aperf; + mcnt = mperf - s->mperf; + + s->aperf = aperf; + s->mperf = mperf; + + scale_freq_tick(acnt, mcnt); +} #endif /* CONFIG_X86_64 && CONFIG_SMP */