All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Zhang Rui <rui.zhang@intel.com>
Cc: Matt Fleming <matt@console-pimps.org>,
	"Lin, Ming M" <ming.m.lin@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"acme@redhat.com" <acme@redhat.com>,
	linux-pm <linux-pm@lists.linux-foundation.org>,
	"mingo@elte.hu" <mingo@elte.hu>
Subject: Re: [PATCH 2/3] introduce intel_rapl driver
Date: Fri, 27 May 2011 21:56:33 +0200	[thread overview]
Message-ID: <1306526193.2497.474.camel__36375.384257599$1306538836$gmane$org@laptop> (raw)
In-Reply-To: <1306484810.16581.375.camel@rui>

On Fri, 2011-05-27 at 16:26 +0800, Zhang Rui wrote:
> > > +static void rapl_event_update(struct perf_event *event)
> > > +{
> > > +   s64 prev;
> > > +   u64 now;
> > > +   struct rapl_domain *domain = to_rapl_domain(event->pmu);
> > > +
> > > +   now = rapl_read_energy(domain);
> > 
> > So I had to get the Intel SDM because your driver lacks all useful
> > information, and I learned that the RAPL status MSRs contain 32 bits.
> > 
> > So you get those 32 bits, divide them by some number,
> > 
> > > +   prev = local64_xchg(&event->hw.prev_count, now);
> > > +   local64_add(now - prev, &event->count);
> > 
> > And then expect that to work?
> > 
> rapl_read_energy first reads energy status from MSR and then invokes
> rapl_unit_xlate to translate it into Joules.
> For example, on the laptop I tested, the energy unit bits is 0x10, which
> means that the energy unit is 1/65536 Joule.
> So I need to divide the value read from MSR by 65536 to calculate how
> many Joules of energy are cost. 
> 
> But this reveals a problem. If the task is scheduled out with energy
> consumption less than 1 Joule, we failed to record it.
> 
> IMO, a new callback should be introduced so that I can save the MSR
> value first and translate it to Joule when the task exits. Or just do
> the translation in user space.
> 
> what do you think? 

That's not the problem I meant, but lets start with that, you can solve
that differently, just keep a fraction somewhere in hw_perf_event.

Anyway, the problem you missed is what happens when those 32 bits roll
over, at that point you get now < prev and the value added to
event->count is a _HUGE_ 64 bit number.

  parent reply	other threads:[~2011-05-27 19:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26  8:34 [PATCH 2/3] introduce intel_rapl driver Zhang Rui
2011-05-26  9:43 ` Peter Zijlstra
2011-05-26  9:43 ` Peter Zijlstra
2011-05-26 10:21   ` Peter Zijlstra
2011-05-26 10:21   ` Peter Zijlstra
2011-05-26 10:55   ` Matt Fleming
2011-06-02  8:04     ` Matt Fleming
2011-06-02  8:04       ` Matt Fleming
2011-05-26 10:55   ` Matt Fleming
2011-05-27  8:26   ` Zhang Rui
2011-05-27  8:26   ` Zhang Rui
2011-05-27 19:56     ` Peter Zijlstra
2011-05-27 19:56     ` Peter Zijlstra [this message]
2011-05-27 19:56     ` Peter Zijlstra
2011-05-30  3:11       ` Zhang Rui
2011-05-30  3:11       ` Zhang Rui
2011-05-27 19:56     ` Peter Zijlstra
2011-05-26 15:48 ` Randy Dunlap
2011-05-30  2:40   ` Zhang Rui
2011-05-30  2:40   ` Zhang Rui
2011-05-26 15:48 ` Randy Dunlap
2011-05-28 10:17 ` Greg KH
2011-05-30  7:04   ` Zhang Rui
2011-05-30  7:04   ` Zhang Rui
2011-05-28 10:17 ` Greg KH
2011-05-26  8:34 Zhang Rui

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='1306526193.2497.474.camel__36375.384257599$1306538836$gmane$org@laptop' \
    --to=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=matt@console-pimps.org \
    --cc=ming.m.lin@intel.com \
    --cc=mingo@elte.hu \
    --cc=rui.zhang@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.