From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E16ECC55ABD for ; Tue, 10 Nov 2020 18:45:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92CE120809 for ; Tue, 10 Nov 2020 18:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgKJSp2 (ORCPT ); Tue, 10 Nov 2020 13:45:28 -0500 Received: from mx2.suse.de ([195.135.220.15]:49622 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgKJSp2 (ORCPT ); Tue, 10 Nov 2020 13:45:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8ABCCABD1; Tue, 10 Nov 2020 18:45:26 +0000 (UTC) Message-ID: <1605033925.14855.15.camel@suse.cz> Subject: Re: [PATCH 1/3] x86, sched: Calculate frequency invariance for AMD systems From: Giovanni Gherdovich To: Peter Zijlstra Cc: Borislav Petkov , Thomas Gleixner , Ingo Molnar , Len Brown , "Rafael J . Wysocki" , Jon Grimm , Nathan Fontenot , Yazen Ghannam , Thomas Lendacky , Mel Gorman , Pu Wen , Viresh Kumar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Doug Smythies , x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Date: Tue, 10 Nov 2020 19:45:25 +0100 In-Reply-To: <20201110094956.GZ2594@hirez.programming.kicks-ass.net> References: <20201110083936.31994-1-ggherdovich@suse.cz> <20201110083936.31994-2-ggherdovich@suse.cz> <20201110094956.GZ2594@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Tue, 2020-11-10 at 10:49 +0100, Peter Zijlstra wrote: > On Tue, Nov 10, 2020 at 09:39:34AM +0100, Giovanni Gherdovich wrote: > > > +#ifdef CONFIG_ACPI > > +void init_freq_invariance_cppc(void) > > +{ > > + init_freq_invariance(false, true); > > + > > + if (static_branch_likely(&arch_scale_freq_key)) > > + on_each_cpu(init_counter_refs, NULL, 0); > > +} > > +#endif > > + > > static void disable_freq_invariance_workfn(struct work_struct *work) > > { > > static_branch_disable(&arch_scale_freq_key); > > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c > > index 7a99b19bb893..e1969ff876ff 100644 > > --- a/drivers/acpi/cppc_acpi.c > > +++ b/drivers/acpi/cppc_acpi.c > > @@ -39,6 +39,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -850,6 +851,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) > > goto out_free; > > } > > > > + /* Only needed once, so call on CPU0 */ > > + if (pr->id == 0) > > + init_freq_invariance_cppc(); > > + > > This seems broken vs lovely things like booting with maxcpus= or > physical hotplug where you add logical CPUs. Right. > > Given the latter hunk limits it to one invocation (is phys_id 0 > guaranteed to exist? Can a BIOS monkey screw us over?) only to then call > it on all CPUs, shouldn't this be changed to let > acpi_cppc_processor_probe() call it for every CPU that comes online? I sent a V2 that basically does that, it just makes sure that "init_freq_invariance(secondary=false)" is called only once (the first CPU that gets there), and init_counter_refs() instead is called by all. Which makes me think, I could make better use of the "secondary" argument to init_freq_invariance() and trim a couple of lines from init_freq_invariance_cppc(). Giovanni