public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: George Anzinger <george@mvista.com>
To: Tim Schmielau <tim@physik3.uni-rostock.de>
Cc: john stultz <johnstul@us.ibm.com>,
	Albert Cahalan <albert@users.sourceforge.net>,
	David Ford <david+powerix@blue-labs.org>,
	linux-kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: /proc or ps tools bug?  2.6.3, time is off
Date: Wed, 14 Apr 2004 10:03:39 -0700	[thread overview]
Message-ID: <407D6EEB.4070102@mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.53.0404141353450.21779@gockel.physik3.uni-rostock.de>

Tim Schmielau wrote:
>>diff -Nru a/include/linux/times.h b/include/linux/times.h
>>--- a/include/linux/times.h	Tue Apr 13 15:00:25 2004
>>+++ b/include/linux/times.h	Tue Apr 13 15:00:25 2004
>>@@ -7,7 +7,12 @@
>> #include <asm/param.h>
>> 
>> #if (HZ % USER_HZ)==0
>>-# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
>>+static inline long jiffies_to_clock_t(long x)
>>+{
>>+	u64 tmp = (u64)x * TICK_NSEC;
>>+	x = do_div(tmp, (NSEC_PER_SEC / USER_HZ));
>>+	return (long)tmp;
>>+}
>> #else
>> # define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
>> #endif
> 
> 
> Excuse me for barging in lately and innocently, but I find this patch
> hard to comprehend:
>  - shouldn't a foo_to_clock_t() function return a clock?
>  - the x = seems superfluous
>  - the #if is not a shortcut anymore, so why keep it?
> Shouldn't this patch be more like the following
> (completely untested)?
> 
> Tim
> 
> 
> diff -urp --exclude-from dontdiff linux-2.6.5/include/linux/times.h linux-2.6.5-jfix1/include/linux/times.h
> --- linux-2.6.5/include/linux/times.h	2004-02-04 04:43:09.000000000 +0100
> +++ linux-2.6.5-jfix1/include/linux/times.h	2004-04-14 13:48:57.000000000 +0200
> @@ -6,11 +6,16 @@
>  #include <asm/types.h>
>  #include <asm/param.h>
>  
> -#if (HZ % USER_HZ)==0
> -# define jiffies_to_clock_t(x) ((x) / (HZ / USER_HZ))
> -#else
> -# define jiffies_to_clock_t(x) ((clock_t) jiffies_64_to_clock_t((u64) x))
> -#endif
> +static inline clock_t jiffies_to_clock_t(long x)
> +{
> +#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
> +	return x / (HZ / USER_HZ);
> +#else
> +	u64 tmp = (u64)x * TICK_NSEC;
> +	do_div(tmp, (NSEC_PER_SEC / USER_HZ));
> +	return (long)tmp;
> +#endif
> +}
>  
>  static inline unsigned long clock_t_to_jiffies(unsigned long x)
>  {
> 
It does look a bit better.  Takes into account the issue of TICK_NSEC being what 
it is.

-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml


  reply	other threads:[~2004-04-14 17:03 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-25  1:58 /proc or ps tools bug? 2.6.3, time is off David Ford
2004-02-25  1:54 ` Albert Cahalan
2004-02-25  5:10   ` David Ford
2004-02-25  3:27     ` Albert Cahalan
2004-02-25 16:28       ` George Anzinger
2004-02-25 16:04         ` Albert Cahalan
2004-02-25 20:45           ` George Anzinger
2004-02-25 19:16             ` Albert Cahalan
2004-02-25 21:10           ` George Anzinger
2004-02-26  1:52             ` john stultz
2004-02-26 23:06               ` George Anzinger
2004-02-26 23:10                 ` john stultz
2004-02-27  0:20                   ` George Anzinger
2004-04-13 22:38                     ` john stultz
2004-04-13 22:59                       ` George Anzinger
2004-04-14 12:10                       ` Tim Schmielau
2004-04-14 17:03                         ` George Anzinger [this message]
2004-04-14 18:28                         ` john stultz
2004-04-15 10:37                           ` Petri Kaukasoina
2004-04-15 11:05                             ` Tim Schmielau
2004-04-15 16:14                               ` Petri Kaukasoina
2004-05-01 13:51                                 ` Tim Schmielau
2004-05-02  1:41                                   ` Andrew Morton
2004-05-02  1:59                                     ` Tim Schmielau
2004-05-04  2:40                                       ` john stultz
2004-05-04  6:12                                         ` Tim Schmielau
2004-05-04 14:59                                           ` john stultz
2004-05-04 16:50                                             ` Tim Schmielau
2004-05-07  0:33                                             ` George Anzinger
2004-05-07  1:21                                               ` john stultz
2004-05-07 20:41                                                 ` George Anzinger
2004-05-07 21:38                                                   ` john stultz
2004-02-26 23:14               ` George Anzinger
2004-02-25  9:14 ` Petri Kaukasoina
2004-02-25  9:18   ` Petri Kaukasoina
2004-02-25 21:39   ` David Ford

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=407D6EEB.4070102@mvista.com \
    --to=george@mvista.com \
    --cc=albert@users.sourceforge.net \
    --cc=david+powerix@blue-labs.org \
    --cc=ganzinger@mvista.com \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim@physik3.uni-rostock.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox