intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Konstantin Belousov <kostikbel@gmail.com>,
	Intel-gfx <Intel-gfx@lists.freedesktop.org>
Subject: Re: i915_chipset_val()
Date: Fri, 08 Jul 2011 10:42:02 +0100	[thread overview]
Message-ID: <d08817$n6lv6@azsmga001.ch.intel.com> (raw)
In-Reply-To: <20110708092651.GN48734@deviant.kiev.zoral.com.ua>

On Fri, 8 Jul 2011 12:26:51 +0300, Konstantin Belousov <kostikbel@gmail.com> wrote:
> i915_chipset_val saves the jiffies count of the invocation in last_time1.
> Then, on the next call, the diff between current jiffies value and
> last_time1 is used as divisor.
> 
> I have a suspicious that two rapid calls to i915_chipset_val() may result
> in division by zero. This looks as user-controllable action, since
> debugfs, if configured, would export i915_chipset_val() as emon status.
> 
> I did not tested the Linux, but in the (ported) code I am able to get
> into the described situation. As a workaround, I cached the previous
> return value from i915_chipset_val() and return it instead of doing
> the calculation if consequtive calls are close enough.
> 
> What do you think ? (patch is not directly applicable to Linux).

You're right. But I would go even further and say that if the difference
is less than say 10ms then we have not accumulated enough samples for the
calculation to be stable.

>  unsigned long i915_mch_val(struct drm_i915_private *dev_priv)
> diff --git a/sys/dev/drm/i915_drv.h b/sys/dev/drm/i915_drv.h
> index 5e6340b..36d066a 100644
> --- a/sys/dev/drm/i915_drv.h
> +++ b/sys/dev/drm/i915_drv.h
> @@ -579,6 +579,7 @@ typedef struct drm_i915_private {
>  
>  	u64 last_count1;
>  	unsigned long last_time1;
> +	unsigned long last_chipset_val;
>  	u64 last_count2;
>  	struct timespec last_time2;
>  	unsigned long gfx_power;

We need to thank Jesse for such informative variable names. Not even a
comment to mention that they are part of IPS.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

  reply	other threads:[~2011-07-08  9:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-08  9:26 i915_chipset_val() Konstantin Belousov
2011-07-08  9:42 ` Chris Wilson [this message]
2011-07-08 12:24   ` i915_chipset_val() Konstantin Belousov
2011-07-08 14:21     ` i915_chipset_val() Jesse Barnes

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='d08817$n6lv6@azsmga001.ch.intel.com' \
    --to=chris@chris-wilson.co.uk \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=kostikbel@gmail.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 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).