mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Giovanni Gherdovich <ggherdovich@suse.cz>,
	Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] x86: fix platform info detection in frequency invariance
Date: Fri, 20 May 2022 09:44:25 -0700	[thread overview]
Message-ID: <7dffbd70-d7db-6d58-abbb-19006cd9e4a2@intel.com> (raw)
In-Reply-To: <20220520161022.5972-2-ggherdovich@suse.cz>

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.

  reply	other threads:[~2022-05-20 16:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 16:10 [PATCH 1/2] x86: Fix return value in frequency invariance setup for XEON_PHI_KNL/KNM Giovanni Gherdovich
2022-05-20 16:10 ` [PATCH 2/2] x86: fix platform info detection in frequency invariance Giovanni Gherdovich
2022-05-20 16:44   ` Dave Hansen [this message]
2022-05-23  9:56     ` Giovanni Gherdovich
2022-05-21 10:02 ` [PATCH 1/2] x86: Fix return value in frequency invariance setup for XEON_PHI_KNL/KNM Peter Zijlstra
2022-05-23  9:57   ` Giovanni Gherdovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dffbd70-d7db-6d58-abbb-19006cd9e4a2@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dan.carpenter@oracle.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=ggherdovich@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome