Move div_long_long_rem out of jiffies.h
Subsystems (8)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/43 Move div_long_long_rem out of jiffies.h
plain text document attachment
(move-div-long-long-rem-out-of-jiffiesh.patch)
- move div_long_long_rem() from jiffies.h into a new calc64.h include file, as it is a general math function useful for other things than the jiffy code.
include/linux/calc64.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/jiffies.h | 11 +---------- 2 files changed, 47 insertions(+), 10 deletions(-)
include/linux/calc64.h new file +46 -0
@@ -0,0 +1,46 @@ +#ifndef _LINUX_CALC64_H +#define _LINUX_CALC64_H + +#include <linux/types.h> +#include <asm/div64.h> + +/* +* This is a generic macro which is used when the architecture +* specific div64.h does not provide a optimized one. +* +* The 64bit dividend is divided by the divisor (data type long), the +* result is returned and the remainder stored in the variable +* referenced by remainder (data type long *). In contrast to the +* do_div macro the dividend is kept intact. +*/ +#ifndef div_long_long_rem +#define div_long_long_rem (dividend,divisor,remainder) \ +({ \ + u64 result = (dividend); \ + \ + *(remainder) = do_div(result, divisor); \ + result; \ +}) +#endif + +/* +* Sign aware variation of the above. On some architectures a +* negative dividend leads to an divide overflow exception, which +* is avoided by the sign check. +*/ +static inline long div_long_long_rem_signed (const long long dividend, +const long divisor, +long *remainder) +{ +long res; + +if (unlikely (dividend <0 )) { + res = -div_long_long_rem (-dividend, divisor, remainder); + *remainder = -(*remainder); + }else + res =div_long_long_rem (dividend, divisor, remainder); + +return res; +} + +#endif
include/linux/jiffies.h +1 -10
@@ -1,21 +1,12 @@#ifndef _LINUX_JIFFIES_H#define _LINUX_JIFFIES_H +#include <linux/calc64.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/time.h> #include <linux/timex.h> #include <asm/param.h> /* for HZ */ -#include <asm/div64.h> - -#ifndef div_long_long_rem -#define div_long_long_rem (dividend,divisor,remainder) \ -({ \ - u64 result = dividend; \ - *remainder = do_div(result,divisor); \ - result; \ -}) -#endif /* * The following defines establish the engineering parameters of the PLL
--
Quoted 7 lines · Thomas Gleixner
plain text document attachment
(move-div-long-long-rem-out-of-jiffiesh.patch)- move
div_long_long_rem()fromjiffies.hinto a newcalc64.hinclude file, as it is a general math function useful for other things than the jiffy code.
...
- add a static inline div_long_long_rem_signed() function
This isn't against your patch, but this part of the change wasn't documented.
And while you are at it, is there a reason against making div_long_long_rem() a static inline?
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 6 lines · Thomas Gleixner
plain text document attachment
(move-div-long-long-rem-out-of-jiffiesh.patch)- move
div_long_long_rem()fromjiffies.hinto a newcalc64.hinclude file, as it is a general math function useful for other things than the jiffy code.
please just kill it div_long_long_rem()
PATCH 2/43 Remove duplicate div_long_long_rem implementation
In reply to a message not in the archiveplain text document attachment (remove-div-long-long-rem-duplicate.patch)
- make posix-timers.c use the generic calc64.h facility
kernel/posix-timers.c | 10 +--------- 1 files changed, 1 insertion(+), 9 deletions(-)
kernel/posix-timers.c +1 -9
@@ -35,6 +35,7 @@#include <linux/interrupt.h> #include <linux/slab.h> #include <linux/time.h> +#include <linux/calc64.h> #include <asm/uaccess.h> #include <asm/semaphore.h>
@@ -48,15 +49,6 @@#include <linux/workqueue.h> #include <linux/module.h> -#ifndef div_long_long_rem -#include <asm/div64.h> - -#define div_long_long_rem (dividend,divisor,remainder) ({ \ - u64 result = dividend; \ - *remainder = do_div(result,divisor); \ - result; }) - -#endif #define CLOCK_REALTIME_RES TICK_NSEC/* In nano seconds. */ static inline u64 mpy_l_X_l_ll (unsigned long mpy1,unsigned long mpy2)
--
PATCH 3/43 Deinline mktime and set_normalized_timespec
In reply to a message not in the archiveplain text document attachment (deinline-mktime-set-normalized-timespec.patch)
- mktime() and set_normalized_timespec() are large inline functions used in many places: deinline them.
From: George Anzinger, off-by-1 bugfix
include/linux/time.h | 52 ++++--------------------------------------- kernel/time.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 47 deletions(-)
include/linux/time.h +5 -47
@@ -38,38 +38,9 @@ static __inline__ int timespec_equal(strreturn (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); } -/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. -* Assumes input in normal date format, i.e. 1980-12-31 23:59:59 -* => year=1980, mon=12, day=31, hour=23, min=59, sec=59. -* -* [For the Julian calendar (which was used in Russia before 1917, -* Britain & colonies before 1752, anywhere else before 1582, -* and is still in use by some communities) leave out the -* -year/100+year/400 terms, and add 10.] -* -* This algorithm was first published by Gauss (I think). -* -* WARNING: this function will overflow on 2106-02-07 06:28:16 on -* machines were long is 32-bit! (However, as time_t is signed, we -* will already get problems at other places on 2038-01-19 03:14:08) -*/ -static inline unsigned long -mktime (unsigned int year,unsigned int mon, -unsigned int day,unsigned int hour, -unsigned int min,unsigned int sec) -{ -if (0 >= (int ) (mon -=2 )) {/* 1..12 -> 11,12,1..10 */ - mon +=12 ;/* Puts Feb last since it has leap day */ - year -=1 ; - } - -return ((( - (unsigned long ) (year/4 - year/100 + year/400 +367 *mon/12 + day) + - year*365 -719499 - )*24 + hour/* now have hours */ - )*60 + min/* now have minutes */ - )*60 + sec;/* finally seconds */ -} +extern unsigned long mktime (unsigned int year,unsigned int mon, +unsigned int day,unsigned int hour, +unsigned int min,unsigned int sec);extern struct timespec xtime;extern struct timespec wall_to_monotonic;
@@ -80,6 +51,8 @@ static inline unsigned long get_seconds(return xtime.tv_sec; } +extern void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec); +struct timespec current_kernel_time (void );#define CURRENT_TIME (current_kernel_time())
@@ -98,21 +71,6 @@ extern void getnstimeofday (struct timesextern struct timespec timespec_trunc (struct timespec t,unsigned gran); -static inline void -set_normalized_timespec (struct timespec *ts,time_t sec,long nsec) -{ -while (nsec >=NSEC_PER_SEC ) { - nsec -=NSEC_PER_SEC ; - ++sec; - } -while (nsec <0 ) { - nsec +=NSEC_PER_SEC ; - --sec; - } - ts->tv_sec = sec; - ts->tv_nsec = nsec; -} -#endif /* __KERNEL__ */ #define NFDBITS __NFDBITS
kernel/time.c +61 -0
67 lines not on this page · raw message
--
PATCH 4/43 Clean up mktime and add const modifiers
In reply to a message not in the archiveplain text document attachment (mktime-set-normalized-timespec-const.patch)
- add 'const' to mktime arguments, and clean it up a bit
include/linux/time.h | 10 +++++----- kernel/time.c | 15 +++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-)
include/linux/time.h +5 -5
@@ -38,9 +38,11 @@ static __inline__ int timespec_equal(strreturn (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); } -extern unsigned long mktime (unsigned int year,unsigned int mon, -unsigned int day,unsigned int hour, -unsigned int min,unsigned int sec); +extern unsigned long mktime (const unsigned int year,const unsigned int mon, +const unsigned int day,const unsigned int hour, +const unsigned int min,const unsigned int sec); + +extern void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec);extern struct timespec xtime;extern struct timespec wall_to_monotonic;
@@ -51,8 +53,6 @@ static inline unsigned long get_seconds(return xtime.tv_sec; } -extern void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec); -struct timespec current_kernel_time (void );#define CURRENT_TIME (current_kernel_time())
kernel/time.c +9 -6
@@ -577,12 +577,15 @@ EXPORT_SYMBOL_GPL(getnstimeofday);* will already get problems at other places on 2038-01-19 03:14:08) */ unsigned long -mktime (unsigned int year,unsigned int mon, -unsigned int day,unsigned int hour, -unsigned int min,unsigned int sec) +mktime (const unsigned int year0,const unsigned int mon0, +const unsigned int day,const unsigned int hour, +const unsigned int min,const unsigned int sec) { -if (0 >= (int ) (mon -=2 )) {/* 1..12 -> 11,12,1..10 */ - mon +=12 ;/* Puts Feb last since it has leap day */ +unsigned int mon = mon0, year = year0; + +/* 1..12 -> 11,12,1..10 */ +if (0 >= (int ) (mon -=2 )) { + mon +=12 ;/* Puts Feb last since it has leap day */ year -=1 ; }
@@ -608,7 +611,7 @@ mktime (unsigned int year, unsigned int* 0 <= tv_nsec < NSEC_PER_SEC * For negative values only the tv_sec field is negative ! */ -void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec) +void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec) {while (nsec >=NSEC_PER_SEC ) { nsec -=NSEC_PER_SEC ;
--
PATCH 5/43 Export deinlined mktime
In reply to a message not in the archiveplain text document attachment (deinline-mktime-export.patch)
From: Andrew Morton <[email protected]>
This is now uninlined, but some modules use it.
Make it a non-GPL export, since the inlined mktime() was also available that way.
kernel/time.c | 2 ++ 1 files changed, 2 insertions(+)
kernel/time.c +2 -0
@@ -597,6 +597,8 @@ mktime(const unsigned int year0, const u )*60 + sec; /* finally seconds */ } +EXPORT_SYMBOL (mktime); +/** * set_normalized_timespec - set timespec sec and nsec parts and normalize *
--
PATCH 6/43 Remove unused clock constants
In reply to a message not in the archiveplain text document attachment
(time-h-remove-unused-clock-constants.patch)
- remove unused CLOCK_ constants from time.h
include/linux/time.h | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
include/linux/time.h +4 -7
@@ -103,12 +103,10 @@ struct itimerval {/* * The IDs of the various system clocks (for POSIX.1b interval timers). */ -#define CLOCK_REALTIME 0 -#define CLOCK_MONOTONIC 1 +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1#define CLOCK_PROCESS_CPUTIME_ID 2#define CLOCK_THREAD_CPUTIME_ID 3 -#define CLOCK_REALTIME_HR 4 -#define CLOCK_MONOTONIC_HR 5/* * The IDs of various hardware clocks
@@ -117,9 +115,8 @@ struct itimerval {#define CLOCK_SGI_CYCLE 10#define MAX_CLOCKS 16 -#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC | \ - CLOCK_REALTIME_HR | CLOCK_MONOTONIC_HR) -#define CLOCKS_MONO (CLOCK_MONOTONIC & CLOCK_MONOTONIC_HR) +#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC) +#define CLOCKS_MONO (CLOCK_MONOTONIC)/* * The various flags for setting POSIX.1b interval timers.
--
PATCH 7/43 Cleanup clock constants coding style
In reply to a message not in the archiveplain text document attachment (time-h-clean-up-clock-constants.patch)
- clean up the CLOCK_ portions of time.h
include/linux/time.h | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-)
include/linux/time.h +9 -14
@@ -99,30 +99,25 @@ struct itimerval { struct timeval it_value; /* current value */ }; -/* * The IDs of the various system clocks (for POSIX.1b interval timers). */ -#define CLOCK_REALTIME 0 -#define CLOCK_MONOTONIC 1 -#define CLOCK_PROCESS_CPUTIME_ID 2 -#define CLOCK_THREAD_CPUTIME_ID 3 +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#define CLOCK_PROCESS_CPUTIME_ID 2 +#define CLOCK_THREAD_CPUTIME_ID 3/* * The IDs of various hardware clocks */ - - -#define CLOCK_SGI_CYCLE 10 -#define MAX_CLOCKS 16 -#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC) -#define CLOCKS_MONO (CLOCK_MONOTONIC) +#define CLOCK_SGI_CYCLE 10 +#define MAX_CLOCKS 16 +#define CLOCKS_MASK (CLOCK_REALTIME | CLOCK_MONOTONIC) +#define CLOCKS_MONO CLOCK_MONOTONIC/* * The various flags for setting POSIX.1b interval timers. */ - -#define TIMER_ABSTIME 0x01 - +#define TIMER_ABSTIME 0x01#endif
--
PATCH 8/43 Coding style and whitespace cleanup time.h
In reply to a message not in the archiveplain text document attachment (time-h-clean-up-rest.patch)
- style and whitespace cleanup of the rest of time.h.
include/linux/time.h | 63 +++++++++++++++++++++++++-------------------------- 1 files changed, 32 insertions(+), 31 deletions(-)
include/linux/time.h +32 -31
@@ -4,7 +4,7 @@#include <linux/types.h> #ifdef __KERNEL__ -#include <linux/seqlock.h> +# include <linux/seqlock.h> #endif #ifndef _STRUCT_TIMESPEC
@@ -13,7 +13,7 @@ struct timespec {time_t tv_sec;/* seconds */ long tv_nsec;/* nanoseconds */ }; -#endif /* _STRUCT_TIMESPEC */ +#endif struct timeval {time_t tv_sec;/* seconds */
@@ -27,16 +27,16 @@ struct timezone {#ifdef __KERNEL__ -/* Parameters used to convert the timespec values */ -#define MSEC_PER_SEC (1000L) -#define USEC_PER_SEC (1000000L) -#define NSEC_PER_SEC (1000000000L) -#define NSEC_PER_USEC (1000L) +/* Parameters used to convert the timespec values: */ +#define MSEC_PER_SEC 1000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L +#define NSEC_PER_USEC 1000L -static __inline__int timespec_equal (struct timespec *a,struct timespec *b) -{ +static __inline__int timespec_equal (struct timespec *a,struct timespec *b) +{return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); -} +} extern unsigned long mktime(const unsigned int year, const unsigned int mon, const unsigned int day, const unsigned int hour,
@@ -49,25 +49,26 @@ extern struct timespec wall_to_monotonicextern seqlock_t xtime_lock;static inline unsigned long get_seconds (void ) -{ +{return xtime.tv_sec; }struct timespec current_kernel_time (void ); -#define CURRENT_TIME (current_kernel_time()) -#define CURRENT_TIME_SEC ((struct timespec) { xtime.tv_sec, 0 }) +#define CURRENT_TIME (current_kernel_time()) +#define CURRENT_TIME_SEC ((struct timespec) { xtime.tv_sec, 0 })extern void do_gettimeofday (struct timeval *tv);extern int do_settimeofday (struct timespec *tv);extern int do_sys_settimeofday (struct timespec *tv,struct timezone *tz); -extern void clock_was_set (void );// call when ever the clock is set +extern void clock_was_set (void );// call whenever the clock is set extern int do_posix_clock_monotonic_gettime (struct timespec *tp); -extern long do_utimes (char __user * filename,struct timeval * times); +extern long do_utimes (char __user *filename,struct timeval *times);struct itimerval ; -extern int do_setitimer (int which,struct itimerval *value,struct itimerval *ovalue); +extern int do_setitimer (int which,struct itimerval *value, +struct itimerval *ovalue);extern int do_getitimer (int which,struct itimerval *value); -extern void getnstimeofday (struct timespec *tv); +extern void getnstimeofday (struct timespec *tv);extern struct timespec timespec_trunc (struct timespec t,unsigned gran);
@@ -83,24 +84,24 @@ extern struct timespec timespec_trunc(st/* * Names of the interval timers, and structure -* defining a timer setting. +* defining a timer setting: */ -#define ITIMER_REAL 0 -#define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 - -struct itimerspec { -struct timespec it_interval;/* timer period */ -struct timespec it_value;/* timer expiration */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerspec { +struct timespec it_interval;/* timer period */ +struct timespec it_value;/* timer expiration */ }; -struct itimerval { -struct timeval it_interval;/* timer interval */ -struct timeval it_value;/* current value */ +struct itimerval { +struct timeval it_interval;/* timer interval */ +struct timeval it_value;/* current value */ };/* -* The IDs of the various system clocks (for POSIX.1b interval timers). +* The IDs of the various system clocks (for POSIX.1b interval timers): */ #define CLOCK_REALTIME 0#define CLOCK_MONOTONIC 1
@@ -108,7 +109,7 @@ struct itimerval {#define CLOCK_THREAD_CPUTIME_ID 3/* -* The IDs of various hardware clocks +* The IDs of various hardware clocks: */ #define CLOCK_SGI_CYCLE 10#define MAX_CLOCKS 16
@@ -116,7 +117,7 @@ struct itimerval {#define CLOCKS_MONO CLOCK_MONOTONIC/* -* The various flags for setting POSIX.1b interval timers. +* The various flags for setting POSIX.1b interval timers: */ #define TIMER_ABSTIME 0x01
--
PATCH 9/43 Make clock selectors in posix-timers const
In reply to a message not in the archiveplain text document attachment (posix-timer-const-overhaul.patch)
- add const arguments to the posix-timers.h API functions
include/linux/posix-timers.h | 22 +++++++++++----------- kernel/posix-cpu-timers.c | 40 ++++++++++++++++++++++------------------ kernel/posix-timers.c | 38 +++++++++++++++++++++----------------- 3 files changed, 54 insertions(+), 46 deletions(-)
include/linux/posix-timers.h +11 -11
@@ -72,12 +72,12 @@ struct k_clock_abs { };struct k_clock {int res;/* in nano seconds */ -int (*clock_getres) (clockid_t which_clock,struct timespec *tp); +int (*clock_getres) (const clockid_t which_clock,struct timespec *tp);struct k_clock_abs *abs_struct; -int (*clock_set) (clockid_t which_clock,struct timespec * tp); -int (*clock_get) (clockid_t which_clock,struct timespec * tp); +int (*clock_set) (const clockid_t which_clock,struct timespec * tp); +int (*clock_get) (const clockid_t which_clock,struct timespec * tp);int (*timer_create) (struct k_itimer *timer); -int (*nsleep) (clockid_t which_clock,int flags,struct timespec *); +int (*nsleep) (const clockid_t which_clock,int flags,struct timespec *);int (*timer_set) (struct k_itimer * timr,int flags,struct itimerspec * new_setting,struct itimerspec * old_setting);
@@ -87,12 +87,12 @@ struct k_clock { struct itimerspec * cur_setting); }; -void register_posix_clock (clockid_t clock_id,struct k_clock *new_clock); +void register_posix_clock (const clockid_t clock_id,struct k_clock *new_clock);/* Error handlers for timer_create, nanosleep and settime */ int do_posix_clock_notimer_create (struct k_itimer *timer); -int do_posix_clock_nonanosleep (clockid_t ,int flags,struct timespec *); -int do_posix_clock_nosettime (clockid_t ,struct timespec *tp); +int do_posix_clock_nonanosleep (const clockid_t ,int flags,struct timespec *); +int do_posix_clock_nosettime (const clockid_t ,struct timespec *tp);/* function to call to trigger timer event */ int posix_timer_event (struct k_itimer *timr,int si_private);
@@ -117,11 +117,11 @@ struct now_struct { } \ }while (0 ) -int posix_cpu_clock_getres(clockid_t which_clock, struct timespec *); -int posix_cpu_clock_get (clockid_t which_clock,struct timespec *); -int posix_cpu_clock_set (clockid_t which_clock,const struct timespec *tp); +int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *); +int posix_cpu_clock_get (const clockid_t which_clock,struct timespec *); +int posix_cpu_clock_set (const clockid_t which_clock,const struct timespec *tp);int posix_cpu_timer_create (struct k_itimer *); -int posix_cpu_nsleep (clockid_t ,int ,struct timespec *); +int posix_cpu_nsleep (const clockid_t ,int ,struct timespec *);int posix_cpu_timer_set (struct k_itimer *,int ,struct itimerspec *,struct itimerspec *);int posix_cpu_timer_del (struct k_itimer *);
kernel/posix-cpu-timers.c +22 -18
@@ -7,7 +7,7 @@#include <asm/uaccess.h> #include <linux/errno.h> -static int check_clock (clockid_t which_clock) +static int check_clock (const clockid_t which_clock) {int error =0 ;struct task_struct *p;
@@ -31,7 +31,7 @@ static int check_clock(clockid_t which_c }static inline union cpu_time_count -timespec_to_sample (clockid_t which_clock,const struct timespec *tp) +timespec_to_sample (const clockid_t which_clock,const struct timespec *tp) {union cpu_time_count ret; ret.sched =0 ;/* high half always zero when .cpu used */
@@ -43,7 +43,7 @@ timespec_to_sample(clockid_t which_clockreturn ret; } -static void sample_to_timespec (clockid_t which_clock, +static void sample_to_timespec (const clockid_t which_clock,union cpu_time_count cpu,struct timespec *tp) {
@@ -55,7 +55,7 @@ static void sample_to_timespec(clockid_t } } -static inline int cpu_time_before (clockid_t which_clock, +static inline int cpu_time_before (const clockid_t which_clock,union cpu_time_count now,union cpu_time_count then) {
@@ -65,7 +65,7 @@ static inline int cpu_time_before(clockireturn cputime_lt (now.cpu, then.cpu); } } -static inline void cpu_time_add (clockid_t which_clock, +static inline void cpu_time_add (const clockid_t which_clock,union cpu_time_count *acc,union cpu_time_count val) {
@@ -75,7 +75,7 @@ static inline void cpu_time_add(clockid_ acc->cpu =cputime_add (acc->cpu, val.cpu); } } -static inline union cpu_time_count cpu_time_sub (clockid_t which_clock, +static inline union cpu_time_count cpu_time_sub (const clockid_t which_clock,union cpu_time_count a,union cpu_time_count b) {
@@ -151,7 +151,7 @@ static inline unsigned long long sched_nreturn (p == current) ?current_sched_time (p) : p->sched_time; } -int posix_cpu_clock_getres (clockid_t which_clock,struct timespec *tp) +int posix_cpu_clock_getres (const clockid_t which_clock,struct timespec *tp) {int error =check_clock (which_clock);if (!error) {
@@ -169,7 +169,7 @@ int posix_cpu_clock_getres(clockid_t whireturn error; } -int posix_cpu_clock_set (clockid_t which_clock,const struct timespec *tp) +int posix_cpu_clock_set (const clockid_t which_clock,const struct timespec *tp) {/* * You can never reset a CPU clock, but we check for other errors
@@ -186,7 +186,7 @@ int posix_cpu_clock_set(clockid_t which_/* * Sample a per-thread clock for the given task. */ -static int cpu_clock_sample (clockid_t which_clock,struct task_struct *p, +static int cpu_clock_sample (const clockid_t which_clock,struct task_struct *p,union cpu_time_count *cpu) {switch (CPUCLOCK_WHICH (which_clock)) {
@@ -259,7 +259,7 @@ static int cpu_clock_sample_group_locked* Sample a process (thread group) clock for the given group_leader task. * Must be called with tasklist_lock held for reading. */ -static int cpu_clock_sample_group (clockid_t which_clock, +static int cpu_clock_sample_group (const clockid_t which_clock,struct task_struct *p,union cpu_time_count *cpu) {
@@ -273,7 +273,7 @@ static int cpu_clock_sample_group(clocki } -int posix_cpu_clock_get (clockid_t which_clock,struct timespec *tp) +int posix_cpu_clock_get (const clockid_t which_clock,struct timespec *tp) {const pid_t pid =CPUCLOCK_PID (which_clock);int error = -EINVAL ;
@@ -1410,7 +1410,7 @@ void set_process_cpu_timer(struct task_sstatic long posix_cpu_clock_nanosleep_restart (struct restart_block *); -int posix_cpu_nsleep (clockid_t which_clock,int flags, +int posix_cpu_nsleep (const clockid_t which_clock,int flags,struct timespec *rqtp) { struct restart_block *restart_block =
@@ -1514,11 +1514,13 @@ posix_cpu_clock_nanosleep_restart(struct#define PROCESS_CLOCK MAKE_PROCESS_CPUCLOCK(0, CPUCLOCK_SCHED)#define THREAD_CLOCK MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED) -static int process_cpu_clock_getres (clockid_t which_clock,struct timespec *tp) +static int process_cpu_clock_getres (const clockid_t which_clock, +struct timespec *tp) {return posix_cpu_clock_getres (PROCESS_CLOCK , tp); } -static int process_cpu_clock_get (clockid_t which_clock,struct timespec *tp) +static int process_cpu_clock_get (const clockid_t which_clock, +struct timespec *tp) {return posix_cpu_clock_get (PROCESS_CLOCK , tp); }
@@ -1527,16 +1529,18 @@ static int process_cpu_timer_create(stru timer->it_clock =PROCESS_CLOCK ;return posix_cpu_timer_create (timer); } -static int process_cpu_nsleep (clockid_t which_clock,int flags, +static int process_cpu_nsleep (const clockid_t which_clock,int flags,struct timespec *rqtp) {return posix_cpu_nsleep (PROCESS_CLOCK , flags, rqtp); } -static int thread_cpu_clock_getres (clockid_t which_clock,struct timespec *tp) +static int thread_cpu_clock_getres (const clockid_t which_clock, +struct timespec *tp) {return posix_cpu_clock_getres (THREAD_CLOCK , tp); } -static int thread_cpu_clock_get (clockid_t which_clock,struct timespec *tp) +static int thread_cpu_clock_get (const clockid_t which_clock, +struct timespec *tp) {return posix_cpu_clock_get (THREAD_CLOCK , tp); }
@@ -1545,7 +1549,7 @@ static int thread_cpu_timer_create(struc timer->it_clock =THREAD_CLOCK ;return posix_cpu_timer_create (timer); } -static int thread_cpu_nsleep (clockid_t which_clock,int flags, +static int thread_cpu_nsleep (const clockid_t which_clock,int flags,struct timespec *rqtp) {return -EINVAL ;
kernel/posix-timers.c +21 -17
@@ -151,7 +151,7 @@ static void posix_timer_fn(unsigned longstatic u64 do_posix_clock_monotonic_gettime_parts (struct timespec *tp,struct timespec *mo);int do_posix_clock_monotonic_gettime (struct timespec *tp); -static int do_posix_clock_monotonic_get (clockid_t ,struct timespec *tp); +static int do_posix_clock_monotonic_get (const clockid_t ,struct timespec *tp);static struct k_itimer *lock_timer (timer_t timer_id,unsigned long *flags);
@@ -176,7 +176,7 @@ static inline void unlock_timer(struct k* the function pointer CALL in struct k_clock. */ -static inline int common_clock_getres (clockid_t which_clock, +static inline int common_clock_getres (const clockid_t which_clock,struct timespec *tp) { tp->tv_sec =0 ;
@@ -184,13 +184,15 @@ static inline int common_clock_getres(clreturn 0 ; } -static inline int common_clock_get (clockid_t which_clock,struct timespec *tp) +static inline int common_clock_get (const clockid_t which_clock, +struct timespec *tp) {getnstimeofday (tp);return 0 ; } -static inline int common_clock_set (clockid_t which_clock,struct timespec *tp) +static inline int common_clock_set (const clockid_t which_clock, +struct timespec *tp) {return do_sys_settimeofday (tp,NULL ); }
@@ -207,7 +209,7 @@ static inline int common_timer_create(st/* * These ones are defined below. */ -static int common_nsleep (clockid_t ,int flags,struct timespec *t); +static int common_nsleep (const clockid_t ,int flags,struct timespec *t);static void common_timer_get (struct k_itimer *,struct itimerspec *);static int common_timer_set (struct k_itimer *,int ,struct itimerspec *,struct itimerspec *);
@@ -216,7 +218,7 @@ static int common_timer_del(struct k_iti/* * Return nonzero iff we know a priori this clockid_t value is bogus. */ -static inline int invalid_clockid (clockid_t which_clock) +static inline int invalid_clockid (const clockid_t which_clock) {if (which_clock <0 )/* CPU clock, posix_cpu_* will check it */ return 0 ;
@@ -522,7 +524,7 @@ static inline struct task_struct * good_return rtn; } -void register_posix_clock (clockid_t clock_id,struct k_clock *new_clock) +void register_posix_clock (const clockid_t clock_id,struct k_clock *new_clock) {if ((unsigned ) clock_id >=MAX_CLOCKS ) { printk("POSIX clock register failed for clock_id %d\n",
@@ -568,7 +570,7 @@ static void release_posix_timer(struct k/* Create a POSIX.1b interval timer. */ asmlinkage long -sys_timer_create (clockid_t which_clock, +sys_timer_create (const clockid_t which_clock,struct sigevent __user *timer_event_spec,timer_t __user * created_timer_id) {
@@ -1195,7 +1197,8 @@ static u64 do_posix_clock_monotonic_gettreturn jiff; } -static int do_posix_clock_monotonic_get (clockid_t clock,struct timespec *tp) +static int do_posix_clock_monotonic_get (const clockid_t clock, +struct timespec *tp) {struct timespec wall_to_mono;
@@ -1212,7 +1215,7 @@ int do_posix_clock_monotonic_gettime(strreturn do_posix_clock_monotonic_get (CLOCK_MONOTONIC , tp); } -int do_posix_clock_nosettime (clockid_t clockid,struct timespec *tp) +int do_posix_clock_nosettime (const clockid_t clockid,struct timespec *tp) {return -EINVAL ; }
@@ -1224,7 +1227,8 @@ int do_posix_clock_notimer_create(struct }EXPORT_SYMBOL_GPL (do_posix_clock_notimer_create); -int do_posix_clock_nonanosleep (clockid_t clock,int flags,struct timespec *t) +int do_posix_clock_nonanosleep (const clockid_t clock,int flags, +struct timespec *t) {#ifndef ENOTSUP return -EOPNOTSUPP ;/* aka ENOTSUP in userland for POSIX */
@@ -1234,8 +1238,8 @@ int do_posix_clock_nonanosleep(clockid_t }EXPORT_SYMBOL_GPL (do_posix_clock_nonanosleep); -asmlinkage long -sys_clock_settime (clockid_t which_clock,const struct timespec __user *tp) +asmlinkage long sys_clock_settime (const clockid_t which_clock, +const struct timespec __user *tp) {struct timespec new_tp;
@@ -1248,7 +1252,7 @@ sys_clock_settime(clockid_t which_clock, }asmlinkage long -sys_clock_gettime (clockid_t which_clock,struct timespec __user *tp) +sys_clock_gettime (const clockid_t which_clock,struct timespec __user *tp) {struct timespec kernel_tp;int error;
@@ -1265,7 +1269,7 @@ sys_clock_gettime(clockid_t which_clock, }asmlinkage long -sys_clock_getres (clockid_t which_clock,struct timespec __user *tp) +sys_clock_getres (const clockid_t which_clock,struct timespec __user *tp) {struct timespec rtn_tp;int error;
@@ -1387,7 +1391,7 @@ void clock_was_set(void)long clock_nanosleep_restart (struct restart_block *restart_block);asmlinkage long -sys_clock_nanosleep (clockid_t which_clock,int flags, +sys_clock_nanosleep (const clockid_t which_clock,int flags,const struct timespec __user *rqtp,struct timespec __user *rmtp) {
@@ -1419,7 +1423,7 @@ sys_clock_nanosleep(clockid_t which_cloc } -static int common_nsleep (clockid_t which_clock, +static int common_nsleep (const clockid_t which_clock,int flags,struct timespec *tsave) {struct timespec t, dum;
--
PATCH 10/43 Coding style and white space cleanup posix-timer.h
In reply to a message not in the archiveplain text document attachment (posix-timer-h-cleanup.patch)
- style/whitespace/macro cleanups of posix-timers.h
include/linux/posix-timers.h | 78 +++++++++++++++++++++++-------------------- 1 files changed, 43 insertions(+), 35 deletions(-)
include/linux/posix-timers.h +43 -35
@@ -42,7 +42,7 @@ struct k_itimer {timer_t it_id;/* timer id */ int it_overrun;/* overrun on pending signal */ int it_overrun_last;/* overrun on last delivered signal */ -int it_requeue_pending;/* waiting to requeue this timer */ +int it_requeue_pending;/* waiting to requeue this timer */ #define REQUEUE_PENDING 1int it_sigev_notify;/* notify word of sigevent struct */ int it_sigev_signo;/* signo word of sigevent struct */
@@ -52,8 +52,10 @@ struct k_itimer {union {struct {struct timer_list timer; -struct list_head abs_timer_entry;/* clock abs_timer_list */ -struct timespec wall_to_prev;/* wall_to_monotonic used when set */ +/* clock abs_timer_list: */ +struct list_head abs_timer_entry; +/* wall_to_monotonic used when set: */ +struct timespec wall_to_prev;unsigned long incr;/* interval in jiffies */ } real;struct cpu_timer_list cpu;
@@ -70,14 +72,16 @@ struct k_clock_abs {struct list_head list;spinlock_t lock; }; +struct k_clock { -int res;/* in nano seconds */ +int res;/* in nanoseconds */ int (*clock_getres) (const clockid_t which_clock,struct timespec *tp);struct k_clock_abs *abs_struct;int (*clock_set) (const clockid_t which_clock,struct timespec * tp);int (*clock_get) (const clockid_t which_clock,struct timespec * tp);int (*timer_create) (struct k_itimer *timer); -int (*nsleep) (const clockid_t which_clock,int flags,struct timespec *); +int (*nsleep) (const clockid_t which_clock,int flags, +struct timespec *);int (*timer_set) (struct k_itimer * timr,int flags,struct itimerspec * new_setting,struct itimerspec * old_setting);
@@ -89,7 +93,7 @@ struct k_clock {void register_posix_clock (const clockid_t clock_id,struct k_clock *new_clock); -/* Error handlers for timer_create, nanosleep and settime */ +/* error handlers for timer_create, nanosleep and settime */ int do_posix_clock_notimer_create (struct k_itimer *timer);int do_posix_clock_nonanosleep (const clockid_t ,int flags,struct timespec *);int do_posix_clock_nosettime (const clockid_t ,struct timespec *tp);
@@ -101,39 +105,43 @@ struct now_struct {unsigned long jiffies; }; -#define posix_get_now (now) (now)->jiffies = jiffies; +#define posix_get_now (now) \ + do { (now)->jiffies = jiffies; } while (0) +#define posix_time_before (timer, now) \ time_before((timer)->expires, (now)->jiffies)#define posix_bump_timer (timr, now) \ - do { \ - long delta, orun; \ - delta = now.jiffies - (timr)->it.real.timer.expires; \ - if (delta >= 0) { \ - orun = 1 + (delta / (timr)->it.real.incr); \ - (timr)->it.real.timer.expires += \ - orun * (timr)->it.real.incr; \ - (timr)->it_overrun += orun; \ - } \ - }while (0) - -int posix_cpu_clock_getres (const clockid_t which_clock,struct timespec *); -int posix_cpu_clock_get (const clockid_t which_clock,struct timespec *); -int posix_cpu_clock_set (const clockid_t which_clock,const struct timespec *tp); -int posix_cpu_timer_create (struct k_itimer *); -int posix_cpu_nsleep (const clockid_t ,int ,struct timespec *); -int posix_cpu_timer_set (struct k_itimer *,int , -struct itimerspec *,struct itimerspec *); -int posix_cpu_timer_del (struct k_itimer *); -void posix_cpu_timer_get (struct k_itimer *,struct itimerspec *); - -void posix_cpu_timer_schedule (struct k_itimer *); - -void run_posix_cpu_timers (struct task_struct *); -void posix_cpu_timers_exit (struct task_struct *); -void posix_cpu_timers_exit_group (struct task_struct *); + do { \ + long delta, orun; \ + \ + delta = (now).jiffies - (timr)->it.real.timer.expires; \ + if (delta >= 0) { \ + orun = 1 + (delta / (timr)->it.real.incr); \ + (timr)->it.real.timer.expires += \ + orun * (timr)->it.real.incr; \ + (timr)->it_overrun += orun; \ + } \ + } while (0) + +int posix_cpu_clock_getres (const clockid_t which_clock,struct timespec *ts); +int posix_cpu_clock_get (const clockid_t which_clock,struct timespec *ts); +int posix_cpu_clock_set (const clockid_t which_clock,const struct timespec *ts); +int posix_cpu_timer_create (struct k_itimer *timer); +int posix_cpu_nsleep (const clockid_t which_clock,int flags, +struct timespec *ts); +int posix_cpu_timer_set (struct k_itimer *timer,int flags, +struct itimerspec *new,struct itimerspec *old); +int posix_cpu_timer_del (struct k_itimer *timer); +void posix_cpu_timer_get (struct k_itimer *timer,struct itimerspec *itp); + +void posix_cpu_timer_schedule (struct k_itimer *timer); + +void run_posix_cpu_timers (struct task_struct *task); +void posix_cpu_timers_exit (struct task_struct *task); +void posix_cpu_timers_exit_group (struct task_struct *task); -void set_process_cpu_timer (struct task_struct *,unsigned int , -cputime_t *,cputime_t *); +void set_process_cpu_timer (struct task_struct *task,unsigned int clock_idx, +cputime_t *newval,cputime_t *oldval);#endif
--
PATCH 11/43 Create timespec_valid macro
In reply to a message not in the archiveplain text document attachment (introduce-timespec-valid.patch)
- add timespec_valid(ts) [returns false if the timespec is denorm]
include/linux/time.h | 6 ++++++ kernel/posix-timers.c | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-)
include/linux/time.h +6 -0
@@ -44,6 +44,12 @@ extern unsigned long mktime(const unsignextern void set_normalized_timespec (struct timespec *ts,time_t sec,long nsec); +/* +* Returns true if the timespec is norm, false if denorm: +*/ +#define timespec_valid (ts) \ + (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) +extern struct timespec xtime;extern struct timespec wall_to_monotonic;extern seqlock_t xtime_lock;
kernel/posix-timers.c +2 -3
@@ -712,8 +712,7 @@ out:*/ static int good_timespec (const struct timespec *ts) { -if ((!ts) || (ts->tv_sec <0 ) || - ((unsigned ) ts->tv_nsec >=NSEC_PER_SEC )) +if ((!ts) || !timespec_valid (ts))return 0 ;return 1 ; }
@@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t whicif (copy_from_user (&t, rqtp,sizeof (struct timespec )))return -EFAULT ; -if ((unsigned ) t.tv_nsec >=NSEC_PER_SEC || t.tv_sec <0 ) +if (!timespec_valid (&t))return -EINVAL ;/*
--
PATCH 12/43 Check user space timespec in do_sys_settimeofday
In reply to a message not in the archiveplain text document attachment (sys-settimeofday-check-timespec.patch)
- Check if the timespec which is provided from user space is normalized.
kernel/time.c | 3 +++ 1 files changed, 3 insertions(+)
kernel/time.c +3 -0
@@ -154,6 +154,9 @@ int do_sys_settimeofday(struct timespecstatic int firsttime =1 ;int error =0 ; +if (!timespec_valid (tv)) +return -EINVAL ; + error =security_settime (tv, tz);if (error)return error;
--
PATCH 13/43 Introduce nsec_t type and conversion functions
In reply to a message not in the archiveplain text document attachment (nsec-t.patch)
- introduce the nsec_t type
- basic nsec conversion routines: timespec_to_ns(), timeval_to_ns(), ns_to_timespec(), ns_to_timeval().
include/linux/time.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ kernel/time.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+)
include/linux/time.h +47 -0
@@ -50,6 +50,12 @@ extern void set_normalized_timespec(stru#define timespec_valid (ts) \ (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) +/* +* 64-bit nanosec type. Large enough to span 292+ years in nanosecond +* resolution. Ought to be enough for a while. +*/ +typedef s64 nsec_t ; +extern struct timespec xtime;extern struct timespec wall_to_monotonic;extern seqlock_t xtime_lock;
@@ -78,6 +84,47 @@ extern void getnstimeofday(struct timespextern struct timespec timespec_trunc (struct timespec t,unsigned gran); +/** +* timespec_to_ns - Convert timespec to nanoseconds +* @ts: pointer to the timespec variable to be converted +* +* Returns the scalar nanosecond representation of the timespec +* parameter. +*/ +static inline nsec_t timespec_to_ns (const struct timespec *ts) +{ +return ((nsec_t ) ts->tv_sec *NSEC_PER_SEC ) + ts->tv_nsec; +} + +/** +* timeval_to_ns - Convert timeval to nanoseconds +* @ts: pointer to the timeval variable to be converted +* +* Returns the scalar nanosecond representation of the timeval +* parameter. +*/ +static inline nsec_t timeval_to_ns (const struct timeval *tv) +{ +return ((nsec_t ) tv->tv_sec *NSEC_PER_SEC ) + + tv->tv_usec *NSEC_PER_USEC ; +} + +/** +* ns_to_timespec - Convert nanoseconds to timespec +* @nsec: the nanoseconds value to be converted +* +* Returns the timespec representation of the nsec parameter. +*/ +extern struct timespec ns_to_timespec (const nsec_t nsec); + +/** +* ns_to_timeval - Convert nanoseconds to timeval +* @nsec: the nanoseconds value to be converted +* +* Returns the timeval representation of the nsec parameter. +*/ +extern struct timeval ns_to_timeval (const nsec_t nsec); +#endif /* __KERNEL__ */ #define NFDBITS __NFDBITS
kernel/time.c +36 -0
@@ -630,6 +630,42 @@ void set_normalized_timespec(struct time ts->tv_nsec = nsec; } +/** +* ns_to_timespec - Convert nanoseconds to timespec +* @nsec: the nanoseconds value to be converted +* +* Returns the timespec representation of the nsec parameter. +*/ +inline struct timespec ns_to_timespec (const nsec_t nsec) +{ +struct timespec ts; + +if (nsec) + ts.tv_sec =div_long_long_rem_signed (nsec,NSEC_PER_SEC , + &ts.tv_nsec); +else + ts.tv_sec = ts.tv_nsec =0 ; + +return ts; +} + +/** +* ns_to_timeval - Convert nanoseconds to timeval +* @nsec: the nanoseconds value to be converted +* +* Returns the timeval representation of the nsec parameter. +*/ +struct timeval ns_to_timeval (const nsec_t nsec) +{ +struct timespec ts =ns_to_timespec (nsec); +struct timeval tv; + + tv.tv_sec = ts.tv_sec; + tv.tv_usec = (suseconds_t ) ts.tv_nsec /1000 ; + +return tv; +} +#if (BITS_PER_LONG <64 )u64 get_jiffies_64 (void ) {
--
PATCH 14/43 Introduce ktime_t time format
In reply to a message not in the archiveplain text document attachment (ktime-t.patch)
- introduce ktime_t: nanosecond-resolution time format.
- eliminate the plain s64 scalar type, and always use the union. This simplifies the arithmetics. Idea from Roman Zippel.
include/linux/ktime.h | 310 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 310 insertions(+)
include/linux/ktime.h new file +310 -0
@@ -0,0 +1,310 @@ +/* +* include/linux/ktime.h +* +* ktime_t - nanosecond-resolution time format. +* +* Copyright(C) 2005, Thomas Gleixner <[email protected]> +* Copyright(C) 2005, Red Hat, Inc., Ingo Molnar +* +* data type definitions, declarations, prototypes and macros. +* +* Started by: Thomas Gleixner and Ingo Molnar +* +* For licencing details see kernel-base/COPYING +*/ +#ifndef _LINUX_KTIME_H +#define _LINUX_KTIME_H + +#include <linux/time.h> +#include <linux/jiffies.h> + +/* +* ktime_t: +* +* On 64-bit CPUs a single 64-bit variable is used to store the ktimers +* internal representation of time values in scalar nanoseconds. The +* design plays out best on 64-bit CPUs, where most conversions are +* NOPs and most arithmetic ktime_t operations are plain arithmetic +* operations. +* +* On 32-bit CPUs an optimized representation of the timespec structure +* is used to avoid expensive conversions from and to timespecs. The +* endian-aware order of the tv struct members is choosen to allow +* mathematical operations on the tv64 member of the union too, which +* for certain operations produces better code. +* +* For architectures with efficient support for 64/32-bit conversions the +* plain scalar nanosecond based representation can be selected by the +* config switch CONFIG_KTIME_SCALAR. +*/ +typedef union { +s64 tv64; +#if BITS_PER_LONG !=64 && !defined(CONFIG_KTIME_SCALAR ) +struct { +# ifdef __BIG_ENDIAN +s32 sec, nsec; +# else +s32 nsec, sec; +# endif + } tv; +#endif +}ktime_t ; + +#define KTIME_MAX (~((u64)1 << 63)) + +/* +* ktime_t definitions when using the 64-bit scalar representation: +*/ + +#if (BITS_PER_LONG ==64 ) || defined(CONFIG_KTIME_SCALAR ) + +/* Define a ktime_t variable and initialize it to zero: */ +#define DEFINE_KTIME (kt) ktime_t kt = { .tv64 = 0 } + +/** +* ktime_set - Set a ktime_t variable from a seconds/nanoseconds value +* +* @secs: seconds to set +* @nsecs: nanoseconds to set +* +* Return the ktime_t representation of the value +*/ +static inline ktime_t ktime_set (const long secs,const unsigned long nsecs) +{ +return (ktime_t ) { .tv64 = (s64 )secs *NSEC_PER_SEC + (s64 )nsecs }; +} + +/* +* The following 3 macros are used for the nanosleep restart handling +* to store the "low" and "high" part of a 64-bit ktime variable. +* (on 32-bit CPUs the restart block has 32-bit fields, so we have to +* split the 64-bit value up into two pieces) +* +* In the scalar representation we have to split up the 64-bit scalar: +*/ + +/* Set the "low" and "high" part of a ktime_t variable: */ +static inline ktime_t +ktime_set_low_high (const unsigned long low,const unsigned long high) +{ +return (ktime_t ) { .tv64 = (s64 )low | ((s64 )high <<32 ) }; +} + +/* Get the "low" part of a ktime_t variable: */ +#define ktime_get_low (kt) ((kt).tv64 & 0xFFFFFFFF) + +/* Get the "high" part of a ktime_t variable: */ +#define ktime_get_high (kt) ((kt).tv64 >> 32) + +/* Subtract two ktime_t variables. rem = lhs -rhs: */ +#define ktime_sub (lhs, rhs) \ + ({ (ktime_t){ .tv64 = (lhs).tv64 - (rhs).tv64 }; }) + +/* Add two ktime_t variables. res = lhs + rhs: */ +#define ktime_add (lhs, rhs) \ + ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; }) + +/* +* Add a ktime_t variable and a scalar nanosecond value. +* res = kt + nsval: +*/ +#define ktime_add_ns (kt, nsval) \ + ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) + +/* convert a timespec to ktime_t format: */ +#define timespec_to_ktime (ts) ktime_set((ts).tv_sec, (ts).tv_nsec) + +/* convert a timeval to ktime_t format: */ +#define timeval_to_ktime (tv) ktime_set((tv).tv_sec, (tv).tv_usec * 1000) + +/* Map the ktime_t to timespec conversion to ns_to_timespec function */ +#define ktime_to_timespec (kt) ns_to_timespec((kt).tv64) + +/* Map the ktime_t to timeval conversion to ns_to_timeval function */ +#define ktime_to_timeval (kt) ns_to_timeval((kt).tv64) + +/* Map the ktime_t to clock_t conversion to the inline in jiffies.h: */ +#define ktime_to_clock_t (kt) nsec_to_clock_t((kt).tv64) + +/* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */ +#define ktime_to_ns (kt) ((kt).tv64) + +#else + +/* +* Helper macros/inlines to get the ktime_t math right in the timespec +* representation. The macros are sometimes ugly - their actual use is +* pretty okay-ish, given the circumstances. We do all this for +* performance reasons. The pure scalar nsec_t based code was nice and +* simple, but created too many 64-bit / 32-bit conversions and divisions. +* +* Be especially aware that negative values are represented in a way +* that the tv.sec field is negative and the tv.nsec field is greater +* or equal to zero but less than nanoseconds per second. This is the +* same representation which is used by timespecs. +* +* tv.sec < 0 and 0 >= tv.nsec < NSEC_PER_SEC +*/ + +/* Define a ktime_t variable and initialize it to zero: */ +#define DEFINE_KTIME (kt) ktime_t kt = { .tv64 = 0 } + +/* Set a ktime_t variable to a value in sec/nsec representation: */ +static inline ktime_t ktime_set (const long secs,const unsigned long nsecs) +{ +return (ktime_t ) { .tv = { .sec = secs, .nsec = nsecs } }; +} + +/* +* The following 3 macros are used for the nanosleep restart handling +* to store the "low" and "high" part of a 64-bit ktime variable. +* (on 32-bit CPUs the restart block has 32-bit fields, so we have to +* split the 64-bit value up into two pieces) +* +* In the union type representation this is just storing and restoring +* the sec and nsec members of the tv structure: +*/ + +/* Set the "low" and "high" part of a ktime_t variable: */ +#define ktime_set_low_high (l, h) ktime_set(h, l) + +/* Get the "low" part of a ktime_t variable: */ +#define ktime_get_low (kt) (kt).tv.nsec + +/* Get the "high" part of a ktime_t variable: */ +#define ktime_get_high (kt) (kt).tv.sec + +/** +* ktime_sub - subtract two ktime_t variables +* +* @lhs: minuend +* @rhs: subtrahend +* +* Returns the remainder of the substraction +*/ +static inline ktime_t ktime_sub (const ktime_t lhs,const ktime_t rhs) +{ +ktime_t res; + + res.tv64 = lhs.tv64 - rhs.tv64; +if (res.tv.nsec <0 ) + res.tv.nsec +=NSEC_PER_SEC ; + +return res; +} + +/** +* ktime_add - add two ktime_t variables +* +* @add1: addend1 +* @add2: addend2 +* +* Returns the sum of addend1 and addend2 +*/ +static inline ktime_t ktime_add (const ktime_t add1,const ktime_t add2) +{ +ktime_t res; + + res.tv64 = add1.tv64 + add2.tv64; +/* +* performance trick: the (u32) -NSEC gives 0x00000000Fxxxxxxx +* so we subtract NSEC_PER_SEC and add 1 to the upper 32 bit. +* +* it's equivalent to: +* tv.nsec -= NSEC_PER_SEC +* tv.sec ++; +*/ +if (res.tv.nsec >=NSEC_PER_SEC ) + res.tv64 += (u32)-NSEC_PER_SEC ; + +return res; +} + +/** +* ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable +* +* @kt: addend +* @nsec: the scalar nsec value to add +* +* Returns the sum of kt and nsec in ktime_t format +*/ +extern ktime_t ktime_add_ns (const ktime_t kt,u64 nsec); + +/** +* timespec_to_ktime - convert a timespec to ktime_t format +* +* @ts: the timespec variable to convert +* +* Returns a ktime_t variable with the converted timespec value +*/ +static inline ktime_t timespec_to_ktime (const struct timespec ts) +{ +return (ktime_t ) { .tv = { .sec = (s32 )ts.tv_sec, + .nsec = (s32 )ts.tv_nsec } }; +} + +/** +* timeval_to_ktime - convert a timeval to ktime_t format +* +* @tv: the timeval variable to convert +* +* Returns a ktime_t variable with the converted timeval value +*/ +static inline ktime_t timeval_to_ktime (const struct timeval tv) +{ +return (ktime_t ) { .tv = { .sec = (s32 )tv.tv_sec, + .nsec = (s32 )tv.tv_usec *1000 } }; +} + +/** +* ktime_to_timespec - convert a ktime_t variable to timespec format +* +* @kt: the ktime_t variable to convert +* +* Returns the timespec representation of the ktime value +*/ +static inline struct timespec ktime_to_timespec (const ktime_t kt) +{ +return (struct timespec ) { .tv_sec = (time_t ) kt.tv.sec, + .tv_nsec = (long ) kt.tv.nsec }; +} + +/** +* ktime_to_timeval - convert a ktime_t variable to timeval format +* +* @kt: the ktime_t variable to convert +* +* Returns the timeval representation of the ktime value +*/ +static inline struct timeval ktime_to_timeval (const ktime_t kt) +{ +return (struct timeval ) { + .tv_sec = (time_t ) kt.tv.sec, + .tv_usec = (suseconds_t) (kt.tv.nsec /NSEC_PER_USEC ) }; +} + +/** +* ktime_to_clock_t - convert a ktime_t variable to clock_t format +* @kt: the ktime_t variable to convert +* +* Returns a clock_t variable with the converted value +*/ +static inline clock_t ktime_to_clock_t (const ktime_t kt) +{ +return nsec_to_clock_t ( (u64 ) kt.tv.sec *NSEC_PER_SEC + kt.tv.nsec); +} + +/** +* ktime_to_ns - convert a ktime_t variable to scalar nanoseconds +* @kt: the ktime_t variable to convert +* +* Returns the scalar nanoseconds representation of kt +*/ +static inline u64 ktime_to_ns (const ktime_t kt) +{ +return (u64 ) kt.tv.sec *NSEC_PER_SEC + kt.tv.nsec; +} + +#endif + +#endif
--
PATCH 15/43 ktimer core code
In reply to a message not in the archiveplain text document attachment (ktimer-core.patch)
- ktimer subsystem core. It is initialized at bootup and expired by the timer interrupt, but is otherwise not utilized by any other subsystem yet.
include/linux/ktime.h | 21 + include/linux/ktimer.h | 170 +++++++++ init/main.c | 3 kernel/Makefile | 3 kernel/ktimer.c | 905 +++++++++++++++++++++++++++++++++++++++++++++++++ kernel/timer.c | 2 6 files changed, 1103 insertions(+), 1 deletion(-)
include/linux/ktime.h +21 -0
@@ -307,4 +307,25 @@ static inline u64 ktime_to_ns(const ktim#endif +/* +* The resolution of the clocks. The resolution value is returned in +* the clock_getres() system call to give application programmers an +* idea of the (in)accuracy of timers. Timer values are rounded up to +* this resolution values. +*/ +#define KTIME_REALTIME_RES (NSEC_PER_SEC/HZ) +#define KTIME_MONOTONIC_RES (NSEC_PER_SEC/HZ) + +/* Get the monotonic time in ktime_t format: */ +extern ktime_t ktime_get (void ); + +/* Get the real (wall-) time in ktime_t format: */ +extern ktime_t ktime_get_real (void ); + +/* Get the monotonic time in timespec format: */ +extern void ktime_get_ts (struct timespec *ts); + +/* Get the real (wall-) time in timespec format: */ +#define ktime_get_real_ts (ts) getnstimeofday(ts) +#endif
include/linux/ktimer.h new file +170 -0
170 lines not on this page · raw message
init/main.c +3 -0
@@ -47,6 +47,8 @@#include <linux/rmap.h> #include <linux/mempolicy.h> #include <linux/key.h> +#include <linux/ktimer.h> +#include <net/sock.h> #include <asm/io.h>
@@ -487,6 +489,7 @@ asmlinkage void __init start_kernel(voidinit_IRQ ();pidhash_init ();init_timers (); +ktimers_init ();softirq_init ();time_init ();
kernel/Makefile +2 -1
@@ -7,7 +7,8 @@ obj-y = sched.o fork.o exec_domain.o sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ - kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o + kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o \ + ktimer.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/ktimer.c new file +905 -0
905 lines not on this page · raw message
kernel/timer.c +2 -0
@@ -30,6 +30,7 @@#include <linux/thread_info.h> #include <linux/time.h> #include <linux/jiffies.h> +#include <linux/ktimer.h> #include <linux/posix-timers.h> #include <linux/cpu.h> #include <linux/syscalls.h>
@@ -857,6 +858,7 @@ static void run_timer_softirq(struct sof {tvec_base_t *base = &__get_cpu_var (tvec_bases); +ktimer_run_queues ();if (time_after_eq (jiffies, base->timer_jiffies))__run_timers (base); }
--
PATCH 16/43 ktimer documentation
In reply to a message not in the archiveplain text document attachment (ktimer-documentation.patch)
- add ktimer docbook and design document
Documentation/DocBook/kernel-api.tmpl | 5 Documentation/ktimers.txt | 239 ++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+)
Documentation/DocBook/kernel-api.tmpl +5 -0
@@ -54,6 +54,11 @@ !Ekernel/sched.c !Ekernel/timer.c </sect1> + <sect1><title>High-precision timers</title> +!Iinclude/linux/ktime.h +!Iinclude/linux/ktimer.h +!Ekernel/ktimer.c + </sect1> <sect1><title>Internal Functions</title> !Ikernel/exit.c !Ikernel/signal.c
Documentation/ktimers.txt new file +239 -0
239 lines not on this page · raw message
--
PATCH 17/43 Switch itimers to ktimer
In reply to a message not in the archiveplain text document attachment (ktimer-convert-itimer.patch)
- switch itimers to a ktimers-based implementation
fs/exec.c | 7 +-- fs/proc/array.c | 6 +- include/linux/sched.h | 4 - include/linux/timer.h | 2 kernel/exit.c | 2 kernel/fork.c | 5 -- kernel/itimer.c | 108 ++++++++++++++++++++++---------------------------- 7 files changed, 62 insertions(+), 72 deletions(-)
fs/exec.c +4 -3
@@ -642,10 +642,11 @@ static inline int de_thread(struct task_* synchronize with any firing (by calling del_timer_sync) * before we can safely let the old group leader die. */ - sig->real_timer.data = (unsigned long )current; + sig->real_timer.data = current;spin_unlock_irq (lock); -if (del_timer_sync (&sig->real_timer)) -add_timer (&sig->real_timer); +if (ktimer_cancel (&sig->real_timer)) +ktimer_start (&sig->real_timer,NULL , +KTIMER_RESTART |KTIMER_NOCHECK );spin_lock_irq (lock); }while (atomic_read (&sig->count) > count) {
fs/proc/array.c +3 -3
@@ -330,7 +330,7 @@ static int do_task_stat(struct task_struunsigned long min_flt =0 , maj_flt =0 ;cputime_t cutime, cstime, utime, stime;unsigned long rsslim =0 ; -unsigned long it_real_value =0 ; +DEFINE_KTIME (it_real_value);struct task_struct *t;char tcomm[sizeof (task->comm)];
@@ -386,7 +386,7 @@ static int do_task_stat(struct task_stru utime =cputime_add (utime, task->signal->utime); stime =cputime_add (stime, task->signal->stime); } - it_real_value = task->signal->it_real_value; + it_real_value = task->signal->real_timer.expires; } ppid =pid_alive (task) ? task->group_leader->real_parent->tgid :0 ;read_unlock (&tasklist_lock);
@@ -435,7 +435,7 @@ static int do_task_stat(struct task_stru priority, nice, num_threads, -jiffies_to_clock_t (it_real_value), + (long )ktime_to_clock_t (it_real_value), start_time, vsize, mm ? get_mm_rss(mm) : 0,
include/linux/sched.h +2 -2
@@ -104,6 +104,7 @@ extern unsigned long nr_iowait(void);#include <linux/param.h> #include <linux/resource.h> #include <linux/timer.h> +#include <linux/ktimer.h> #include <asm/processor.h>
@@ -402,8 +403,7 @@ struct signal_struct {struct list_head posix_timers;/* ITIMER_REAL timer for the process */ -struct timer_list real_timer; -unsigned long it_real_value, it_real_incr; +struct ktimer real_timer;/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ cputime_t it_prof_expires, it_virt_expires;
include/linux/timer.h +1 -1
@@ -96,6 +96,6 @@ static inline void add_timer(struct timeextern void init_timers (void );extern void run_local_timers (void ); -extern void it_real_fn (unsigned long ); +extern void it_real_fn (void *);#endif
kernel/exit.c +1 -1
@@ -842,7 +842,7 @@ fastcall NORET_TYPE void do_exit(long co } group_dead =atomic_dec_and_test (&tsk->signal->live);if (group_dead) { -del_timer_sync (&tsk->signal->real_timer); +ktimer_cancel (&tsk->signal->real_timer);exit_itimers (tsk->signal);acct_process (code); }
kernel/fork.c +2 -3
@@ -793,10 +793,9 @@ static inline int copy_signal(unsigned linit_sigpending (&sig->shared_pending);INIT_LIST_HEAD (&sig->posix_timers); - sig->it_real_value = sig->it_real_incr =0 ; +ktimer_init (&sig->real_timer); sig->real_timer.function = it_real_fn; - sig->real_timer.data = (unsigned long ) tsk; -init_timer (&sig->real_timer); + sig->real_timer.data = tsk; sig->it_virt_expires = cputime_zero; sig->it_virt_incr = cputime_zero;
kernel/itimer.c +49 -59
144 lines not on this page · raw message
--
PATCH 18/43 Remove now unnecessary includes
In reply to a message not in the archiveplain text document attachment (ktimer-cleanup-includes.patch)
- remove some now unnecessary includes
init/main.c | 2 -- kernel/timer.c | 1 - 2 files changed, 3 deletions(-)
init/main.c +0 -2
@@ -47,8 +47,6 @@#include <linux/rmap.h> #include <linux/mempolicy.h> #include <linux/key.h> -#include <linux/ktimer.h> -#include <net/sock.h> #include <asm/io.h>
kernel/timer.c +0 -1
@@ -30,7 +30,6 @@#include <linux/thread_info.h> #include <linux/time.h> #include <linux/jiffies.h> -#include <linux/ktimer.h> #include <linux/posix-timers.h> #include <linux/cpu.h> #include <linux/syscalls.h>
--
PATCH 19/43 Introduce ktimer_nanosleep APIs
In reply to a message not in the archiveplain text document attachment (ktimer-nanosleep-interface.patch)
- introduce the ktimer_nanosleep() and ktimer_nanosleep_real() APIs. Not yet used by any code.
include/linux/ktimer.h | 6 + kernel/ktimer.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+)
include/linux/ktimer.h +6 -0
@@ -155,6 +155,12 @@ extern ktime_t ktimer_round_timeval(consextern ktime_t ktimer_round_timespec (const struct ktimer *timer,const struct timespec *ts); +/* Precise sleep: */ +extern long ktimer_nanosleep (struct timespec *rqtp, +struct timespec __user *rmtp,const int mode); +extern long ktimer_nanosleep_real (struct timespec *rqtp, +struct timespec __user *rmtp,const int mode); +#ifdef CONFIG_SMP extern void wait_for_ktimer (const struct ktimer *timer);#else
kernel/ktimer.c +164 -0
170 lines not on this page · raw message
--
PATCH 20/43 Convert sys_nanosleep to ktimer_nanosleep
In reply to a message not in the archiveplain text document attachment (ktimer-convert-sys-nanosleep.patch)
- convert sys_nanosleep() to use ktimer_nanosleep()
kernel/ktimer.c | 14 ++++++++++++++ kernel/timer.c | 56 -------------------------------------------------------- 2 files changed, 14 insertions(+), 56 deletions(-)
kernel/ktimer.c +14 -0
@@ -969,6 +969,20 @@ long ktimer_nanosleep_real(struct timesp nanosleep_restart_real); } +asmlinkage long +sys_nanosleep (struct timespec __user *rqtp,struct timespec __user *rmtp) +{ +struct timespec tu; + +if (copy_from_user (&tu, rqtp,sizeof (tu))) +return -EFAULT ; + +if (!timespec_valid (&tu)) +return -EINVAL ; + +return ktimer_nanosleep (&tu, rmtp,KTIMER_REL ); +} +/* * Functions related to boot-time initialization: */
kernel/timer.c +0 -56
62 lines not on this page · raw message
--
PATCH 21/43 Switch clock_nanosleep to ktimer nanosleep API
In reply to a message not in the archiveplain text document attachment (ktimer-convert-posix-clock-nanosleep.patch)
- Switch clock_nanosleep to use the new nanosleep functions in ktimer.c
include/linux/posix-timers.h | 7 +- kernel/posix-cpu-timers.c | 23 ++++-- kernel/posix-timers.c | 150 +++++++------------------------------------ 3 files changed, 44 insertions(+), 136 deletions(-)
include/linux/posix-timers.h +4 -3
@@ -81,7 +81,7 @@ struct k_clock {int (*clock_get) (const clockid_t which_clock,struct timespec * tp);int (*timer_create) (struct k_itimer *timer);int (*nsleep) (const clockid_t which_clock,int flags, -struct timespec *); +struct timespec *,struct timespec __user *);int (*timer_set) (struct k_itimer * timr,int flags,struct itimerspec * new_setting,struct itimerspec * old_setting);
@@ -95,7 +95,8 @@ void register_posix_clock(const clockid_/* error handlers for timer_create, nanosleep and settime */ int do_posix_clock_notimer_create (struct k_itimer *timer); -int do_posix_clock_nonanosleep (const clockid_t ,int flags,struct timespec *); +int do_posix_clock_nonanosleep (const clockid_t ,int flags,struct timespec *, +struct timespec __user *);int do_posix_clock_nosettime (const clockid_t ,struct timespec *tp);/* function to call to trigger timer event */
@@ -129,7 +130,7 @@ int posix_cpu_clock_get(const clockid_tint posix_cpu_clock_set (const clockid_t which_clock,const struct timespec *ts);int posix_cpu_timer_create (struct k_itimer *timer);int posix_cpu_nsleep (const clockid_t which_clock,int flags, -struct timespec *ts); +struct timespec *rqtp,struct timespec __user *rmtp);int posix_cpu_timer_set (struct k_itimer *timer,int flags,struct itimerspec *new,struct itimerspec *old);int posix_cpu_timer_del (struct k_itimer *timer);
kernel/posix-cpu-timers.c +14 -9
@@ -1411,7 +1411,7 @@ void set_process_cpu_timer(struct task_sstatic long posix_cpu_clock_nanosleep_restart (struct restart_block *);int posix_cpu_nsleep (const clockid_t which_clock,int flags, -struct timespec *rqtp) +struct timespec *rqtp,struct timespec __user *rmtp) {struct restart_block *restart_block = ¤t_thread_info ()->restart_block;
@@ -1436,7 +1436,6 @@ int posix_cpu_nsleep(const clockid_t whi error =posix_cpu_timer_create (&timer); timer.it_process = current;if (!error) { -struct timespec __user *rmtp;static struct itimerspec zero_it;struct itimerspec it = { .it_value = *rqtp, .it_interval = {} };
@@ -1483,7 +1482,6 @@ int posix_cpu_nsleep(const clockid_t whi/* * Report back to the user the time still remaining. */ - rmtp = (struct timespec __user *) restart_block->arg1;if (rmtp !=NULL && !(flags &TIMER_ABSTIME ) &©_to_user (rmtp, &it.it_value,sizeof *rmtp))return -EFAULT ;
@@ -1491,6 +1489,7 @@ int posix_cpu_nsleep(const clockid_t whi restart_block->fn = posix_cpu_clock_nanosleep_restart;/* Caller already set restart_block->arg1 */ restart_block->arg0 = which_clock; + restart_block->arg1 = (unsigned long ) rmtp; restart_block->arg2 = rqtp->tv_sec; restart_block->arg3 = rqtp->tv_nsec;
@@ -1504,10 +1503,15 @@ static long posix_cpu_clock_nanosleep_restart(struct restart_block *restart_block) {clockid_t which_clock = restart_block->arg0; -struct timespec t = { .tv_sec = restart_block->arg2, - .tv_nsec = restart_block->arg3 }; +struct timespec __user *rmtp; +struct timespec t; + + rmtp = (struct timespec __user *) restart_block->arg1; + t.tv_sec = restart_block->arg2; + t.tv_nsec = restart_block->arg3; + restart_block->fn = do_no_restart_syscall; -return posix_cpu_nsleep (which_clock,TIMER_ABSTIME , &t); +return posix_cpu_nsleep (which_clock,TIMER_ABSTIME , &t, rmtp); }
@@ -1530,9 +1534,10 @@ static int process_cpu_timer_create(strureturn posix_cpu_timer_create (timer); }static int process_cpu_nsleep (const clockid_t which_clock,int flags, -struct timespec *rqtp) +struct timespec *rqtp, +struct timespec __user *rmtp) { -return posix_cpu_nsleep (PROCESS_CLOCK , flags, rqtp); +return posix_cpu_nsleep (PROCESS_CLOCK , flags, rqtp, rmtp); }static int thread_cpu_clock_getres (const clockid_t which_clock,struct timespec *tp)
@@ -1550,7 +1555,7 @@ static int thread_cpu_timer_create(strucreturn posix_cpu_timer_create (timer); }static int thread_cpu_nsleep (const clockid_t which_clock,int flags, -struct timespec *rqtp) +struct timespec *rqtp,struct timespec __user *rmtp) {return -EINVAL ; }
kernel/posix-timers.c +26 -124
178 lines not on this page · raw message
--
PATCH 22/43 Convert posix interval timers to use ktimers
In reply to a message not in the archiveplain text document attachment (ktimer-convert-posix-timers.patch)
- convert posix-timers.c to use ktimers
include/linux/ktimer.h | 7 include/linux/posix-timers.h | 121 +++++-- include/linux/time.h | 3 kernel/posix-timers.c | 690 +++++++++---------------------------------- 4 files changed, 246 insertions(+), 575 deletions(-)
include/linux/ktimer.h +7 -0
@@ -122,6 +122,13 @@ struct ktimer_base {#define KTIMER_POISON ((void *) 0x00100101) +/* +* clock_was_set() is a NOP for non- high-resolution systems. The +* time-sorted order guarantees that a timer does not expire early and +* is expired in the next softirq when the clock was advanced. +*/ +#define clock_was_set () do { } while (0) +/* Exported timer functions: */ /* Initialize timers: */
include/linux/posix-timers.h +88 -33
139 lines not on this page · raw message
include/linux/time.h +1 -2
@@ -73,8 +73,7 @@ struct timespec current_kernel_time(voidextern void do_gettimeofday (struct timeval *tv);extern int do_settimeofday (struct timespec *tv);extern int do_sys_settimeofday (struct timespec *tv,struct timezone *tz); -extern void clock_was_set (void );// call whenever the clock is set -extern int do_posix_clock_monotonic_gettime (struct timespec *tp); +extern void do_posix_clock_monotonic_gettime (struct timespec *ts);extern long do_utimes (char __user *filename,struct timeval *times);struct itimerval ; extern int do_setitimer(int which, struct itimerval *value,
kernel/posix-timers.c +150 -540
885 lines not on this page · raw message
--
PATCH 23/43 Simplify ktimers rearm code
In reply to a message not in the archiveplain text document attachment (ktimer-simplify-rearm.patch)
- Simplify the rearming code and expose the functionality so it can be used instead of forward_posix_timer(). This allows also to replace the posix-timer struct real by a simple ktimer structure.
The automatic rearming in the expiry code was modified to depend on the return value of the callback function. This is based on an idea of Roman Zippel.
include/linux/ktimer.h | 6 ++ include/linux/posix-timers.h | 92 -------------------------------------- include/linux/timer.h | 2 kernel/itimer.c | 5 +- kernel/ktimer.c | 103 ++++++++++++++++++++++++++++++++----------- kernel/posix-timers.c | 66 +++++++++++++++------------ 6 files changed, 123 insertions(+), 151 deletions(-)
include/linux/ktimer.h +5 -1
@@ -87,7 +87,7 @@ struct ktimer {ktime_t interval;int overrun;enum ktimer_state state; -void (*function)(void *); +int (*function)(void *);void *data;struct ktimer_base *base; };
@@ -156,6 +156,10 @@ static inline int ktimer_active(const streturn timer->state !=KTIMER_INACTIVE ; } +/* Forward a ktimer so it expires after now */ +extern void ktimer_forward (struct ktimer *timer, +const ktime_t interval,const ktime_t now); +/* Convert with rounding based on resolution of timer's clock: */ extern ktime_t ktimer_round_timeval (const struct ktimer *timer,const struct timeval *tv);
include/linux/posix-timers.h +1 -91
104 lines not on this page · raw message
include/linux/timer.h +1 -1
@@ -96,6 +96,6 @@ static inline void add_timer(struct timeextern void init_timers (void );extern void run_local_timers (void ); -extern void it_real_fn (void *); +extern int it_real_fn (void *);#endif
kernel/itimer.c +3 -2
@@ -129,9 +129,10 @@ asmlinkage long sys_getitimer(int which,/* * The timer is automagically restarted, when interval != 0 */ -void it_real_fn (void *data) +int it_real_fn (void *data) {send_group_sig_info (SIGALRM ,SEND_SIG_PRIV , data); +return KTIMER_REARM ; }int do_setitimer (int which,struct itimerval *value,struct itimerval *ovalue)
@@ -151,7 +152,7 @@ int do_setitimer(int which, struct itime ovalue->it_interval =ktime_to_timeval (timer->interval); } timer->interval =ktimer_round_timeval (timer, - &value->it_interval); + &value->it_interval); expires =timeval_to_ktime (value->it_value);if (expires.tv64 !=0 ) ktimer_restart(timer, &expires,
kernel/ktimer.c +77 -26
167 lines not on this page · raw message
kernel/posix-timers.c +36 -30
180 lines not on this page · raw message
--
PATCH 24/43 Split timeout code into kernel/ktimeout.c
In reply to a message not in the archiveplain text document attachment (ktimeout-c.patch)
- split the timeout implementation from kernel/timer.c, into kernel/ktimeout.c
kernel/Makefile | 2 kernel/ktimeout.c | 771 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/timer.c | 747 ---------------------------------------------------- 3 files changed, 773 insertions(+), 747 deletions(-)
kernel/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-y = sched.o fork.o exec_domain.o signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o \ - ktimer.o + ktimer.o ktimeout.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/ktimeout.c new file +771 -0
771 lines not on this page · raw message
kernel/timer.c +1 -746
789 lines not on this page · raw message
--
PATCH 25/43 Create ktimeout.h and move timer.h code into it
In reply to a message not in the archiveplain text document attachment (ktimeout-h.patch)
- introduce ktimeout.h and move the timeout implementation into it, as-is.
- keep timer.h for compatibility
include/linux/ktimeout.h | 100 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/timer.h | 96 +-------------------------------------------- 2 files changed, 103 insertions(+), 93 deletions(-)
include/linux/ktimeout.h new file +100 -0
@@ -0,0 +1,100 @@ +#ifndef _LINUX_KTIMEOUT_H +#define _LINUX_KTIMEOUT_H + +#include <linux/config.h> +#include <linux/list.h> +#include <linux/spinlock.h> +#include <linux/stddef.h> + +struct timer_base_s ; + +struct timer_list { +struct list_head entry; +unsigned long expires; + +void (*function)(unsigned long ); +unsigned long data; + +struct timer_base_s *base; +}; + +extern struct timer_base_s __init_timer_base; + +#define TIMER_INITIALIZER (_function, _expires, _data) { \ + .function = (_function), \ + .expires = (_expires), \ + .data = (_data), \ + .base = &__init_timer_base, \ + } + +#define DEFINE_TIMER (_name, _function, _expires, _data) \ + struct timer_list _name = \ + TIMER_INITIALIZER(_function, _expires, _data) + +void fastcall init_timer(struct timer_list * timer); + +static inline void setup_timer (struct timer_list * timer, +void (*function)(unsigned long ), +unsigned long data) +{ + timer->function = function; + timer->data = data; +init_timer (timer); +} + +/*** +* timer_pending - is a timer pending? +* @timer: the timer in question +* +* timer_pending will tell whether a given timer is currently pending, +* or not. Callers must ensure serialization wrt. other operations done +* to this timer, eg. interrupt contexts, or other CPUs on SMP. +* +* return value: 1 if the timer is pending, 0 if not. +*/ +static inline int timer_pending (const struct timer_list * timer) +{ +return timer->entry.next !=NULL ; +} + +extern void add_timer_on (struct timer_list *timer,int cpu); +extern int del_timer (struct timer_list * timer); +extern int __mod_timer (struct timer_list *timer,unsigned long expires); +extern int mod_timer (struct timer_list *timer,unsigned long expires); + +extern unsigned long next_timer_interrupt (void ); + +/*** +* add_timer - start a timer +* @timer: the timer to be added +* +* The kernel will do a ->function(->data) callback from the +* timer interrupt at the ->expired point in the future. The +* current time is 'jiffies'. +* +* The timer's ->expired, ->function (and if the handler uses it, ->data) +* fields must be set prior calling this function. +* +* Timers with an ->expired field in the past will be executed in the next +* timer tick. +*/ +static inline void add_timer (struct timer_list *timer) +{ +BUG_ON (timer_pending (timer)); +__mod_timer (timer, timer->expires); +} + +#ifdef CONFIG_SMP +extern int try_to_del_timer_sync (struct timer_list *timer); +extern int del_timer_sync (struct timer_list *timer); +#else +# define try_to_del_timer_sync (t) del_timer(t) +# define del_timer_sync (t) del_timer(t) +#endif + +#define del_singleshot_timer_sync (t) del_timer_sync(t) + +extern void init_timers (void ); +extern void run_local_timers (void ); + +#endif
include/linux/timer.h +3 -93
104 lines not on this page · raw message
--
Re: [patch 25/43] Create ktimeout.h and move timer.h code into it
Quoted 4 lines · Thomas Gleixner
plain text document attachment (ktimeout-h.patch)
- introducektimeout.hand move the timeout implementation into it, as-is.
- keeptimer.hfor compatibility
...
If you do this, you should either immediately remove timer.h or add a #warning to this file.
Both cases imply changing all in-kernel users (which is anyway a good idea if we really want to rename this header).
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedRe: [patch 25/43] Create ktimeout.h and move timer.h code into it
Quoted 11 lines · Adrian Bunk
Quoted 4 lines · Thomas Gleixner
plain text document attachment (ktimeout-h.patch)
- introducektimeout.hand move the timeout implementation into it, as-is.
- keeptimer.hfor compatibility
...If you do this, you should either immediately remove
timer.hor add a #warning to this file.Both cases imply changing all in-kernel users (which is anyway a good idea if we really want to rename this header).
agreed, but we didnt want to be this drastic - we just wanted to demonstrate that a smooth transition (short of an overnight changeover) is possible as well.
also, we are very interested in suggestions to further improve the ktimeout APIs. The perfect time is when there are no direct users of it yet.
e.g. there's an interesting thought that Roman demonstrated in his ptimer queue: the elimination of the .data field from struct ktimer. An analogous thing could be done for timeouts as well: we do not actually need a .data field in a fair number of cases - the position of any data-context information can be recovered via container_of():
void timer_fn(struct ktimeout *kt)
{
struct my_data *ptr = container_of(kt, struct my_data, timer);
...
}for compatibility we could provide a "struct ktimeout_standalone" that embedds a .data field and a struct timeout - which would be equivalent to the current "struct ktimeout".
the advantage would be data-structure size reduction of one word per embedded ktimeout structure. We'd also have one less word per standalone timer that needs no data field. For standalone timeouts which do need a data field there would be no impact.
one downside is that it's not as straightforward to code as the current .data field.
Ingo
PATCH 26/43 Rename struct timer_list to struct ktimeout
In reply to a message not in the archiveplain text document attachment (ktimeout-struct-base.patch)
- change the main timeout data structure from 'struct timer_list' to 'struct ktimeout'
- introduce compatibility define for timer_list
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -8,7 +8,7 @@struct timer_base_s ; -struct timer_list { +struct ktimeout {struct list_head entry;unsigned long expires;
include/linux/timer.h +6 -1
@@ -1,9 +1,14 @@ +/* +* This file is a compatibility placeholder - it will go away. +*/ #ifndef _LINUX_TIMER_H#define _LINUX_TIMER_H/* -* This file is a compatibility placeholder - it will go away. +* Compatibility define to turn 'struct timer_list' into 'struct ktimeout': */ +#define timer_list ktimeout +#include <linux/ktimeout.h> extern int it_real_fn (void *);
--
PATCH 27/43 Convert timer_list users to ktimeout
In reply to a message not in the archiveplain text document attachment (ktimeout-struct-more.patch)
- convert all uses of struct timer_list in ktimeout.h over to struct ktimeout
include/linux/ktimeout.h | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-)
include/linux/ktimeout.h +11 -11
@@ -28,12 +28,12 @@ extern struct timer_base_s __init_timer_ }#define DEFINE_TIMER (_name, _function, _expires, _data) \ - struct timer_list _name = \ + struct ktimeout _name = \ TIMER_INITIALIZER(_function, _expires, _data) -void fastcall init_timer(struct timer_list * timer); +void fastcall init_timer(struct ktimeout * timer); -static inline void setup_timer (struct timer_list * timer, +static inline void setup_timer (struct ktimeout * timer,void (*function)(unsigned long ),unsigned long data) {
@@ -52,15 +52,15 @@ static inline void setup_timer(struct ti* * return value: 1 if the timer is pending, 0 if not. */ -static inline int timer_pending (const struct timer_list * timer) +static inline int timer_pending (const struct ktimeout * timer) {return timer->entry.next !=NULL ; } -extern void add_timer_on (struct timer_list *timer,int cpu); -extern int del_timer (struct timer_list * timer); -extern int __mod_timer (struct timer_list *timer,unsigned long expires); -extern int mod_timer (struct timer_list *timer,unsigned long expires); +extern void add_timer_on (struct ktimeout *timer,int cpu); +extern int del_timer (struct ktimeout * timer); +extern int __mod_timer (struct ktimeout *timer,unsigned long expires); +extern int mod_timer (struct ktimeout *timer,unsigned long expires);extern unsigned long next_timer_interrupt (void );
@@ -78,15 +78,15 @@ extern unsigned long next_timer_interrup* Timers with an ->expired field in the past will be executed in the next * timer tick. */ -static inline void add_timer (struct timer_list *timer) +static inline void add_timer (struct ktimeout *timer) {BUG_ON (timer_pending (timer));__mod_timer (timer, timer->expires); }#ifdef CONFIG_SMP -extern int try_to_del_timer_sync (struct timer_list *timer); -extern int del_timer_sync (struct timer_list *timer); +extern int try_to_del_timer_sync (struct ktimeout *timer); +extern int del_timer_sync (struct ktimeout *timer);#else # define try_to_del_timer_sync (t) del_timer(t)# define del_timer_sync (t) del_timer(t)
--
PATCH 28/43 Convert ktimeout.h and create wrappers
In reply to a message not in the archiveplain text document attachment (ktimeout-new-apis.patch)
- convert ktimeout.h to use the ktimeout naming
- introduce compatibility wrapper defines in the timer.h code
include/linux/ktimeout.h | 80 +++++++++++++++++++++++------------------------ include/linux/timer.h | 27 +++++++++++++++ 2 files changed, 66 insertions(+), 41 deletions(-)
include/linux/ktimeout.h +40 -40
@@ -6,7 +6,7 @@#include <linux/spinlock.h> #include <linux/stddef.h> -struct timer_base_s ; +struct ktimeout_base_s ;struct ktimeout {struct list_head entry;
@@ -15,86 +15,86 @@ struct ktimeout {void (*function)(unsigned long );unsigned long data; -struct timer_base_s *base; +struct ktimeout_base_s *base; }; -extern struct timer_base_s __init_timer_base; +extern struct ktimeout_base_s __init_ktimeout_base; -#define TIMER_INITIALIZER (_function, _expires, _data) { \ +#define KTIMEOUT_INITIALIZER (_function, _expires, _data) { \ .function = (_function), \ .expires = (_expires), \ .data = (_data), \ - .base = &__init_timer_base, \ + .base = &__init_ktimeout_base, \ } -#define DEFINE_TIMER (_name, _function, _expires, _data) \ - struct ktimeout _name = \ - TIMER_INITIALIZER(_function, _expires, _data) +#define DEFINE_KTIMEOUT (_name, _function, _expires, _data) \ + struct ktimeout _name = \ + KTIMEOUT_INITIALIZER(_function, _expires, _data) -void fastcall init_timer(struct ktimeout * timer); +void fastcall init_ktimeout(struct ktimeout * ktimeout); -static inline void setup_timer (struct ktimeout * timer, +static inline void setup_ktimeout (struct ktimeout * ktimeout,void (*function)(unsigned long ),unsigned long data) { - timer->function = function; - timer->data = data; -init_timer (timer); + ktimeout->function = function; + ktimeout->data = data; +init_ktimeout (ktimeout); }/*** -* timer_pending - is a timer pending? -* @timer: the timer in question +* ktimeout_pending - is a ktimeout pending? +* @ktimeout: the ktimeout in question * -* timer_pending will tell whether a given timer is currently pending, +* ktimeout_pending will tell whether a given ktimeout is currently pending, * or not. Callers must ensure serialization wrt. other operations done -* to this timer, eg. interrupt contexts, or other CPUs on SMP. +* to this ktimeout, eg. interrupt contexts, or other CPUs on SMP. * -* return value: 1 if the timer is pending, 0 if not. +* return value: 1 if the ktimeout is pending, 0 if not. */ -static inline int timer_pending (const struct ktimeout * timer) +static inline int ktimeout_pending (const struct ktimeout * ktimeout) { -return timer->entry.next !=NULL ; +return ktimeout->entry.next !=NULL ; } -extern void add_timer_on (struct ktimeout *timer,int cpu); -extern int del_timer (struct ktimeout * timer); -extern int __mod_timer (struct ktimeout *timer,unsigned long expires); -extern int mod_timer (struct ktimeout *timer,unsigned long expires); +extern void add_ktimeout_on (struct ktimeout *ktimeout,int cpu); +extern int del_ktimeout (struct ktimeout * ktimeout); +extern int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires); +extern int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires); -extern unsigned long next_timer_interrupt (void ); +extern unsigned long next_ktimeout_interrupt (void );/*** -* add_timer - start a timer -* @timer: the timer to be added +* add_ktimeout - start a ktimeout +* @ktimeout: the ktimeout to be added * * The kernel will do a ->function(->data) callback from the -* timer interrupt at the ->expired point in the future. The +* ktimeout interrupt at the ->expired point in the future. The * current time is 'jiffies'. * -* The timer's ->expired, ->function (and if the handler uses it, ->data) +* The ktimeout's ->expired, ->function (and if the handler uses it, ->data) * fields must be set prior calling this function. * * Timers with an ->expired field in the past will be executed in the next -* timer tick. +* ktimeout tick. */ -static inline void add_timer (struct ktimeout *timer) +static inline void add_ktimeout (struct ktimeout *ktimeout) { -BUG_ON (timer_pending (timer)); -__mod_timer (timer, timer->expires); +BUG_ON (ktimeout_pending (ktimeout)); +__mod_ktimeout (ktimeout, ktimeout->expires); }#ifdef CONFIG_SMP -extern int try_to_del_timer_sync (struct ktimeout *timer); -extern int del_timer_sync (struct ktimeout *timer); +extern int try_to_del_ktimeout_sync (struct ktimeout *ktimeout); +extern int del_ktimeout_sync (struct ktimeout *ktimeout);#else -# define try_to_del_timer_sync (t) del_timer(t) -# define del_timer_sync (t) del_timer(t) +# define try_to_del_ktimeout_sync (t) del_ktimeout(t) +# define del_ktimeout_sync (t) del_ktimeout(t)#endif -#define del_singleshot_timer_sync (t) del_timer_sync(t) +#define del_singleshot_ktimeout_sync (t) del_ktimeout_sync(t) -extern void init_timers (void ); -extern void run_local_timers (void ); +extern void init_ktimeouts (void ); +extern void run_local_ktimeouts (void );#endif
include/linux/timer.h +26 -1
@@ -7,8 +7,33 @@/* * Compatibility define to turn 'struct timer_list' into 'struct ktimeout': */ -#define timer_list ktimeout +#define timer_list ktimeout +#define timer_base_s ktimeout_base_s +#define __init_timer_base __init_ktimeout_base +/* +* Compatibility defines for the old timer APIs: +*/ +#define TIMER_INITIALIZER KTIMEOUT_INITIALIZER +#define DEFINE_TIMER DEFINE_KTIMEOUT +#define init_timer init_ktimeout +#define setup_timer setup_ktimeout +#define timer_pending ktimeout_pending +#define add_timer_on add_ktimeout_on +#define del_timer del_ktimeout +#define __mod_timer __mod_ktimeout +#define mod_timer mod_ktimeout +#define next_timer_interrupt next_ktimeout_interrupt +#define add_timer add_ktimeout +#define try_to_del_timer_sync try_to_del_ktimeout_sync +#define del_timer_sync del_ktimeout_sync +#define del_singleshot_timer_sync del_singleshot_ktimeout_sync +#define init_timers init_ktimeouts +#define run_local_timers run_local_ktimeouts + +/* +* Pick up the timeout APIs: +*/ #include <linux/ktimeout.h> extern int it_real_fn (void *);
--
PATCH 29/43 Convert ktimeout.c to ktimeout struct and APIs
In reply to a message not in the archiveplain text document attachment (ktimeout-c-convert.patch)
- convert ktimeout.c to use the new ktimeout structs and APIs
kernel/ktimeout.c | 360 +++++++++++++++++++++++++++--------------------------- 1 files changed, 180 insertions(+), 180 deletions(-)
kernel/ktimeout.c +180 -180
@@ -5,8 +5,8 @@* * Copyright (C) 1991, 1992 Linus Torvalds * -* 1997-01-28 Modified by Finn Arne Gangstad to make timers scale better. -* 2000-10-05 Implemented scalable SMP per-CPU timer handling. +* 1997-01-28 Modified by Finn Arne Gangstad to make timeouts scale better. +* 2000-10-05 Implemented scalable SMP per-CPU timeout handling. * Copyright (C) 2000, 2001, 2002 Ingo Molnar * Designed by David S. Miller, Alexey Kuznetsov and Ingo Molnar */
@@ -33,7 +33,7 @@#include <asm/io.h> /* -* per-CPU timer vector definitions: +* per-CPU ktimeout vector definitions: */ #define TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6)
@@ -43,9 +43,9 @@#define TVN_MASK (TVN_SIZE - 1)#define TVR_MASK (TVR_SIZE - 1) -struct timer_base_s { +struct ktimeout_base_s {spinlock_t lock; -struct timer_list *running_timer; +struct ktimeout *running_ktimeout; }; typedef struct tvec_s {
@@ -57,8 +57,8 @@ typedef struct tvec_root_s { } tvec_root_t;struct tvec_t_base_s { -struct timer_base_s t_base; -unsigned long timer_jiffies; +struct ktimeout_base_s t_base; +unsigned long ktimeout_jiffies;tvec_root_t tv1;tvec_t tv2;tvec_t tv3;
@@ -69,18 +69,18 @@ struct tvec_t_base_s {typedef struct tvec_t_base_s tvec_base_t ; static DEFINE_PER_CPU(tvec_base_t, tvec_bases); -static inline void set_running_timer (tvec_base_t *base, -struct timer_list *timer) +static inline void set_running_ktimeout (tvec_base_t *base, +struct ktimeout *ktimeout) {#ifdef CONFIG_SMP - base->t_base.running_timer = timer; + base->t_base.running_ktimeout = ktimeout;#endif } -static void internal_add_timer (tvec_base_t *base,struct timer_list *timer) +static void internal_add_ktimeout (tvec_base_t *base,struct ktimeout *ktimeout) { -unsigned long expires = timer->expires; -unsigned long idx = expires - base->timer_jiffies; +unsigned long expires = ktimeout->expires; +unsigned long idx = expires - base->ktimeout_jiffies;struct list_head *vec;if (idx <TVR_SIZE ) {
@@ -97,10 +97,10 @@ static void internal_add_timer(tvec_base vec = base->tv4.vec + i; }else if ((signed long ) idx <0 ) {/* -* Can happen if you add a timer with expires == jiffies, -* or you set a timer to go off in the past +* Can happen if you add a ktimeout with expires == jiffies, +* or you set a ktimeout to go off in the past */ - vec = base->tv1.vec + (base->timer_jiffies &TVR_MASK ); + vec = base->tv1.vec + (base->ktimeout_jiffies &TVR_MASK ); }else {int i;/* If the timeout is larger than 0xffffffff on 64-bit
@@ -108,7 +108,7 @@ static void internal_add_timer(tvec_base*/ if (idx >0xffffffffUL ) { idx =0xffffffffUL ; - expires = idx + base->timer_jiffies; + expires = idx + base->ktimeout_jiffies; } i = (expires >> (TVR_BITS +3 *TVN_BITS )) &TVN_MASK ; vec = base->tv5.vec + i;
@@ -116,36 +116,36 @@ static void internal_add_timer(tvec_base/* * Timers are FIFO: */ -list_add_tail (&timer->entry, vec); +list_add_tail (&ktimeout->entry, vec); } -typedef struct timer_base_s timer_base_t ; +typedef struct ktimeout_base_s ktimeout_base_t ;/* * Used by TIMER_INITIALIZER, we can't use per_cpu(tvec_bases) -* at compile time, and we need timer->base to lock the timer. +* at compile time, and we need ktimeout->base to lock the ktimeout. */ -timer_base_t __init_timer_base +ktimeout_base_t __init_ktimeout_base____cacheline_aligned_in_smp = { .lock =SPIN_LOCK_UNLOCKED }; -EXPORT_SYMBOL (__init_timer_base); +EXPORT_SYMBOL (__init_ktimeout_base);/*** -* init_timer - initialize a timer. -* @timer: the timer to be initialized +* init_ktimeout - initialize a ktimeout. +* @ktimeout: the ktimeout to be initialized * -* init_timer() must be done to a timer prior calling *any* of the -* other timer functions. +* init_ktimeout() must be done to a ktimeout prior calling *any* of the +* other ktimeout functions. */ -void fastcall init_timer(struct timer_list *timer) +void fastcall init_ktimeout(struct ktimeout *ktimeout) { - timer->entry.next =NULL ; - timer->base = &per_cpu (tvec_bases,raw_smp_processor_id ()).t_base; + ktimeout->entry.next =NULL ; + ktimeout->base = &per_cpu (tvec_bases,raw_smp_processor_id ()).t_base; } -EXPORT_SYMBOL (init_timer); +EXPORT_SYMBOL (init_ktimeout); -static inline void detach_timer (struct timer_list *timer, +static inline void detach_ktimeout (struct ktimeout *ktimeout,int clear_pending) { -struct list_head *entry = &timer->entry; +struct list_head *entry = &ktimeout->entry;__list_del (entry->prev, entry->next);if (clear_pending)
@@ -155,47 +155,47 @@ static inline void detach_timer(struct t/* * We are using hashed locking: holding per_cpu(tvec_bases).t_base.lock -* means that all timers which are tied to this base via timer->base are +* means that all ktimeouts which are tied to this base via ktimeout->base are * locked, and the base itself is locked too. * -* So __run_timers/migrate_timers can safely modify all timers which could +* So __run_ktimeouts/migrate_ktimeouts can safely modify all ktimeouts which could * be found on ->tvX lists. * -* When the timer's base is locked, and the timer removed from list, it is -* possible to set timer->base = NULL and drop the lock: the timer remains +* When the ktimeout's base is locked, and the ktimeout removed from list, it is +* possible to set ktimeout->base = NULL and drop the lock: the ktimeout remains * locked. */ -static timer_base_t *lock_timer_base (struct timer_list *timer, +static ktimeout_base_t *lock_ktimeout_base (struct ktimeout *ktimeout,unsigned long *flags) { -timer_base_t *base; +ktimeout_base_t *base;for (;;) { - base = timer->base; + base = ktimeout->base;if (likely (base !=NULL )) {spin_lock_irqsave (&base->lock, *flags); -if (likely (base == timer->base)) +if (likely (base == ktimeout->base))return base; -/* The timer has migrated to another CPU */ +/* The ktimeout has migrated to another CPU */ spin_unlock_irqrestore (&base->lock, *flags); }cpu_relax (); } } -int __mod_timer (struct timer_list *timer,unsigned long expires) +int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires) { -timer_base_t *base; +ktimeout_base_t *base;tvec_base_t *new_base;unsigned long flags;int ret =0 ; -BUG_ON (!timer->function); +BUG_ON (!ktimeout->function); - base =lock_timer_base (timer, &flags); + base =lock_ktimeout_base (ktimeout, &flags); -if (timer_pending (timer)) { -detach_timer (timer,0 ); +if (ktimeout_pending (ktimeout)) { +detach_ktimeout (ktimeout,0 ); ret =1 ; }
@@ -203,110 +203,110 @@ int __mod_timer(struct timer_list *timerif (base != &new_base->t_base) {/* -* We are trying to schedule the timer on the local CPU. -* However we can't change timer's base while it is running, -* otherwise del_timer_sync() can't detect that the timer's +* We are trying to schedule the ktimeout on the local CPU. +* However we can't change ktimeout's base while it is running, +* otherwise del_ktimeout_sync() can't detect that the ktimeout's * handler yet has not finished. This also guarantees that -* the timer is serialized wrt itself. +* the ktimeout is serialized wrt itself. */ -if (unlikely (base->running_timer == timer)) { -/* The timer remains on a former base */ +if (unlikely (base->running_ktimeout == ktimeout)) { +/* The ktimeout remains on a former base */ new_base =container_of (base, tvec_base_t, t_base); }else { -/* See the comment in lock_timer_base() */ - timer->base =NULL ; +/* See the comment in lock_ktimeout_base() */ + ktimeout->base =NULL ;spin_unlock (&base->lock);spin_lock (&new_base->t_base.lock); - timer->base = &new_base->t_base; + ktimeout->base = &new_base->t_base; } } - timer->expires = expires; -internal_add_timer (new_base, timer); + ktimeout->expires = expires; +internal_add_ktimeout (new_base, ktimeout);spin_unlock_irqrestore (&new_base->t_base.lock, flags);return ret; } -EXPORT_SYMBOL (__mod_timer); +EXPORT_SYMBOL (__mod_ktimeout);/*** -* add_timer_on - start a timer on a particular CPU -* @timer: the timer to be added +* add_ktimeout_on - start a ktimeout on a particular CPU +* @ktimeout: the ktimeout to be added * @cpu: the CPU to start it on * * This is not very scalable on SMP. Double adds are not possible. */ -void add_timer_on (struct timer_list *timer,int cpu) +void add_ktimeout_on (struct ktimeout *ktimeout,int cpu) {tvec_base_t *base = &per_cpu (tvec_bases, cpu);unsigned long flags; -BUG_ON (timer_pending (timer) || !timer->function); +BUG_ON (ktimeout_pending (ktimeout) || !ktimeout->function);spin_lock_irqsave (&base->t_base.lock, flags); - timer->base = &base->t_base; -internal_add_timer (base, timer); + ktimeout->base = &base->t_base; +internal_add_ktimeout (base, ktimeout);spin_unlock_irqrestore (&base->t_base.lock, flags); }/*** -* mod_timer - modify a timer's timeout -* @timer: the timer to be modified +* mod_ktimeout - modify a ktimeout's timeout +* @ktimeout: the ktimeout to be modified * -* mod_timer is a more efficient way to update the expire field of an -* active timer (if the timer is inactive it will be activated) +* mod_ktimeout is a more efficient way to update the expire field of an +* active ktimeout (if the ktimeout is inactive it will be activated) * -* mod_timer(timer, expires) is equivalent to: +* mod_ktimeout(ktimeout, expires) is equivalent to: * -* del_timer(timer); timer->expires = expires; add_timer(timer); +* del_ktimeout(ktimeout); ktimeout->expires = expires; add_ktimeout(ktimeout); * * Note that if there are multiple unserialized concurrent users of the -* same timer, then mod_timer() is the only safe way to modify the timeout, -* since add_timer() cannot modify an already running timer. +* same ktimeout, then mod_ktimeout() is the only safe way to modify the timeout, +* since add_ktimeout() cannot modify an already running ktimeout. * -* The function returns whether it has modified a pending timer or not. -* (ie. mod_timer() of an inactive timer returns 0, mod_timer() of an -* active timer returns 1.) +* The function returns whether it has modified a pending ktimeout or not. +* (ie. mod_ktimeout() of an inactive ktimeout returns 0, mod_ktimeout() of an +* active ktimeout returns 1.) */ -int mod_timer (struct timer_list *timer,unsigned long expires) +int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires) { -BUG_ON (!timer->function); +BUG_ON (!ktimeout->function);/* * This is a common optimization triggered by the -* networking code - if the timer is re-modified +* networking code - if the ktimeout is re-modified * to be the same thing then just return: */ -if (timer->expires == expires &&timer_pending (timer)) +if (ktimeout->expires == expires &&ktimeout_pending (ktimeout))return 1 ; -return __mod_timer (timer, expires); +return __mod_ktimeout (ktimeout, expires); } -EXPORT_SYMBOL (mod_timer); +EXPORT_SYMBOL (mod_ktimeout);/*** -* del_timer - deactive a timer. -* @timer: the timer to be deactivated +* del_ktimeout - deactive a ktimeout. +* @ktimeout: the ktimeout to be deactivated * -* del_timer() deactivates a timer - this works on both active and inactive -* timers. +* del_ktimeout() deactivates a ktimeout - this works on both active and inactive +* ktimeouts. * -* The function returns whether it has deactivated a pending timer or not. -* (ie. del_timer() of an inactive timer returns 0, del_timer() of an -* active timer returns 1.) +* The function returns whether it has deactivated a pending ktimeout or not. +* (ie. del_ktimeout() of an inactive ktimeout returns 0, del_ktimeout() of an +* active ktimeout returns 1.) */ -int del_timer (struct timer_list *timer) +int del_ktimeout (struct ktimeout *ktimeout) { -timer_base_t *base; +ktimeout_base_t *base;unsigned long flags;int ret =0 ; -if (timer_pending (timer)) { - base =lock_timer_base (timer, &flags); -if (timer_pending (timer)) { -detach_timer (timer,1 ); +if (ktimeout_pending (ktimeout)) { + base =lock_ktimeout_base (ktimeout, &flags); +if (ktimeout_pending (ktimeout)) { +detach_ktimeout (ktimeout,1 ); ret =1 ; }spin_unlock_irqrestore (&base->lock, flags);
@@ -315,29 +315,29 @@ int del_timer(struct timer_list *timer)return ret; } -EXPORT_SYMBOL (del_timer); +EXPORT_SYMBOL (del_ktimeout);#ifdef CONFIG_SMP /* -* This function tries to deactivate a timer. Upon successful (ret >= 0) -* exit the timer is not queued and the handler is not running on any CPU. +* This function tries to deactivate a ktimeout. Upon successful (ret >= 0) +* exit the ktimeout is not queued and the handler is not running on any CPU. * * It must not be called from interrupt contexts. */ -int try_to_del_timer_sync (struct timer_list *timer) +int try_to_del_ktimeout_sync (struct ktimeout *ktimeout) { -timer_base_t *base; +ktimeout_base_t *base;unsigned long flags;int ret =-1 ; - base =lock_timer_base (timer, &flags); + base =lock_ktimeout_base (ktimeout, &flags); -if (base->running_timer == timer) +if (base->running_ktimeout == ktimeout) goto out; ret =0 ; -if (timer_pending (timer)) { -detach_timer (timer,1 ); +if (ktimeout_pending (ktimeout)) { +detach_ktimeout (ktimeout,1 ); ret =1 ; } out:
@@ -347,52 +347,52 @@ out: }/*** -* del_timer_sync - deactivate a timer and wait for the handler to finish. -* @timer: the timer to be deactivated +* del_ktimeout_sync - deactivate a ktimeout and wait for the handler to finish. +* @ktimeout: the ktimeout to be deactivated * -* This function only differs from del_timer() on SMP: besides deactivating -* the timer it also makes sure the handler has finished executing on other +* This function only differs from del_ktimeout() on SMP: besides deactivating +* the ktimeout it also makes sure the handler has finished executing on other * CPUs. * -* Synchronization rules: callers must prevent restarting of the timer, +* Synchronization rules: callers must prevent restarting of the ktimeout, * otherwise this function is meaningless. It must not be called from * interrupt contexts. The caller must not hold locks which would prevent -* completion of the timer's handler. The timer's handler must not call -* add_timer_on(). Upon exit the timer is not queued and the handler is +* completion of the ktimeout's handler. The ktimeout's handler must not call +* add_ktimeout_on(). Upon exit the ktimeout is not queued and the handler is * not running on any CPU. * -* The function returns whether it has deactivated a pending timer or not. +* The function returns whether it has deactivated a pending ktimeout or not. */ -int del_timer_sync (struct timer_list *timer) +int del_ktimeout_sync (struct ktimeout *ktimeout) {for (;;) { -int ret =try_to_del_timer_sync (timer); +int ret =try_to_del_ktimeout_sync (ktimeout);if (ret >=0 )return ret; } } -EXPORT_SYMBOL (del_timer_sync); +EXPORT_SYMBOL (del_ktimeout_sync);#endif static int cascade (tvec_base_t *base,tvec_t *tv,int index) { -/* cascade all the timers from tv up one level */ +/* cascade all the ktimeouts from tv up one level */ struct list_head *head, *curr; head = tv->vec + index; curr = head->next;/* -* We are removing _all_ timers from the list, so we don't have to +* We are removing _all_ ktimeouts from the list, so we don't have to * detach them individually, just clear the list afterwards. */ while (curr != head) { -struct timer_list *tmp; +struct ktimeout *tmp; - tmp = list_entry(curr, struct timer_list, entry); + tmp = list_entry(curr, struct ktimeout, entry);BUG_ON (tmp->base != &base->t_base); curr = curr->next; -internal_add_timer (base, tmp); +internal_add_ktimeout (base, tmp); }INIT_LIST_HEAD (head);
@@ -400,44 +400,44 @@ static int cascade(tvec_base_t *base, tv }/*** -* __run_timers - run all expired timers (if any) on this CPU. -* @base: the timer vector to be processed. +* __run_ktimeouts - run all expired ktimeouts (if any) on this CPU. +* @base: the ktimeout vector to be processed. * -* This function cascades all vectors and executes all expired timer +* This function cascades all vectors and executes all expired ktimeout * vectors. */ -#define INDEX (N ) (base->timer_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK +#define INDEX (N ) (base->ktimeout_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK -static inline void __run_timers (tvec_base_t *base) +static inline void __run_ktimeouts (tvec_base_t *base) { -struct timer_list *timer; +struct ktimeout *ktimeout;spin_lock_irq (&base->t_base.lock); -while (time_after_eq (jiffies, base->timer_jiffies)) { +while (time_after_eq (jiffies, base->ktimeout_jiffies)) {struct list_head work_list =LIST_HEAD_INIT (work_list);struct list_head *head = &work_list; -int index = base->timer_jiffies &TVR_MASK ; +int index = base->ktimeout_jiffies &TVR_MASK ;/* -* Cascade timers: +* Cascade ktimeouts: */ if (!index && (!cascade (base, &base->tv2,INDEX (0 ))) && (!cascade (base, &base->tv3,INDEX (1 ))) && !cascade (base, &base->tv4,INDEX (2 )))cascade (base, &base->tv5,INDEX (3 )); - ++base->timer_jiffies; + ++base->ktimeout_jiffies;list_splice_init (base->tv1.vec + index, &work_list);while (!list_empty (head)) {void (*fn)(unsigned long );unsigned long data; - timer = list_entry(head->next,struct timer_list,entry); - fn = timer->function; - data = timer->data; + ktimeout = list_entry(head->next,struct ktimeout,entry); + fn = ktimeout->function; + data = ktimeout->data; -set_running_timer (base, timer); -detach_timer (timer,1 ); +set_running_ktimeout (base, ktimeout); +detach_ktimeout (ktimeout,1 );spin_unlock_irq (&base->t_base.lock); {int preempt_count =preempt_count ();
@@ -454,41 +454,41 @@ static inline void __run_timers(tvec_basspin_lock_irq (&base->t_base.lock); } } -set_running_timer (base,NULL ); +set_running_ktimeout (base,NULL );spin_unlock_irq (&base->t_base.lock); }#ifdef CONFIG_NO_IDLE_HZ /* -* Find out when the next timer event is due to happen. This +* Find out when the next ktimeout event is due to happen. This * is used on S/390 to stop all activity when a cpus is idle. * This functions needs to be called disabled. */ -unsigned long next_timer_interrupt (void ) +unsigned long next_ktimeout_interrupt (void ) {tvec_base_t *base;struct list_head *list; -struct timer_list *nte; +struct ktimeout *nte;unsigned long expires;tvec_t *varray[4 ];int i, j; base = &__get_cpu_var (tvec_bases);spin_lock (&base->t_base.lock); - expires = base->timer_jiffies + (LONG_MAX >>1 ); + expires = base->ktimeout_jiffies + (LONG_MAX >>1 ); list =0 ; -/* Look for timer events in tv1. */ - j = base->timer_jiffies &TVR_MASK ; +/* Look for ktimeout events in tv1. */ + j = base->ktimeout_jiffies &TVR_MASK ;do {list_for_each_entry (nte, base->tv1.vec + j, entry) { expires = nte->expires; -if (j < (base->timer_jiffies &TVR_MASK )) +if (j < (base->ktimeout_jiffies &TVR_MASK )) list = base->tv2.vec + (INDEX (0 )); goto found; } j = (j +1 ) &TVR_MASK ; - }while (j != (base->timer_jiffies &TVR_MASK )); + }while (j != (base->ktimeout_jiffies &TVR_MASK ));/* Check tv2-tv5. */ varray[0 ] = &base->tv2;
@@ -515,7 +515,7 @@ found:/* * The search wrapped. We need to look at the next list * from next tv element that would cascade into tv element -* where we found the timer element. +* where we found the ktimeout element. */ list_for_each_entry (nte, list, entry) {if (time_before (nte->expires, expires))
@@ -528,21 +528,21 @@ found:#endif /* -* This function runs timers and the timer-tq in bottom half context. +* This function runs ktimeouts and the ktimeout-tq in bottom half context. */ -static void run_timer_softirq (struct softirq_action *h) +static void run_ktimeout_softirq (struct softirq_action *h) {tvec_base_t *base = &__get_cpu_var (tvec_bases);ktimer_run_queues (); -if (time_after_eq (jiffies, base->timer_jiffies)) -__run_timers (base); +if (time_after_eq (jiffies, base->ktimeout_jiffies)) +__run_ktimeouts (base); }/* -* Called by the local, per-CPU timer interrupt on SMP. +* Called by the local, per-CPU ktimeout interrupt on SMP. */ -void run_local_timers (void ) +void run_local_ktimeouts (void ) {raise_softirq (TIMER_SOFTIRQ ); }
@@ -567,7 +567,7 @@ static void process_timeout(unsigned lon* * %TASK_INTERRUPTIBLE - the routine may return early if a signal is * delivered to the current task. In this case the remaining time -* in jiffies will be returned, or 0 if the timer expired in time +* in jiffies will be returned, or 0 if the ktimeout expired in time * * The current task state is guaranteed to be TASK_RUNNING when this * routine returns.
@@ -580,7 +580,7 @@ static void process_timeout(unsigned lon*/ fastcall signed long __sched schedule_timeout(signed long timeout) { -struct timer_list timer; +struct ktimeout ktimeout;unsigned long expire; switch (timeout)
@@ -615,10 +615,10 @@ fastcall signed long __sched schedule_ti expire = timeout + jiffies; -setup_timer (&timer, process_timeout, (unsigned long )current); -__mod_timer (&timer, expire); +setup_ktimeout (&ktimeout, process_timeout, (unsigned long )current); +__mod_ktimeout (&ktimeout, expire);schedule (); -del_singleshot_timer_sync (&timer); +del_singleshot_ktimeout_sync (&ktimeout); timeout = expire - jiffies;
@@ -674,7 +674,7 @@ unsigned long msleep_interruptible(unsigEXPORT_SYMBOL (msleep_interruptible); -static void __devinit init_timers_cpu (int cpu) +static void __devinit init_ktimeouts_cpu (int cpu) {int j;tvec_base_t *base;
@@ -690,23 +690,23 @@ static void __devinit init_timers_cpu(infor (j =0 ; j <TVR_SIZE ; j++)INIT_LIST_HEAD (base->tv1.vec + j); - base->timer_jiffies = jiffies; + base->ktimeout_jiffies = jiffies; }#ifdef CONFIG_HOTPLUG_CPU -static void migrate_timer_list (tvec_base_t *new_base,struct list_head *head) +static void migrate_ktimeout (tvec_base_t *new_base,struct list_head *head) { -struct timer_list *timer; +struct ktimeout *ktimeout;while (!list_empty (head)) { - timer = list_entry(head->next, struct timer_list, entry); -detach_timer (timer,0 ); - timer->base = &new_base->t_base; -internal_add_timer (new_base, timer); + ktimeout = list_entry(head->next, struct ktimeout, entry); +detach_ktimeout (ktimeout,0 ); + ktimeout->base = &new_base->t_base; +internal_add_ktimeout (new_base, ktimeout); } } -static void __devinit migrate_timers (int cpu) +static void __devinit migrate_ktimeouts (int cpu) {tvec_base_t *old_base;tvec_base_t *new_base;
@@ -720,15 +720,15 @@ static void __devinit migrate_timers(intspin_lock (&new_base->t_base.lock);spin_lock (&old_base->t_base.lock); -if (old_base->t_base.running_timer) +if (old_base->t_base.running_ktimeout)BUG ();for (i =0 ; i <TVR_SIZE ; i++) -migrate_timer_list (new_base, old_base->tv1.vec + i); +migrate_ktimeout (new_base, old_base->tv1.vec + i);for (i =0 ; i <TVN_SIZE ; i++) { -migrate_timer_list (new_base, old_base->tv2.vec + i); -migrate_timer_list (new_base, old_base->tv3.vec + i); -migrate_timer_list (new_base, old_base->tv4.vec + i); -migrate_timer_list (new_base, old_base->tv5.vec + i); +migrate_ktimeout (new_base, old_base->tv2.vec + i); +migrate_ktimeout (new_base, old_base->tv3.vec + i); +migrate_ktimeout (new_base, old_base->tv4.vec + i); +migrate_ktimeout (new_base, old_base->tv5.vec + i); }spin_unlock (&old_base->t_base.lock);
@@ -738,17 +738,17 @@ static void __devinit migrate_timers(int }#endif /* CONFIG_HOTPLUG_CPU */ -static int __devinit timer_cpu_notify (struct notifier_block *self, +static int __devinit ktimeout_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;switch (action) {case CPU_UP_PREPARE : -init_timers_cpu (cpu); +init_ktimeouts_cpu (cpu);break ;#ifdef CONFIG_HOTPLUG_CPU case CPU_DEAD : -migrate_timers (cpu); +migrate_ktimeouts (cpu);break ;#endif default :
@@ -757,15 +757,15 @@ static int __devinit timer_cpu_notify(streturn NOTIFY_OK ; } -static struct notifier_block __devinitdata timers_nb = { - .notifier_call = timer_cpu_notify, +static struct notifier_block __devinitdata ktimeouts_nb = { + .notifier_call = ktimeout_cpu_notify, }; -void __init init_timers (void ) +void __init init_ktimeouts (void ) { -timer_cpu_notify (&timers_nb, (unsigned long )CPU_UP_PREPARE , +ktimeout_cpu_notify (&ktimeouts_nb, (unsigned long )CPU_UP_PREPARE , (void *)(long )smp_processor_id ()); -register_cpu_notifier (&timers_nb); -open_softirq (TIMER_SOFTIRQ , run_timer_softirq,NULL ); +register_cpu_notifier (&ktimeouts_nb); +open_softirq (TIMER_SOFTIRQ , run_ktimeout_softirq,NULL ); }
--
PATCH 30/43 ktimeout documentation
In reply to a message not in the archiveplain text document attachment (ktimeout-doc.patch)
- document ktimeouts and fix up existing documentation
include/linux/ktimeout.h | 21 ++++--- kernel/ktimeout.c | 124 ++++++++++++++++++++++++----------------------- 2 files changed, 77 insertions(+), 68 deletions(-)
include/linux/ktimeout.h +12 -9
@@ -1,3 +1,6 @@ +/* +* Support for kernel-internal timeout events: +*/ #ifndef _LINUX_KTIMEOUT_H#define _LINUX_KTIMEOUT_H
@@ -43,14 +46,14 @@ static inline void setup_ktimeout(struct }/*** -* ktimeout_pending - is a ktimeout pending? -* @ktimeout: the ktimeout in question +* ktimeout_pending - is a timeout pending? +* @ktimeout: the timeout in question * -* ktimeout_pending will tell whether a given ktimeout is currently pending, +* ktimeout_pending will tell whether a given timeout is currently pending, * or not. Callers must ensure serialization wrt. other operations done -* to this ktimeout, eg. interrupt contexts, or other CPUs on SMP. +* to this timeout, eg. interrupt contexts, or other CPUs on SMP. * -* return value: 1 if the ktimeout is pending, 0 if not. +* return value: 1 if the timeout is pending, 0 if not. */ static inline int ktimeout_pending (const struct ktimeout * ktimeout) {
@@ -66,17 +69,17 @@ extern unsigned long next_ktimeout_inter/*** * add_ktimeout - start a ktimeout -* @ktimeout: the ktimeout to be added +* @ktimeout: the timeout to be added * * The kernel will do a ->function(->data) callback from the -* ktimeout interrupt at the ->expired point in the future. The +* timeout interrupt at the ->expired point in the future. The * current time is 'jiffies'. * -* The ktimeout's ->expired, ->function (and if the handler uses it, ->data) +* The timeout's ->expired, ->function (and if the handler uses it, ->data) * fields must be set prior calling this function. * * Timers with an ->expired field in the past will be executed in the next -* ktimeout tick. +* timeout tick. */ static inline void add_ktimeout (struct ktimeout *ktimeout) {
kernel/ktimeout.c +65 -59
294 lines not on this page · raw message
--
PATCH 31/43 rename init_ktimeout() to ktimeout_init()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_init.patch)
- rename init_ktimeout() to ktimeout_init()
include/linux/ktimeout.h | 4 ++-- include/linux/timer.h | 2 +- kernel/ktimeout.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-)
include/linux/ktimeout.h +2 -2
@@ -34,7 +34,7 @@ extern struct ktimeout_base_s __init_ktistruct ktimeout _name = \ KTIMEOUT_INITIALIZER(_function, _expires, _data) -void fastcall init_ktimeout(struct ktimeout * ktimeout); +void fastcall ktimeout_init(struct ktimeout * ktimeout); static inline void setup_ktimeout(struct ktimeout * ktimeout, void (*function)(unsigned long),
@@ -42,7 +42,7 @@ static inline void setup_ktimeout(struct { ktimeout->function = function; ktimeout->data = data; -init_ktimeout (ktimeout); +ktimeout_init (ktimeout); }/***
include/linux/timer.h +1 -1
@@ -16,7 +16,7 @@*/ #define TIMER_INITIALIZER KTIMEOUT_INITIALIZER#define DEFINE_TIMER DEFINE_KTIMEOUT -#define init_timer init_ktimeout +#define init_timer ktimeout_init#define setup_timer setup_ktimeout#define timer_pending ktimeout_pending#define add_timer_on add_ktimeout_on
kernel/ktimeout.c +4 -4
@@ -135,18 +135,18 @@ ktimeout_base_t __init_ktimeout_baseEXPORT_SYMBOL (__init_ktimeout_base);/*** -* init_ktimeout - initialize a timeout. +* ktimeout_init - initialize a timeout. * @ktimeout: the timeout to be initialized * -* init_ktimeout() must be done to a timeout prior calling *any* of the +* ktimeout_init() must be done to a timeout prior calling *any* of the * other timeout functions. */ -void fastcall init_ktimeout(struct ktimeout *ktimeout) +void fastcall ktimeout_init(struct ktimeout *ktimeout) { ktimeout->entry.next =NULL ; ktimeout->base = &per_cpu (tvec_bases,raw_smp_processor_id ()).t_base; } -EXPORT_SYMBOL (init_ktimeout); +EXPORT_SYMBOL (ktimeout_init);static inline void detach_ktimeout (struct ktimeout *ktimeout,int clear_pending)
--
PATCH 32/43 rename setup_ktimeout() to ktimeout_setup()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_setup.patch)
- rename setup_ktimeout() to ktimeout_setup()
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 2 +- kernel/ktimeout.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -36,7 +36,7 @@ extern struct ktimeout_base_s __init_kti void fastcall ktimeout_init(struct ktimeout * ktimeout); -static inline void setup_ktimeout (struct ktimeout * ktimeout, +static inline void ktimeout_setup (struct ktimeout * ktimeout,void (*function)(unsigned long ),unsigned long data) {
include/linux/timer.h +1 -1
@@ -17,7 +17,7 @@#define TIMER_INITIALIZER KTIMEOUT_INITIALIZER#define DEFINE_TIMER DEFINE_KTIMEOUT#define init_timer ktimeout_init -#define setup_timer setup_ktimeout +#define setup_timer ktimeout_setup#define timer_pending ktimeout_pending#define add_timer_on add_ktimeout_on#define del_timer del_ktimeout
kernel/ktimeout.c +1 -1
@@ -621,7 +621,7 @@ fastcall signed long __sched schedule_ti expire = timeout + jiffies; -setup_ktimeout (&ktimeout, process_timeout, (unsigned long )current); +ktimeout_setup (&ktimeout, process_timeout, (unsigned long )current);__mod_ktimeout (&ktimeout, expire);schedule ();del_singleshot_ktimeout_sync (&ktimeout);
--
PATCH 33/43 rename add_ktimeout_on() to ktimeout_add_on()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_add_on.patch)
- rename add_ktimeout_on() to ktimeout_add_on()
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 2 +- kernel/ktimeout.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -60,7 +60,7 @@ static inline int ktimeout_pending(constreturn ktimeout->entry.next !=NULL ; } -extern void add_ktimeout_on (struct ktimeout *ktimeout,int cpu); +extern void ktimeout_add_on (struct ktimeout *ktimeout,int cpu);extern int del_ktimeout (struct ktimeout * ktimeout);extern int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires);extern int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires);
include/linux/timer.h +1 -1
@@ -19,7 +19,7 @@#define init_timer ktimeout_init#define setup_timer ktimeout_setup#define timer_pending ktimeout_pending -#define add_timer_on add_ktimeout_on +#define add_timer_on ktimeout_add_on#define del_timer del_ktimeout#define __mod_timer __mod_ktimeout#define mod_timer mod_ktimeout
kernel/ktimeout.c +3 -3
@@ -237,13 +237,13 @@ int __mod_ktimeout(struct ktimeout *ktimEXPORT_SYMBOL (__mod_ktimeout);/*** -* add_ktimeout_on - start a timeout on a particular CPU +* ktimeout_add_on - start a timeout on a particular CPU * @ktimeout: the timeout to be added * @cpu: the CPU to start it on * * This is not very scalable on SMP. Double adds are not possible. */ -void add_ktimeout_on (struct ktimeout *ktimeout,int cpu) +void ktimeout_add_on (struct ktimeout *ktimeout,int cpu) {tvec_base_t *base = &per_cpu (tvec_bases, cpu);unsigned long flags;
@@ -364,7 +364,7 @@ out:* otherwise this function is meaningless. It must not be called from * interrupt contexts. The caller must not hold locks which would prevent * completion of the timeout's handler. The timeout's handler must not call -* add_ktimeout_on(). Upon exit the timeout is not queued and the handler is +* ktimeout_add_on(). Upon exit the timeout is not queued and the handler is * not running on any CPU. * * The function returns whether it has deactivated a pending timeout or not.
--
PATCH 34/43 rename del_ktimeout() to ktimeout_del()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_del.patch)
- rename del_ktimeout() to ktimeout_del()
include/linux/ktimeout.h | 6 +++--- include/linux/timer.h | 2 +- kernel/ktimeout.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-)
include/linux/ktimeout.h +3 -3
@@ -61,7 +61,7 @@ static inline int ktimeout_pending(const }extern void ktimeout_add_on (struct ktimeout *ktimeout,int cpu); -extern int del_ktimeout (struct ktimeout * ktimeout); +extern int ktimeout_del (struct ktimeout * ktimeout);extern int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires);extern int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires);
@@ -91,8 +91,8 @@ static inline void add_ktimeout(struct kextern int try_to_del_ktimeout_sync (struct ktimeout *ktimeout);extern int del_ktimeout_sync (struct ktimeout *ktimeout);#else -# define try_to_del_ktimeout_sync (t) del_ktimeout(t) -# define del_ktimeout_sync (t) del_ktimeout(t) +# define try_to_del_ktimeout_sync (t) ktimeout_del(t) +# define del_ktimeout_sync (t) ktimeout_del(t)#endif #define del_singleshot_ktimeout_sync (t) del_ktimeout_sync(t)
include/linux/timer.h +1 -1
@@ -20,7 +20,7 @@#define setup_timer ktimeout_setup#define timer_pending ktimeout_pending#define add_timer_on ktimeout_add_on -#define del_timer del_ktimeout +#define del_timer ktimeout_del#define __mod_timer __mod_ktimeout#define mod_timer mod_ktimeout#define next_timer_interrupt next_ktimeout_interrupt
kernel/ktimeout.c +7 -7
@@ -265,7 +265,7 @@ void ktimeout_add_on(struct ktimeout *kt* * mod_ktimeout(ktimeout, expires) is equivalent to: * -* del_ktimeout(ktimeout); ktimeout->expires = expires; add_ktimeout(ktimeout); +* ktimeout_del(ktimeout); ktimeout->expires = expires; add_ktimeout(ktimeout); * * Note that if there are multiple unserialized concurrent users of the same * timeout, then mod_ktimeout() is the only safe way to modify the interval,
@@ -293,17 +293,17 @@ int mod_ktimeout(struct ktimeout *ktimeoEXPORT_SYMBOL (mod_ktimeout);/*** -* del_ktimeout - deactive a timeout. +* ktimeout_del - deactive a timeout. * @ktimeout: the timeout to be deactivated * -* del_ktimeout() deactivates a timeout - this works on both active and inactive +* ktimeout_del() deactivates a timeout - this works on both active and inactive * ktimeouts. * * The function returns whether it has deactivated a pending timeout or not. -* (ie. del_ktimeout() of an inactive timeout returns 0, del_ktimeout() of an +* (ie. ktimeout_del() of an inactive timeout returns 0, ktimeout_del() of an * active timeout returns 1.) */ -int del_ktimeout (struct ktimeout *ktimeout) +int ktimeout_del (struct ktimeout *ktimeout) {ktimeout_base_t *base;unsigned long flags;
@@ -321,7 +321,7 @@ int del_ktimeout(struct ktimeout *ktimeoreturn ret; } -EXPORT_SYMBOL (del_ktimeout); +EXPORT_SYMBOL (ktimeout_del);#ifdef CONFIG_SMP /*
@@ -356,7 +356,7 @@ out:* del_ktimeout_sync - deactivate a timeout and wait for the handler to finish. * @ktimeout: the timeout to be deactivated * -* This function only differs from del_ktimeout() on SMP: besides deactivating +* This function only differs from ktimeout_del() on SMP: besides deactivating * the timeout it also makes sure the handler has finished executing on other * CPUs. *
--
PATCH 35/43 rename __mod_ktimeout() to __mod_ktimeout()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-__ktimeout_mod.patch)
- rename __mod_ktimeout() to __mod_ktimeout()
include/linux/ktimeout.h | 4 ++-- include/linux/timer.h | 2 +- kernel/ktimeout.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-)
include/linux/ktimeout.h +2 -2
@@ -62,7 +62,7 @@ static inline int ktimeout_pending(constextern void ktimeout_add_on (struct ktimeout *ktimeout,int cpu);extern int ktimeout_del (struct ktimeout * ktimeout); -extern int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires); +extern int __ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires);extern int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires);extern unsigned long next_ktimeout_interrupt (void );
@@ -84,7 +84,7 @@ extern unsigned long next_ktimeout_interstatic inline void add_ktimeout (struct ktimeout *ktimeout) {BUG_ON (ktimeout_pending (ktimeout)); -__mod_ktimeout (ktimeout, ktimeout->expires); +__ktimeout_mod (ktimeout, ktimeout->expires); }#ifdef CONFIG_SMP
include/linux/timer.h +1 -1
@@ -21,7 +21,7 @@#define timer_pending ktimeout_pending#define add_timer_on ktimeout_add_on#define del_timer ktimeout_del -#define __mod_timer __mod_ktimeout +#define __mod_timer __ktimeout_mod#define mod_timer mod_ktimeout#define next_timer_interrupt next_ktimeout_interrupt#define add_timer add_ktimeout
kernel/ktimeout.c +4 -4
@@ -189,7 +189,7 @@ static ktimeout_base_t *lock_ktimeout_ba } } -int __mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires) +int __ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires) {ktimeout_base_t *base;tvec_base_t *new_base;
@@ -234,7 +234,7 @@ int __mod_ktimeout(struct ktimeout *ktimreturn ret; } -EXPORT_SYMBOL (__mod_ktimeout); +EXPORT_SYMBOL (__ktimeout_mod);/*** * ktimeout_add_on - start a timeout on a particular CPU
@@ -287,7 +287,7 @@ int mod_ktimeout(struct ktimeout *ktimeoif (ktimeout->expires == expires &&ktimeout_pending (ktimeout))return 1 ; -return __mod_ktimeout (ktimeout, expires); +return __ktimeout_mod (ktimeout, expires); }EXPORT_SYMBOL (mod_ktimeout);
@@ -622,7 +622,7 @@ fastcall signed long __sched schedule_ti expire = timeout + jiffies;ktimeout_setup (&ktimeout, process_timeout, (unsigned long )current); -__mod_ktimeout (&ktimeout, expire); +__ktimeout_mod (&ktimeout, expire);schedule ();del_singleshot_ktimeout_sync (&ktimeout);
--
PATCH 36/43 rename mod_ktimeout() to ktimeout_mod()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_mod.patch)
- rename mod_ktimeout() to ktimeout_mod()
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 2 +- kernel/ktimeout.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -63,7 +63,7 @@ static inline int ktimeout_pending(constextern void ktimeout_add_on (struct ktimeout *ktimeout,int cpu);extern int ktimeout_del (struct ktimeout * ktimeout);extern int __ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires); -extern int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires); +extern int ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires);extern unsigned long next_ktimeout_interrupt (void );
include/linux/timer.h +1 -1
@@ -22,7 +22,7 @@#define add_timer_on ktimeout_add_on#define del_timer ktimeout_del#define __mod_timer __ktimeout_mod -#define mod_timer mod_ktimeout +#define mod_timer ktimeout_mod#define next_timer_interrupt next_ktimeout_interrupt#define add_timer add_ktimeout#define try_to_del_timer_sync try_to_del_ktimeout_sync
kernel/ktimeout.c +7 -7
@@ -257,25 +257,25 @@ void ktimeout_add_on(struct ktimeout *kt/*** -* mod_ktimeout - modify a timeout's interval +* ktimeout_mod - modify a timeout's interval * @ktimeout: the timeout to be modified * -* mod_ktimeout is a more efficient way to update the expire field of an +* ktimeout_mod is a more efficient way to update the expire field of an * active timeout (if the timeout is inactive it will be activated) * -* mod_ktimeout(ktimeout, expires) is equivalent to: +* ktimeout_mod(ktimeout, expires) is equivalent to: * * ktimeout_del(ktimeout); ktimeout->expires = expires; add_ktimeout(ktimeout); * * Note that if there are multiple unserialized concurrent users of the same -* timeout, then mod_ktimeout() is the only safe way to modify the interval, +* timeout, then ktimeout_mod() is the only safe way to modify the interval, * since add_ktimeout() cannot modify an already running ktimeout. * * The function returns whether it has modified a pending timeout or not. -* (ie. mod_ktimeout() of an inactive timeout returns 0, mod_ktimeout() of an +* (ie. ktimeout_mod() of an inactive timeout returns 0, ktimeout_mod() of an * active timeout returns 1.) */ -int mod_ktimeout (struct ktimeout *ktimeout,unsigned long expires) +int ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires) {BUG_ON (!ktimeout->function);
@@ -290,7 +290,7 @@ int mod_ktimeout(struct ktimeout *ktimeoreturn __ktimeout_mod (ktimeout, expires); } -EXPORT_SYMBOL (mod_ktimeout); +EXPORT_SYMBOL (ktimeout_mod);/*** * ktimeout_del - deactive a timeout.
--
PATCH 37/43 rename next_ktimeout_interrupt() to ktimeout_next_interrupt()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_next_interrupt.patch)
- rename next_ktimeout_interrupt() to ktimeout_next_interrupt()
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 2 +- kernel/ktimeout.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -65,7 +65,7 @@ extern int ktimeout_del(struct ktimeoutextern int __ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires);extern int ktimeout_mod (struct ktimeout *ktimeout,unsigned long expires); -extern unsigned long next_ktimeout_interrupt (void ); +extern unsigned long ktimeout_next_interrupt (void );/*** * add_ktimeout - start a ktimeout
include/linux/timer.h +1 -1
@@ -23,7 +23,7 @@#define del_timer ktimeout_del#define __mod_timer __ktimeout_mod#define mod_timer ktimeout_mod -#define next_timer_interrupt next_ktimeout_interrupt +#define next_timer_interrupt ktimeout_next_interrupt#define add_timer add_ktimeout#define try_to_del_timer_sync try_to_del_ktimeout_sync#define del_timer_sync del_ktimeout_sync
kernel/ktimeout.c +1 -1
@@ -470,7 +470,7 @@ static inline void __run_ktimeouts(tvec_* is used on S/390 to stop all activity when a cpus is idle. * This functions needs to be called disabled. */ -unsigned long next_ktimeout_interrupt (void ) +unsigned long ktimeout_next_interrupt (void ) {tvec_base_t *base;struct list_head *list;
--
PATCH 38/43 rename add_ktimeout() to ktimeout_add()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_add.patch)
- rename add_ktimeout() to ktimeout_add()
include/linux/ktimeout.h | 4 ++-- include/linux/timer.h | 2 +- kernel/ktimeout.c | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-)
include/linux/ktimeout.h +2 -2
@@ -68,7 +68,7 @@ extern int ktimeout_mod(struct ktimeoutextern unsigned long ktimeout_next_interrupt (void );/*** -* add_ktimeout - start a ktimeout +* ktimeout_add - start a ktimeout * @ktimeout: the timeout to be added * * The kernel will do a ->function(->data) callback from the
@@ -81,7 +81,7 @@ extern unsigned long ktimeout_next_inter* Timers with an ->expired field in the past will be executed in the next * timeout tick. */ -static inline void add_ktimeout (struct ktimeout *ktimeout) +static inline void ktimeout_add (struct ktimeout *ktimeout) {BUG_ON (ktimeout_pending (ktimeout));__ktimeout_mod (ktimeout, ktimeout->expires);
include/linux/timer.h +1 -1
@@ -24,7 +24,7 @@#define __mod_timer __ktimeout_mod#define mod_timer ktimeout_mod#define next_timer_interrupt ktimeout_next_interrupt -#define add_timer add_ktimeout +#define add_timer ktimeout_add#define try_to_del_timer_sync try_to_del_ktimeout_sync#define del_timer_sync del_ktimeout_sync#define del_singleshot_timer_sync del_singleshot_ktimeout_sync
kernel/ktimeout.c +7 -7
@@ -82,7 +82,7 @@ static inline void set_running_ktimeout(#endif } -static void internal_add_ktimeout (tvec_base_t *base,struct ktimeout *ktimeout) +static void internal_ktimeout_add (tvec_base_t *base,struct ktimeout *ktimeout) {unsigned long expires = ktimeout->expires;unsigned long idx = expires - base->ktimeout_jiffies;
@@ -228,7 +228,7 @@ int __ktimeout_mod(struct ktimeout *ktim } ktimeout->expires = expires; -internal_add_ktimeout (new_base, ktimeout); +internal_ktimeout_add (new_base, ktimeout);spin_unlock_irqrestore (&new_base->t_base.lock, flags);return ret;
@@ -251,7 +251,7 @@ void ktimeout_add_on(struct ktimeout *ktBUG_ON (ktimeout_pending (ktimeout) || !ktimeout->function);spin_lock_irqsave (&base->t_base.lock, flags); ktimeout->base = &base->t_base; -internal_add_ktimeout (base, ktimeout); +internal_ktimeout_add (base, ktimeout);spin_unlock_irqrestore (&base->t_base.lock, flags); }
@@ -265,11 +265,11 @@ void ktimeout_add_on(struct ktimeout *kt* * ktimeout_mod(ktimeout, expires) is equivalent to: * -* ktimeout_del(ktimeout); ktimeout->expires = expires; add_ktimeout(ktimeout); +* ktimeout_del(ktimeout); ktimeout->expires = expires; ktimeout_add(ktimeout); * * Note that if there are multiple unserialized concurrent users of the same * timeout, then ktimeout_mod() is the only safe way to modify the interval, -* since add_ktimeout() cannot modify an already running ktimeout. +* since ktimeout_add() cannot modify an already running ktimeout. * * The function returns whether it has modified a pending timeout or not. * (ie. ktimeout_mod() of an inactive timeout returns 0, ktimeout_mod() of an
@@ -398,7 +398,7 @@ static int cascade(tvec_base_t *base, tv tmp = list_entry(curr, struct ktimeout, entry);BUG_ON (tmp->base != &base->t_base); curr = curr->next; -internal_add_ktimeout (base, tmp); +internal_ktimeout_add (base, tmp); }INIT_LIST_HEAD (head);
@@ -708,7 +708,7 @@ static void migrate_ktimeout(tvec_base_t ktimeout = list_entry(head->next, struct ktimeout, entry);detach_ktimeout (ktimeout,0 ); ktimeout->base = &new_base->t_base; -internal_add_ktimeout (new_base, ktimeout); +internal_ktimeout_add (new_base, ktimeout); } }
--
PATCH 39/43 rename try_to_del_ktimeout_sync() to ktimeout_try_to_del_sync()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_try_to_del_sync.patch)
- rename try_to_del_ktimeout_sync() to ktimeout_try_to_del_sync()
include/linux/ktimeout.h | 4 ++-- include/linux/timer.h | 2 +- kernel/ktimeout.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
include/linux/ktimeout.h +2 -2
@@ -88,10 +88,10 @@ static inline void ktimeout_add(struct k }#ifdef CONFIG_SMP -extern int try_to_del_ktimeout_sync (struct ktimeout *ktimeout); +extern int ktimeout_try_to_del_sync (struct ktimeout *ktimeout);extern int del_ktimeout_sync (struct ktimeout *ktimeout);#else -# define try_to_del_ktimeout_sync (t) ktimeout_del(t) +# define ktimeout_try_to_del_sync (t) ktimeout_del(t)# define del_ktimeout_sync (t) ktimeout_del(t)#endif
include/linux/timer.h +1 -1
@@ -25,7 +25,7 @@#define mod_timer ktimeout_mod#define next_timer_interrupt ktimeout_next_interrupt#define add_timer ktimeout_add -#define try_to_del_timer_sync try_to_del_ktimeout_sync +#define try_to_del_timer_sync ktimeout_try_to_del_sync#define del_timer_sync del_ktimeout_sync#define del_singleshot_timer_sync del_singleshot_ktimeout_sync#define init_timers init_ktimeouts
kernel/ktimeout.c +2 -2
@@ -330,7 +330,7 @@ EXPORT_SYMBOL(ktimeout_del);* * It must not be called from interrupt contexts. */ -int try_to_del_ktimeout_sync (struct ktimeout *ktimeout) +int ktimeout_try_to_del_sync (struct ktimeout *ktimeout) {ktimeout_base_t *base;unsigned long flags;
@@ -372,7 +372,7 @@ out:int del_ktimeout_sync (struct ktimeout *ktimeout) {for (;;) { -int ret =try_to_del_ktimeout_sync (ktimeout); +int ret =ktimeout_try_to_del_sync (ktimeout);if (ret >=0 )return ret; }
--
PATCH 40/43 rename del_ktimeout_sync() to del_ktimeout_sync()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_del_sync.patch)
- rename del_ktimeout_sync() to del_ktimeout_sync()
include/linux/ktimeout.h | 6 +++--- include/linux/timer.h | 2 +- kernel/ktimeout.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
include/linux/ktimeout.h +3 -3
@@ -89,13 +89,13 @@ static inline void ktimeout_add(struct k#ifdef CONFIG_SMP extern int ktimeout_try_to_del_sync (struct ktimeout *ktimeout); -extern int del_ktimeout_sync (struct ktimeout *ktimeout); +extern int ktimeout_del_sync (struct ktimeout *ktimeout);#else # define ktimeout_try_to_del_sync (t) ktimeout_del(t) -# define del_ktimeout_sync (t) ktimeout_del(t) +# define ktimeout_del_sync (t) ktimeout_del(t)#endif -#define del_singleshot_ktimeout_sync (t) del_ktimeout_sync(t) +#define del_singleshot_ktimeout_sync (t) ktimeout_del_sync(t)extern void init_ktimeouts (void );extern void run_local_ktimeouts (void );
include/linux/timer.h +1 -1
@@ -26,7 +26,7 @@#define next_timer_interrupt ktimeout_next_interrupt#define add_timer ktimeout_add#define try_to_del_timer_sync ktimeout_try_to_del_sync -#define del_timer_sync del_ktimeout_sync +#define del_timer_sync ktimeout_del_sync#define del_singleshot_timer_sync del_singleshot_ktimeout_sync#define init_timers init_ktimeouts#define run_local_timers run_local_ktimeouts
kernel/ktimeout.c +4 -4
@@ -211,7 +211,7 @@ int __ktimeout_mod(struct ktimeout *ktim/* * We are trying to schedule the timeout on the local CPU. * However we can't change timeout's base while it is running, -* otherwise del_ktimeout_sync() can't detect that the timeout's +* otherwise ktimeout_del_sync() can't detect that the timeout's * handler yet has not finished. This also guarantees that * the timeout is serialized wrt itself. */
@@ -353,7 +353,7 @@ out: }/*** -* del_ktimeout_sync - deactivate a timeout and wait for the handler to finish. +* ktimeout_del_sync - deactivate a timeout and wait for the handler to finish. * @ktimeout: the timeout to be deactivated * * This function only differs from ktimeout_del() on SMP: besides deactivating
@@ -369,7 +369,7 @@ out:* * The function returns whether it has deactivated a pending timeout or not. */ -int del_ktimeout_sync (struct ktimeout *ktimeout) +int ktimeout_del_sync (struct ktimeout *ktimeout) {for (;;) {int ret =ktimeout_try_to_del_sync (ktimeout);
@@ -378,7 +378,7 @@ int del_ktimeout_sync(struct ktimeout *k } } -EXPORT_SYMBOL (del_ktimeout_sync); +EXPORT_SYMBOL (ktimeout_del_sync);#endif static int cascade (tvec_base_t *base,tvec_t *tv,int index)
--
PATCH 41/43 rename del_singleshot_ktimeout_sync() to ktimeout_del_singleshot_sync()
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-ktimeout_del_singleshot_sync.patch)
- rename del_singleshot_ktimeout_sync() to ktimeout_del_singleshot_sync()
include/linux/ktimeout.h | 2 +- include/linux/timer.h | 2 +- kernel/ktimeout.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/ktimeout.h +1 -1
@@ -95,7 +95,7 @@ static inline void ktimeout_add(struct k# define ktimeout_del_sync (t) ktimeout_del(t)#endif -#define del_singleshot_ktimeout_sync (t) ktimeout_del_sync(t) +#define ktimeout_del_singleshot_sync (t) ktimeout_del_sync(t)extern void init_ktimeouts (void );extern void run_local_ktimeouts (void );
include/linux/timer.h +1 -1
@@ -27,7 +27,7 @@#define add_timer ktimeout_add#define try_to_del_timer_sync ktimeout_try_to_del_sync#define del_timer_sync ktimeout_del_sync -#define del_singleshot_timer_sync del_singleshot_ktimeout_sync +#define del_singleshot_timer_sync ktimeout_del_singleshot_sync#define init_timers init_ktimeouts#define run_local_timers run_local_ktimeouts
kernel/ktimeout.c +1 -1
@@ -624,7 +624,7 @@ fastcall signed long __sched schedule_tiktimeout_setup (&ktimeout, process_timeout, (unsigned long )current);__ktimeout_mod (&ktimeout, expire);schedule (); -del_singleshot_ktimeout_sync (&ktimeout); +ktimeout_del_singleshot_sync (&ktimeout); timeout = expire - jiffies;
--
PATCH 42/43 rename TIMER_SOFTIRQ to TIMEOUT_SOFTIRQ
In reply to a message not in the archiveplain text document attachment (ktimeout-rename-TIMER_SOFTIRQ.patch)
- rename TIMER_SOFTIRQ to TIMEOUT_SOFTIRQ
include/linux/interrupt.h | 2 +- kernel/ktimeout.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/interrupt.h +1 -1
@@ -109,7 +109,7 @@ extern void local_bh_enable(void);enum {HI_SOFTIRQ =0 , -TIMER_SOFTIRQ , +TIMEOUT_SOFTIRQ ,NET_TX_SOFTIRQ ,NET_RX_SOFTIRQ ,SCSI_SOFTIRQ ,
kernel/ktimeout.c +2 -2
@@ -550,7 +550,7 @@ static void run_ktimeout_softirq(struct*/ void run_local_ktimeouts (void ) { -raise_softirq (TIMER_SOFTIRQ ); +raise_softirq (TIMEOUT_SOFTIRQ ); }static void process_timeout (unsigned long __data)
@@ -773,5 +773,5 @@ void __init init_ktimeouts(void)ktimeout_cpu_notify (&ktimeouts_nb, (unsigned long )CPU_UP_PREPARE , (void *)(long )smp_processor_id ());register_cpu_notifier (&ktimeouts_nb); -open_softirq (TIMER_SOFTIRQ , run_ktimeout_softirq,NULL ); +open_softirq (TIMEOUT_SOFTIRQ , run_ktimeout_softirq,NULL ); }
--
PATCH 43/43 ktimeout code style cleanups
In reply to a message not in the archiveplain text document attachment (ktimeout-tidy.patch)
- code style cleanups
kernel/ktimeout.c | 41 ++++++++++++++--------------------------- 1 files changed, 14 insertions(+), 27 deletions(-)
kernel/ktimeout.c +14 -27
@@ -16,26 +16,12 @@* Designed by David S. Miller, Alexey Kuznetsov and Ingo Molnar */ -#include <linux/kernel_stat.h> +#include <linux/notifier.h> #include <linux/module.h> -#include <linux/interrupt.h> #include <linux/percpu.h> #include <linux/init.h> -#include <linux/mm.h> -#include <linux/swap.h> -#include <linux/notifier.h> -#include <linux/thread_info.h> -#include <linux/time.h> -#include <linux/jiffies.h> -#include <linux/posix-timers.h> #include <linux/cpu.h> -#include <linux/syscalls.h> - -#include <asm/uaccess.h> -#include <asm/unistd.h> -#include <asm/div64.h> -#include <asm/timex.h> -#include <asm/io.h> +#include <linux/mm.h> /* * per-CPU ktimeout vector definitions:
@@ -246,9 +232,9 @@ EXPORT_SYMBOL(__ktimeout_mod);void ktimeout_add_on (struct ktimeout *ktimeout,int cpu) {tvec_base_t *base = &per_cpu (tvec_bases, cpu); -unsigned long flags; +unsigned long flags; -BUG_ON (ktimeout_pending (ktimeout) || !ktimeout->function); +BUG_ON (ktimeout_pending (ktimeout) || !ktimeout->function);spin_lock_irqsave (&base->t_base.lock, flags); ktimeout->base = &base->t_base;internal_ktimeout_add (base, ktimeout);
@@ -389,7 +375,7 @@ static int cascade(tvec_base_t *base, tv head = tv->vec + index; curr = head->next;/* -* We are removing _all_ timeouts from the list, so we don't have to +* We are removing _all_ timeouts from the list, so we don't have to * detach them individually, just clear the list afterwards. */ while (curr != head) {
@@ -412,7 +398,8 @@ static int cascade(tvec_base_t *base, tv* This function cascades all vectors and executes all expired timeout * vectors. */ -#define INDEX (N ) (base->ktimeout_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASK +#define INDEX (N ) \ + (base->ktimeout_jiffies >> (TVR_BITS + N * TVN_BITS)) & TVN_MASKstatic inline void __run_ktimeouts (tvec_base_t *base) {
@@ -422,8 +409,8 @@ static inline void __run_ktimeouts(tvec_while (time_after_eq (jiffies, base->ktimeout_jiffies)) {struct list_head work_list =LIST_HEAD_INIT (work_list);struct list_head *head = &work_list; -int index = base->ktimeout_jiffies &TVR_MASK ; - +int index = base->ktimeout_jiffies &TVR_MASK ; +/* * Cascade timeouts: */
@@ -432,15 +419,15 @@ static inline void __run_ktimeouts(tvec_ (!cascade(base, &base->tv3, INDEX(1))) && !cascade(base, &base->tv4, INDEX(2)))cascade (base, &base->tv5,INDEX (3 )); - ++base->ktimeout_jiffies; + ++base->ktimeout_jiffies;list_splice_init (base->tv1.vec + index, &work_list);while (!list_empty (head)) {void (*fn)(unsigned long );unsigned long data; ktimeout = list_entry(head->next,struct ktimeout,entry); - fn = ktimeout->function; - data = ktimeout->data; + fn = ktimeout->function; + data = ktimeout->data;set_running_ktimeout (base, ktimeout);detach_ktimeout (ktimeout,1 );
@@ -540,7 +527,7 @@ static void run_ktimeout_softirq(struct {tvec_base_t *base = &__get_cpu_var (tvec_bases); -ktimer_run_queues (); +ktimer_run_queues ();if (time_after_eq (jiffies, base->ktimeout_jiffies))__run_ktimeouts (base); }
@@ -744,7 +731,7 @@ static void __devinit migrate_ktimeouts( }#endif /* CONFIG_HOTPLUG_CPU */ -static int __devinit ktimeout_cpu_notify (struct notifier_block *self, +static int __devinit ktimeout_cpu_notify (struct notifier_block *self,unsigned long action,void *hcpu) {long cpu = (long )hcpu;
--