[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7dffbd70-d7db-6d58-abbb-19006cd9e4a2@intel.com>
Date: Fri, 20 May 2022 09:44:25 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Giovanni Gherdovich <ggherdovich@...e.cz>,
Borislav Petkov <bp@...en8.de>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] x86: fix platform info detection in frequency
invariance
On 5/20/22 09:10, Giovanni Gherdovich wrote:
> if (slv_set_max_freq_ratio(&base_freq, &turbo_freq))
> goto out;
>
> - if (x86_match_cpu(has_glm_turbo_ratio_limits) &&
> - skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
> + if (x86_match_cpu(has_glm_turbo_ratio_limits)) {
> + skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1);
> goto out;
> + }
>
> - if (x86_match_cpu(has_knl_turbo_ratio_limits) &&
> - knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1))
> + if (x86_match_cpu(has_knl_turbo_ratio_limits)) {
> + knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1);
> goto out;
> + }
>
> - if (x86_match_cpu(has_skx_turbo_ratio_limits) &&
> - skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4))
> + if (x86_match_cpu(has_skx_turbo_ratio_limits)) {
> + skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4);
> goto out;
> + }
>
> if (core_set_max_freq_ratio(&base_freq, &turbo_freq))
> goto out;
But didn't the last patch in the series carefully change the return
value for knl_set_max_freq_ratio()? Now, the only call site is ignoring
the return value? That seems odd.
Also, this is a mess. These constructs:
static const struct x86_cpu_id has_knl_turbo_ratio_limits[] = {
X86_MATCH(XEON_PHI_KNL),
X86_MATCH(XEON_PHI_KNM),
{}
};
static const struct x86_cpu_id has_skx_turbo_ratio_limits[] = {
X86_MATCH(SKYLAKE_X),
{}
};
static const struct x86_cpu_id has_glm_turbo_ratio_limits[] = {
X86_MATCH(ATOM_GOLDMONT),
X86_MATCH(ATOM_GOLDMONT_D),
X86_MATCH(ATOM_GOLDMONT_PLUS),
{}
};
are rather goofy. A single array like rapl_ids[] that points to the
handler function would do us a lot more good here, say:
static const struct x86_cpu_id has_knl_turbo_ratio_limits[] = {
X86_MATCH(XEON_PHI_KNL, &knl_set_max_freq_ratio),
X86_MATCH(XEON_PHI_KNM, &knl_set_max_freq_ratio),
X86_MATCH(SKYLAKE_X, &skx_set_max_freq_ratio),
X86_MATCH(ATOM_GOLDMONT, &skx_set_max_freq_ratio),
X86_MATCH(ATOM_GOLDMONT_D, &skx_set_max_freq_ratio),
X86_MATCH(ATOM_GOLDMONT_PLUS, &skx_set_max_freq_ratio),
X86_MATCH(ANY, &core_set_max_freq_ratio),
{}
};
That would get rid of all the goofy gotos and actually puts all the
logic in one place. BTW, I'm not 100% sure about the 'ANY' line. I
think that's how those work, but please double-check me on it.
While it's generally best to keep bug fixes to a minimum, I think this
one is worth a bit of a cleanup because it will remove a bunch of spaghetti.
Powered by blists - more mailing lists