lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0f19dba47d9b86e79ba043018c4d5d13e4e4425b.camel@suse.cz>
Date:   Mon, 23 May 2022 11:56:00 +0200
From:   Giovanni Gherdovich <ggherdovich@...e.cz>
To:     Dave Hansen <dave.hansen@...el.com>,
        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 Fri, 2022-05-20 at 09:44 -0700, Dave Hansen wrote:
> 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.

Thanks for having a look! You're right. I need to either check these
return values, or not have them at all.

> 
> 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.

That's good advice. I'll do that consolidation.

> 
> 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.


Thanks,
Giovanni

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ