Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4821763ioa; Wed, 27 Apr 2022 11:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTiYHCH2XgcxycXgZdgCPfAAIDPFASNtYDrS2WlTkqqDLixl3WkcErRhK3yoE7UpVBQVPQ X-Received: by 2002:a63:e048:0:b0:39c:c3a3:cfb5 with SMTP id n8-20020a63e048000000b0039cc3a3cfb5mr25202070pgj.579.1651085530089; Wed, 27 Apr 2022 11:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651085530; cv=none; d=google.com; s=arc-20160816; b=x1bXAo9piQmJebqLR3+nzG6WXuY39ySoYCTMzMDKmQIfqQN/mqiq9JIquS5Fq47GBZ oiGF3p8zCqFwgbuFCAPxltZkioo7OWQMhVFyPIRGkYcq66CPfRpYeLeTzxVI/NM1pv4H to81rmISYirD7DLfR6gWMvXCSNoRh6V0nhg4TOnemsPPPLvJfAx6oQZM60Xch7y7C+Lj bE5wBQqxtkRV4fdC0WMlUFHl9+ZcMFmJbB/GIfLaD8e9E+9awrlirF/3s96Lb76aVjbo Gv8LFv1RYEhY13kq+uunqbLiJSFFknLSa/g0t8D+GP1etk1NPPN3vNP7UsRURypwPpCi 2PWQ== 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=EEgFvAkQSB8xlRo9PgqHLJRCeY0iIIXGnavqlRm0dUQ=; b=uFTrQ9bf18BhUkbaGiBqKKNw4ds5S20eFqKMJKqkeoXfO+8Mp3duVjZOhnDFX/RHE8 +b4Sa3COr26vWU1CWcm3PnF3Zz77dha76qGz23ONQ+rbPFDytEIb3SXQ7yw2BKhUhKE5 CO3Hb23Ykqbs+JpwNJ1iXtBf6mFNvmH3vOllXHF88ZW/UXif8MMbIvcZGlYiGZjclBt1 zgDm2kascOnHjfDwZLVC4I6zRjeYDp0nNPzQRJy10X4YxQBG9Zzh836QirhvzD7MhDCc BGYCYqkrHxCioCOgRQiY9FdkZCM3jkKmoOIKuh03ux0N9ReSr7XvxuaRKaPlwITSB5Nb ap2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=S+i+LOBw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=I+ONisyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a656b87000000b003ab1a2b7944si2162263pgw.61.2022.04.27.11.51.53; Wed, 27 Apr 2022 11:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=S+i+LOBw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=I+ONisyi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbiD0Sq0 (ORCPT + 99 others); Wed, 27 Apr 2022 14:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiD0SqG (ORCPT ); Wed, 27 Apr 2022 14:46:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F338F1369; Wed, 27 Apr 2022 11:27:27 -0700 (PDT) Date: Wed, 27 Apr 2022 18:27:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651084046; 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=EEgFvAkQSB8xlRo9PgqHLJRCeY0iIIXGnavqlRm0dUQ=; b=S+i+LOBwWyBCCNyktLQRw/nMjXgK8FkX7tn9cvfIo/7bj6PiLCiY9zydKc8DKxUT+kcal7 plozlh/uiQ/zIUneq0hDTOk+46r5MvE1GFz77pfqI0qTKPjLiDQS3KHemN7VIkjUg4ii+E vXeM8bjgRgmHJ+wp2tZeQEpbGdt8d9zfbFbrm6/FiD1P6Cz4K0mPTTV/KMySFeGG72uV7c dUfNHQv8VnDz/Q+WSN3VwyNctFQt5iSBc3iQHU4mek6DHeVO9GLqvzPdmSG+7Nj0TauLXi I6uaOwlnahctnA3G2axW0QIfN3rCArewVC4w4PuDUMxj9M0rEYjYzD91lQG9yQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651084046; 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=EEgFvAkQSB8xlRo9PgqHLJRCeY0iIIXGnavqlRm0dUQ=; b=I+ONisyiy0Qyn4q245P6YqmxswLZOz5mScqNaOfC8s4507tkMVnp6MGSooI2taN0A+UHOB 92OPasY/7BMX2+DQ== 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: <165108404488.4207.1944029157798373313.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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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: 73a5fa7d51366a549a9f2e3ee875ae51aa0b5580 Gitweb: https://git.kernel.org/tip/73a5fa7d51366a549a9f2e3ee875ae51aa0b5580 Author: Thomas Gleixner AuthorDate: Fri, 15 Apr 2022 21:19:57 +02:00 Committer: Thomas Gleixner CommitterDate: Wed, 27 Apr 2022 20:22:19 +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 */