diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2004-10-14 15:33:33 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2004-10-14 15:33:33 -0400 |
| commit | e58d2eb090023ea4b8e1fe0af2a1bb5314ecfdcb (patch) | |
| tree | bfc1440ee2d3558f78c690d807b7bc788201b301 /include/linux | |
| parent | 5c6f34a71be8749b386e5a773fea0f4784da6a51 (diff) | |
| parent | 8b5915b08dda13ffe1f70f00322dcc34ce161904 (diff) | |
Merge pobox.com:/spare/repo/linux-2.6
into pobox.com:/spare/repo/libata-2.6
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/acct.h | 23 | ||||
| -rw-r--r-- | include/linux/highmem.h | 4 | ||||
| -rw-r--r-- | include/linux/sched.h | 2 | ||||
| -rw-r--r-- | include/linux/times.h | 20 |
4 files changed, 40 insertions, 9 deletions
diff --git a/include/linux/acct.h b/include/linux/acct.h index b46ce1ac1c6a..a6ab17c49aa1 100644 --- a/include/linux/acct.h +++ b/include/linux/acct.h @@ -172,17 +172,24 @@ static inline u32 jiffies_to_AHZ(unsigned long x) #endif } -static inline u64 jiffies_64_to_AHZ(u64 x) +static inline u64 nsec_to_AHZ(u64 x) { -#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 -#if HZ != AHZ - do_div(x, HZ / AHZ); -#endif -#else - x *= TICK_NSEC; +#if (NSEC_PER_SEC % AHZ) == 0 do_div(x, (NSEC_PER_SEC / AHZ)); +#elif (AHZ % 512) == 0 + x *= AHZ/512; + do_div(x, (NSEC_PER_SEC / 512)); +#else + /* + * max relative error 5.7e-8 (1.8s per year) for AHZ <= 1024, + * overflow after 64.99 years. + * exact for AHZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... + */ + x *= 9; + do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (AHZ/2)) + / AHZ)); #endif - return x; + return x; } #endif /* __KERNEL */ diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 232d8fdb557c..7153aef34d5c 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -40,6 +40,8 @@ static inline void clear_user_highpage(struct page *page, unsigned long vaddr) void *addr = kmap_atomic(page, KM_USER0); clear_user_page(addr, vaddr, page); kunmap_atomic(addr, KM_USER0); + /* Make sure this page is cleared on other CPU's too before using it */ + smp_wmb(); } static inline void clear_highpage(struct page *page) @@ -73,6 +75,8 @@ static inline void copy_user_highpage(struct page *to, struct page *from, unsign copy_user_page(vto, vfrom, vaddr, to); kunmap_atomic(vfrom, KM_USER0); kunmap_atomic(vto, KM_USER1); + /* Make sure this page is cleared on other CPU's too before using it */ + smp_wmb(); } static inline void copy_highpage(struct page *to, struct page *from) diff --git a/include/linux/sched.h b/include/linux/sched.h index 90f5cb645116..8810b551082a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -508,7 +508,7 @@ struct task_struct { struct timer_list real_timer; unsigned long utime, stime; unsigned long nvcsw, nivcsw; /* context switch counts */ - u64 start_time; + struct timespec start_time; /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt; /* process credentials */ diff --git a/include/linux/times.h b/include/linux/times.h index ff00f334ffaa..0c5aa078dad4 100644 --- a/include/linux/times.h +++ b/include/linux/times.h @@ -55,6 +55,26 @@ static inline u64 jiffies_64_to_clock_t(u64 x) } #endif +static inline u64 nsec_to_clock_t(u64 x) +{ +#if (NSEC_PER_SEC % USER_HZ) == 0 + do_div(x, (NSEC_PER_SEC / USER_HZ)); +#elif (USER_HZ % 512) == 0 + x *= USER_HZ/512; + do_div(x, (NSEC_PER_SEC / 512)); +#else + /* + * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024, + * overflow after 64.99 years. + * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... + */ + x *= 9; + do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2)) + / USER_HZ)); +#endif + return x; +} + struct tms { clock_t tms_utime; clock_t tms_stime; |
