All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Zhangjin <wuzhangjin@gmail.com>
To: David Daney <ddaney@caviumnetworks.com>
Cc: "Ralf Baechle" <ralf@linux-mips.org>,
	linux-mips@linux-mips.org, "Ralf Rösch" <roesch.ralf@web.de>
Subject: Re: [PATCH v2 1/3] MIPS: add a common mips_cyc2ns()
Date: Thu, 08 Apr 2010 17:32:51 +0800	[thread overview]
Message-ID: <1270719171.5709.37.camel@falcon> (raw)
In-Reply-To: <4BBCB7EC.5020403@caviumnetworks.com>

On Wed, 2010-04-07 at 09:50 -0700, David Daney wrote:
[...]
> > +static inline unsigned long long mips_cyc2ns(u64 cyc, u64 mult, u64 shift)
> > +{
> > +#ifdef CONFIG_32BIT
> > +	/*
> > +	 * To balance the overhead of 128bit-arithematic and the precision
> > +	 * lost, we choose a smaller shift to avoid the quick overflow as the
> > +	 * X86&  ARM does. please refer to arch/x86/kernel/tsc.c and
> > +	 * arch/arm/plat-orion/time.c
> > +	 */
> > +	return (cyc * mult)>>  shift;
> 
> Have you tested that on a 32-bit kernel?  I think it may overflow for 
> many cases.
> 

Yes, I have done some basic testing ;)

Since a c0 count with 400MHz clock frequency will overflow after about
more than 1 hour with the scaling factor 10, I think it is enough for
the generic debugging, such as Ftrace, If it is not enough, perhaps we
can choose a smaller scaling factor, such as 8.

The core idea here is to get a smaller mult to let (cyc * mult) not
overflow that quickly but also not get a 'bad' precision, of course, we
can try to implement the 128bit arithmatic in 32bit system, but that may
increase the overhead(not tested it yet, perhaps will be worse than the
original getnstimeofday()).

Regards,
	Wu Zhangjin

  reply	other threads:[~2010-04-08  9:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 16:05 [PATCH v2 0/3] add high resolution sched_clock() for MIPS Wu Zhangin
     [not found] ` <cover.1270655886.git.wuzhangjin@gmail.com>
2010-04-07 16:05   ` [PATCH v2 1/3] MIPS: add a common mips_cyc2ns() Wu Zhangin
2010-04-07 16:48     ` David Daney
2010-04-08  9:36       ` Wu Zhangjin
2010-04-07 16:50     ` David Daney
2010-04-08  9:32       ` Wu Zhangjin [this message]
2010-04-10  5:46         ` Wu Zhangjin
2010-04-07 16:05   ` [PATCH v2 2/3] MIPS: cavium-octeon: rewrite the sched_clock() based on mips_cyc2ns() Wu Zhangin
2010-07-29  1:24     ` wu zhangjin
2010-07-29  1:24       ` wu zhangjin
2010-04-07 16:05   ` [PATCH v2 3/3] MIPS: r4k: Add a high resolution sched_clock() Wu Zhangin

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=1270719171.5709.37.camel@falcon \
    --to=wuzhangjin@gmail.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=roesch.ralf@web.de \
    /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.