cpufreq Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: Borislav Petkov <bp@amd64.org>
Cc: "cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
	"linux@dominikbrodowski.net" <linux@dominikbrodowski.net>,
	Len Brown <len.brown@intel.com>
Subject: Re: [PATCH 5/5] cpupowerutils: Introduce -b/-t --boost/--turbo cpufreq-info param
Date: Tue, 5 Oct 2010 17:18:06 +0200	[thread overview]
Message-ID: <201010051718.07081.trenn@suse.de> (raw)
In-Reply-To: <20101005144717.GA20505@aftab>

On Tuesday 05 October 2010 16:47:17 Borislav Petkov wrote:
> From: Thomas Renninger <trenn@suse.de>
> Date: Tue, Oct 05, 2010 at 08:23:14AM -0400
> 
> > Prints out this by default (also works with --cpu X param):
> >   Analyzing Boost Capabilities on CPU 0:
> >   Supported: yes
> >   Active: yes
> 
> I think it would be simpler if you dump the boosting information in
> cpufreq-info, i.e. without an explicit --boost option or whatever. You
> can then use the "--boost" option to control the boosting like this:
> 
> cpufreq-set --boost (on|off) - toggles boosting
Yep, I like to add this next.

> > With activation one has to be careful...
> > On AMD, it's enough if any of the CPUs shows "Active: no" and boost mode
> > is not active (cmp with powernow-k8 kernel code).
> 
> yes. But we keep it consistent so that all cores show either off or on.
I am still not sure whether cpufreq-info should access this through
/sys/devices/system/cpu/cpu0/cpufreq/cpb
or directly via msr.

Hm, if it's accessed via /sys/..cpufreq/cpb it should be enough to only touch
CPU0, right? The rest is done by powernow-k8.

I don't like cpb much. It's the only file that has no info in it's name.
There should have been a general interface:
boost_mode
supporting AMD and Intel...
Possibly this can still be done and cpb can get marked deprecated
(it shows up in 2.6.36 the first time? Which is not released yet?
Theoretically this is not part of the ABI yet...).

> > to enable/disable turbo/boost mode.
> > 
> > For AMD there already is:
> > /sys/devices/system/cpu/cpu0/cpufreq/cpb
> > but this could all get handled in userspace and this recently introduced
> > interface could get removed again.
> 
> I don't think it will be removed soon. Rather, if you use the /sysfs
> interface you need kernel support for it and cpufrequtils might run on
> older kernels which don't have the feature yet. So you want to do all
> the detection/control in userspace, independent from the kernel version.
Hmm, I'd prefer cleaner code (and only differing Intel/AMD once, either in
the kernel or in userspace), but the "you need kernel support for it and
cpufrequtils might run on older kernel" arguement is interesting.
Not sure what is more important. Need to think a bit more about this.
Comments are very welcome.
 
> > Then enabling/disabling could all be done on CPU 0 which cannot be taken
> > offline.
> >   -> To be discussed.
> 
> You need to enable/disable the boosting on AMD by toggling bit 25 in
> MSR_K7_HWCR on all cpus.
Ok.
> 
> > Potentially dangerous is if cores get offlined while boost mode got
> > disbled, then the userspace tool would not be able to enable it again.
> > But as this stuff is meant for debugging and performance measuring
> > only, it should be enough to document this a bit in a manpage...
> 
> You can issue a warning whenever you detect that a subset of the cores
> has been offlined. Then the tool should fail changing the boosting
> state, IMHO.
Good idea.

...
> > +	} else if (cpu_info.vendor == X86_VENDOR_AMD) {
> > +		if (cpu_info.ext_cpuid_level < 0x80000007)
> > +			return 0;
> > +		if ((cpuid_edx(0x80000007) >> 9) & 0x1)
> > +			*support = 1;
> > +		else
> > +			return 0;
> 
> wrap this in amd_has_boost_support()?
Yep, after splitting out cpuid.c, this could get put into:
cpuid_amd_has_boost_support.
...
> > +int msr_amd_boost_is_active(unsigned int cpu)
> > +{
> > +	uint64_t k7_hwcr;
> > +	int ret;
> > +
> > +	ret = read_msr(cpu, MSR_K7_HWCR, &k7_hwcr);
> > +	if (ret)
> > +		return ret;
> > +	return !((k7_hwcr >> 25) & 0x1);
> > +}
> 
> This should be done differently on AMD: we want to
> iterate over all cores and check this bit and see
> whether its setting is consistent. See how it is done in
> <arch/x86/kernel/cpu/cpufreq/powernow-k8.c::powernowk8_init()> in the
> kernel.
Yep and this is why the whole code should either sit in userspace
or in the kernel, duplicating the code would be stupid.
IMO it should be in userspace, it's just for debugging/monitoring, etc.
and if it's not too late already cpb sysfs file should better vanish...

      Thomas

  parent reply	other threads:[~2010-10-05 15:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 12:23 cpupowerutils: easier use of msr and cpuid stuff and some more Thomas Renninger
2010-10-05 12:23 ` [PATCH 1/5] cpupowerutils: Move read_msr from cpufreq-aperf.c into own /lib/msr.c file Thomas Renninger
2010-10-05 12:23 ` [PATCH 2/5] cpupowerutils: Let older tools make use of global read_msr functions Thomas Renninger
2010-10-05 12:23 ` [PATCH 3/5] cpupowerutils: Move utils/cpuid.h to lib/cpuid.h Thomas Renninger
2010-10-05 12:38   ` Thomas Renninger
2010-10-05 12:23 ` [PATCH 4/5] cpupowerutils: Add get_cpu_info(..) func to cpuid.h Thomas Renninger
2010-10-05 14:09   ` [PATCH] cpupowerutils: Add get_cpu_info(..) func to cpuid.h V2 Thomas Renninger
2010-10-05 12:23 ` [PATCH 5/5] cpupowerutils: Introduce -b/-t --boost/--turbo cpufreq-info param Thomas Renninger
2010-10-05 13:25   ` Mattia Dongili
2010-10-05 13:43     ` Thomas Renninger
2010-10-05 14:47   ` Borislav Petkov
2010-10-05 14:52     ` Dominik Brodowski
2010-10-05 15:10       ` Borislav Petkov
2010-10-05 15:18     ` Thomas Renninger [this message]
2010-10-05 15:56       ` Borislav Petkov
2010-10-13 21:17         ` Thomas Renninger
2010-10-14  4:44           ` Borislav Petkov
2010-10-05 14:15 ` cpupowerutils: easier use of msr and cpuid stuff and some more Dominik Brodowski
2010-10-05 14:37   ` Thomas Renninger
2010-10-05 14:43     ` Dominik Brodowski

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=201010051718.07081.trenn@suse.de \
    --to=trenn@suse.de \
    --cc=bp@amd64.org \
    --cc=cpufreq@vger.kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux@dominikbrodowski.net \
    /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