login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
February
»
20
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in kernel/tsacct.c
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
[view in full thread]
From: Randy Dunlap
Subject:
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in kernel/tsacct.c
Date: Tuesday, February 19, 2008 - 8:52 pm
Jonathan Lim wrote:
quoted text
> It's possible that the values used in and returned from jiffies_to_usecs() are > incorrect because of truncation when variables of type u64 are involved. So a > function specific to that type is used instead. > > This version implements a correction to jiffies_64_to_usecs() based on feedback > from Randy Dunlap. > > Diff'd against: linux/kernel/git/torvalds/linux-2.6.git > > Signed-off-by: Jonathan Lim <jlim@sgi.com> > > --- a/include/linux/jiffies.h Thu Feb 14 18:04:14 PST 2008 > +++ b/include/linux/jiffies.h Thu Feb 14 18:07:17 PST 2008 > @@ -42,7 +42,7 @@ > /* LATCH is used in the interval timer and ftape setup. */ > #define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ > > -/* Suppose we want to devide two numbers NOM and DEN: NOM/DEN, then we can > +/* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can > * improve accuracy by shifting LSH bits, hence calculating: > * (NOM << LSH) / DEN > * This however means trouble for large NOM, because (NOM << LSH) may no > @@ -204,7 +204,7 @@ extern unsigned long preset_lpj; > * operator if the result is a long long AND at least one of the > * operands is cast to long long (usually just prior to the "*" so as > * not to confuse it into thinking it really has a 64-bit operand, > - * which, buy the way, it can do, but it takes more code and at least 2 > + * which, by the way, it can do, but it takes more code and at least 2 > * mpys). > > * We also need to be aware that one second in nanoseconds is only a > @@ -269,6 +269,7 @@ extern unsigned long preset_lpj; > */ > extern unsigned int jiffies_to_msecs(const unsigned long j); > extern unsigned int jiffies_to_usecs(const unsigned long j); > +extern u64 jiffies_64_to_usecs(const u64 j); > extern unsigned long msecs_to_jiffies(const unsigned int m); > extern unsigned long usecs_to_jiffies(const unsigned int u); > extern unsigned long timespec_to_jiffies(const struct timespec *value); > --- a/kernel/time.c Thu Feb 14 18:05:12 PST 2008 > +++ b/kernel/time.c Tue Feb 19 17:00:11 PST 2008
kernel/time.c needs: #include <asm/div64.h> After that, it's Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
quoted text
> @@ -268,6 +268,12 @@ unsigned int inline jiffies_to_usecs(con > } > EXPORT_SYMBOL(jiffies_to_usecs); > > +u64 jiffies_64_to_usecs(const u64 j) > +{ > + return div64_64(j*HZ_TO_USEC_NUM + HZ_TO_USEC_DEN-1, HZ_TO_USEC_DEN); > +} > +EXPORT_SYMBOL(jiffies_64_to_usecs); > + > /** > * timespec_trunc - Truncate timespec to a granularity > * @t: Timespec > --- a/kernel/tsacct.c Thu Feb 14 18:06:17 PST 2008 > +++ b/kernel/tsacct.c Thu Feb 14 18:08:47 PST 2008 > @@ -85,8 +85,8 @@ void xacct_add_tsk(struct taskstats *sta > struct mm_struct *mm; > > /* convert pages-jiffies to Mbyte-usec */ > - stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB; > - stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB; > + stats->coremem = jiffies_64_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB; > + stats->virtmem = jiffies_64_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB; > mm = get_task_mm(p); > if (mm) { > /* adjust to KB unit */
-- ~Randy --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
Messages in current thread:
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in k ...
, Jonathan Lim
, (Tue Feb 19, 1:52 pm)
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in k ...
, Randy Dunlap
, (Tue Feb 19, 2:25 pm)
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in
, Jonathan Lim
, (Tue Feb 19, 2:59 pm)
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in
, Randy Dunlap
, (Tue Feb 19, 3:13 pm)
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in k ...
, Jonathan Lim
, (Tue Feb 19, 7:17 pm)
Re: [PATCH] Provide u64 version of jiffies_to_usecs() in k ...
, Randy Dunlap
, (Tue Feb 19, 8:52 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
FUJITA Tomonori
Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel
Benjamin Herrenschmidt
[git pull] Please pull powerpc.git merge branch
Ingo Molnar
Re: [RFC/RFT PATCH] sched: automated per tty task groups
Vivek Goyal
Re: [PATCH v4] sched: automated per session task groups
Andres Salomon
Re: [PATCH 1/2] OLPC: Add support for calling into Open Firmware
git
:
Mike Miller
git message
Junio C Hamano
Re: [PATCH] Detached HEAD (experimental)
Stefan Richter
Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins
Jeff King
Re: [PATCH] t7004: test that "git-tag -u" implies "-s"
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
git-commits-head
:
Linux Kernel Mailing List
libata: disable ATAPI AN by default
Linux Kernel Mailing List
ARM: 5905/1: ARM: Global ASID allocation on SMP
Linux Kernel Mailing List
i915: Don't whine when pci_enable_msi() fails.
Linux Kernel Mailing List
Documentation/timers/hpet_example.c: only build on X86
Linux Kernel Mailing List
ALSA: hda - Enable beep on Realtek codecs with PCI SSID override
linux-netdev
:
Arnaldo Carvalho de Melo
Re: [PATCH 06/37] dccp: Limit feature negotiation to connection setup phase
Gerrit Renker
[PATCH 1/5] dccp: Initialisation framework for feature negotiation
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Jeff Garzik
Re: [PATCH] drivers/net: remove network drivers' last few uses of IRQF_SAMPLE_RANDOM
David Miller
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugins for negotiation
openbsd-misc
:
Stuart Henderson
Re: Kuro5hin: OpenBSD Founder Theo deRaadt Has Conflict of Interest With AMD
Christian Weisgerber
Re: CARP with a single public IP address
Marco Peereboom
Re: OpenBSD culture?
"RALOVICH, Kristóf"
Re: thinkpad windows refund
Kevin
Re: uvm_mapent_alloc: out of static map entries on 4.3 i386
Colocation donated by:
Syndicate