mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Bruno Randolf <br1@einfach.org>
Cc: kosaki.motohiro@jp.fujitsu.com, randy.dunlap@oracle.com,
	akpm@linux-foundation.org, kevin.granade@gmail.com,
	Lars_Ericsson@telia.com, blp@cs.stanford.edu,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] Add generic exponentially weighted moving average (EWMA) function
Date: Fri, 22 Oct 2010 10:11:38 +0900 (JST)	[thread overview]
Message-ID: <20101022100316.53A3.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <201010220953.30148.br1@einfach.org>

> > and nit, I don't understand what you intend by 'const unsigned int'. I
> > think we can remove this const safely. it's more easy readable.
> 
> O.K. Will resend.
> 
> Apart from that, what didn't work as you expected?

It works. I meant this const has no meaning.


few additional reviewing comments is here.


> +struct ewma {
> +	unsigned int internal;
> +	unsigned int factor;
> +	unsigned int weight;
> +};

I think unsigned long is better because long is natual register size
on both 32bit and 64bit arch.
and, example, almost linux resource limit is using long or ulong. then
uint may have overflow risk if we are using this one on 64bit arch.
Does uint has any benefit? (note: scheduler loadavg has already used ulong)

> +struct ewma*
> +ewma_add(struct ewma *avg, const unsigned int val)
> +{
> +	avg->internal = avg->internal  ?
> +		(((avg->internal * (avg->weight - 1)) +
> +			(val * avg->factor)) / avg->weight) :
> +		(val * avg->factor);
> +	return avg;

Hm, if ewma_add has this function prototype, we almost always need to
typing "new = ewma_get(ewma_add(&ewma, val))". Is this intentional?
if so, why?

Why can't we simple do following?

unsigned long ewma_add(struct ewma *avg, const unsigned int val)
{
(snip)
	return ewma_get(avg);
}




  reply	other threads:[~2010-10-22  1:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20  8:23 Bruno Randolf
2010-10-20 15:03 ` Peter Zijlstra
2010-10-21  5:40   ` Bruno Randolf
2010-10-21 10:04     ` Peter Zijlstra
2010-10-21 10:31 ` KOSAKI Motohiro
2010-10-22  0:53   ` Bruno Randolf
2010-10-22  1:11     ` KOSAKI Motohiro [this message]
2010-10-22  1:25       ` Bruno Randolf
2010-10-22  1:28         ` KOSAKI Motohiro

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=20101022100316.53A3.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=Lars_Ericsson@telia.com \
    --cc=akpm@linux-foundation.org \
    --cc=blp@cs.stanford.edu \
    --cc=br1@einfach.org \
    --cc=kevin.granade@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.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

all inboxes | Powered by JetHome®