From: "Li, Aubrey" <aubrey.li@linux.intel.com>
To: dirk.brandewie@gmail.com, linux-pm@vger.kernel.org, rjw@rjwysocki.net
Cc: linux-kernel@vger.kernel.org,
Dirk Brandewie <dirk.j.brandewie@intel.com>
Subject: Re: [PATCH 2/5] intel_pstate: remove unneeded sample buffers
Date: Thu, 13 Feb 2014 08:42:10 +0800 [thread overview]
Message-ID: <52FC14E2.6070402@linux.intel.com> (raw)
In-Reply-To: <1392228067-14817-3-git-send-email-dirk.j.brandewie@intel.com>
On 2014/2/13 2:01, dirk.brandewie@gmail.com wrote:
> From: Dirk Brandewie <dirk.j.brandewie@intel.com>
>
> Remove unneeded sample buffers, intel_pstate operates on the most
> recent sample only. This save some memory and make the code more
> readable.
>
> Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
> ---
> drivers/cpufreq/intel_pstate.c | 25 ++++++++++++-------------
> 1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index c788abf..d692b10 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -96,8 +96,7 @@ struct cpudata {
> u64 prev_aperf;
> u64 prev_mperf;
> unsigned long long prev_tsc;
> - int sample_ptr;
> - struct sample samples[SAMPLE_COUNT];
> + struct sample sample;
> };
>
> static struct cpudata **all_cpu_data;
> @@ -570,15 +569,15 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
> rdmsrl(MSR_IA32_MPERF, mperf);
> tsc = native_read_tsc();
To be pikcy, just want the ratio more accurate, since aperf and mperf
are a pair, do you want to turn interrupt off to make sure nothing
occurs between reading aperf and mperf? and since native_read_tsc() is
called here, better to put into no interrupt context as well.
Thanks,
-Aubrey
>
> - cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
> - cpu->samples[cpu->sample_ptr].aperf = aperf;
> - cpu->samples[cpu->sample_ptr].mperf = mperf;
> - cpu->samples[cpu->sample_ptr].tsc = tsc;
> - cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
> - cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
> - cpu->samples[cpu->sample_ptr].tsc -= cpu->prev_tsc;
>
> - intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
> + cpu->sample.aperf = aperf;
> + cpu->sample.mperf = mperf;
> + cpu->sample.tsc = tsc;
> + cpu->sample.aperf -= cpu->prev_aperf;
> + cpu->sample.mperf -= cpu->prev_mperf;
> + cpu->sample.tsc -= cpu->prev_tsc;
> +
> + intel_pstate_calc_busy(cpu, &cpu->sample);
>
> cpu->prev_aperf = aperf;
> cpu->prev_mperf = mperf;
> @@ -598,7 +597,7 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
> {
> int32_t core_busy, max_pstate, current_pstate;
>
> - core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy;
> + core_busy = cpu->sample.core_pct_busy;
> max_pstate = int_tofp(cpu->pstate.max_pstate);
> current_pstate = int_tofp(cpu->pstate.current_pstate);
> return mul_fp(core_busy, div_fp(max_pstate, current_pstate));
> @@ -631,7 +630,7 @@ static void intel_pstate_timer_func(unsigned long __data)
>
> intel_pstate_sample(cpu);
>
> - sample = &cpu->samples[cpu->sample_ptr];
> + sample = &cpu->sample;
>
> intel_pstate_adjust_busy_pstate(cpu);
>
> @@ -712,7 +711,7 @@ static unsigned int intel_pstate_get(unsigned int cpu_num)
> cpu = all_cpu_data[cpu_num];
> if (!cpu)
> return 0;
> - sample = &cpu->samples[cpu->sample_ptr];
> + sample = &cpu->sample;
> return sample->freq;
> }
>
>
next prev parent reply other threads:[~2014-02-13 0:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 18:01 [PATCH 0/5] intel_pstate updates for v3.14-rcX dirk.brandewie
2014-02-12 18:01 ` [PATCH 1/5] intel_pstate: Remove energy reporting from pstate_sample tracepoint dirk.brandewie
2014-02-12 18:01 ` [PATCH 2/5] intel_pstate: remove unneeded sample buffers dirk.brandewie
2014-02-13 0:42 ` Li, Aubrey [this message]
2014-02-12 18:01 ` [PATCH 3/5] intel_pstate: fix pid_reset to use fixed point values dirk.brandewie
2014-02-12 18:01 ` [PATCH 4/5] intel_pstate: Use LFM bus ratio as min ratio/P state dirk.brandewie
2014-02-19 0:58 ` Rafael J. Wysocki
2014-02-19 18:35 ` [PATCH v2] " dirk.brandewie
2014-02-20 0:44 ` Rafael J. Wysocki
2014-02-12 18:01 ` [PATCH 5/5] intel_pstate: Add support for Baytrail turbo P states dirk.brandewie
2014-02-13 0:47 ` [PATCH 0/5] intel_pstate updates for v3.14-rcX Rafael J. Wysocki
2014-02-13 1:00 ` Rafael J. Wysocki
2014-02-13 1:23 ` Rafael J. Wysocki
2014-02-18 20:29 ` Dirk Brandewie
2014-02-18 22:27 ` Rafael J. Wysocki
2014-02-18 23:53 ` Dirk Brandewie
2014-02-19 0:34 ` Rafael J. Wysocki
[not found] ` <CANOOhLToR8ajjiM1x7m_4Pbak3sUkjfq0h4EX6dz1U23D3X3EA@mail.gmail.com>
2014-02-19 0:43 ` Rafael J. Wysocki
2014-02-19 0:35 ` Dirk Brandewie
2014-02-19 0:53 ` Rafael J. Wysocki
2014-02-19 18:26 ` Dirk Brandewie
2014-02-20 0:43 ` 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=52FC14E2.6070402@linux.intel.com \
--to=aubrey.li@linux.intel.com \
--cc=dirk.brandewie@gmail.com \
--cc=dirk.j.brandewie@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.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;
as well as URLs for NNTP newsgroup(s).