From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
Cc: "Brown, Len" <len.brown@intel.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"Accardi, Kristen C" <kristen.c.accardi@intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH v3 1/6] cpufreq: intel_p_state: Fix limiting turbo sub states
Date: Wed, 07 Oct 2015 01:22:58 +0200 [thread overview]
Message-ID: <4304798.l7TM85pp3T@vostro.rjw.lan> (raw)
In-Reply-To: <1444151263.17895.114.camel@spandruv-desk3.jf.intel.com>
On Tuesday, October 06, 2015 05:08:14 PM Pandruvada, Srinivas wrote:
> On Mon, 2015-10-05 at 17:43 -0700, Srinivas Pandruvada wrote:
> > On Tue, 2015-10-06 at 00:56 +0200, Rafael J. Wysocki wrote:
> [..]
> > > struct vid_data {
> > > @@ -132,6 +133,8 @@ struct pstate_funcs {
> > > int (*get_scaling)(void);
> > > void (*set)(struct cpudata*, int pstate);
> > > void (*get_vid)(struct cpudata *);
> > > + u64 (*get_turbo_ratio_limit)(struct cpudata *);
> > > + int (*set_turbo_ratio_limit)(struct cpudata *, u64, u64);
I've started to wonder about the value of having the second new callback at all.
The guys who need it will always have pstate.turbo_ratio_limit different
from zero, so we can use this check to decide whether or not to write to
the register.
> >
> > An int is always passed as the last arg to this, so why is the arg
> u64?
> >
> It can be int as we care only about low byte which is max turbo ratio.
Hmm.
> > > };
> [..]
> > > Instead of shifting def_ratio and new_ratio in each
> > > step, I'd shift max_ratio and the mask:
> > >
> > > u64 mask = 0xff;
> > > u64 max_ratio = new_ratio & mask;
> > >
> > > while (mask) {
> > > if (def_ratio & mask) {
> > > u64 ratio;
> > >
> > > if (new_ratio & mask) {
So why do we need this?
If we only care about the lowest byte only, we should discard all of the upper
bytes in new_ration here, shouldn't we?
> > > ratio = new_ratio & mask;
> > > } else {
> > > ratio = def_ratio & mask;
> > > if (ratio > max_ratio)
> > > ratio = max_ratio;
> > > }
> > > out_ratio |= ratio;
> > > }
> > > max_ratio <<= 8;
> > > mask <<= 8;
> > > }
> > >
> > I will experiment with your algorithm and check.
> >
> Your algorithm works, so will change to this.
>
> [..]
>
> > > > + if (pstate_funcs.get_turbo_ratio_limit &&
> > > > + !cpu->pstate.turbo_ratio_limit)
> > > > + cpu->pstate.turbo_ratio_limit =
> > > > + pstate_funcs.get_turbo_ratio_limit(cpu);
> > >
> > > So we read MSR_NHM_TURBO_RATIO_LIMIT and store it into pstate.turbo_ratio_limit
> > > unless alread populated. This means we do it only once during initialization.
> > >
> > > What if the value we have in there is stale after, say, system suspend-resume?
> > >
> > Did I mess up here? You mean data stored in a variable
> > cpu->pstate.turbo_ratio_limit is corrupted after suspend/resume. This is
> > a vzalloc memory..
> > all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()) one time
> > during __init intel_pstate_init
> Also all_cpu_data[cpunum] is allocated only once during first cpufreq
> callback for init and not freed
> if (!all_cpu_data[cpunum])
> all_cpu_data[cpunum] = kzalloc(sizeof(struct cpudata),
> GFP_KERNEL);
> Did STR tests, didn't see issue. Not sure how else corruption can happen
> unless slab memory is corrupted. Can you tell how it will be stale?
I was concerned about the BIOS changing the value in the register in which
case we probably should restore what we wrote to it last time or users
may be confused.
Thanks,
Rafael
next prev parent reply other threads:[~2015-10-06 22:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 22:54 [PATCH v3 0/6] Intel P states enhancements Srinivas Pandruvada
2015-09-29 22:54 ` [PATCH v3 1/6] cpufreq: intel_p_state: Fix limiting turbo sub states Srinivas Pandruvada
2015-10-05 22:56 ` Rafael J. Wysocki
2015-10-06 0:43 ` Srinivas Pandruvada
2015-10-06 17:08 ` Pandruvada, Srinivas
2015-10-06 23:22 ` Rafael J. Wysocki [this message]
2015-10-06 23:27 ` Rafael J. Wysocki
2015-09-29 22:54 ` [PATCH v3 2/6] cpufreq: intel_pstate: get P1 from TAR when available Srinivas Pandruvada
2015-10-13 20:34 ` Kristen Carlson Accardi
2015-09-29 22:54 ` [PATCH v3 3/6] cpufreq: intel-pstate: Use separate max pstate for scaling Srinivas Pandruvada
2015-10-13 20:36 ` Kristen Carlson Accardi
2015-09-29 22:54 ` [PATCH v3 4/6] cpufreq: intel_pstate: Use ACPI perf configuration Srinivas Pandruvada
2015-10-13 20:39 ` Kristen Carlson Accardi
2015-09-29 22:54 ` [PATCH v3 5/6] Documentation: kernel_parameters for Intel P state driver Srinivas Pandruvada
2015-10-13 20:39 ` Kristen Carlson Accardi
2015-09-29 22:54 ` [PATCH v3 6/6] cpufreq: intel_pstate: Avoid calculation for max/min Srinivas Pandruvada
2015-10-13 20:41 ` Kristen Carlson Accardi
2015-10-14 0:52 ` [PATCH v3 0/6] Intel P states enhancements Rafael J. Wysocki
2015-10-14 23:15 ` Srinivas Pandruvada
2015-10-14 23:50 ` Rafael J. Wysocki
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=4304798.l7TM85pp3T@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=kristen.c.accardi@intel.com \
--cc=len.brown@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=srinivas.pandruvada@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.