Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
timer.h File Reference
#include <linux/list.h>
#include <linux/ktime.h>
#include <linux/stddef.h>
#include <linux/debugobjects.h>
#include <linux/stringify.h>

Go to the source code of this file.

Data Structures

struct  timer_list
 

Macros

#define __TIMER_LOCKDEP_MAP_INITIALIZER(_kn)
 
#define TIMER_DEFERRABLE   0x1LU
 
#define TIMER_IRQSAFE   0x2LU
 
#define TIMER_FLAG_MASK   0x3LU
 
#define __TIMER_INITIALIZER(_function, _expires, _data, _flags)
 
#define TIMER_INITIALIZER(_function, _expires, _data)   __TIMER_INITIALIZER((_function), (_expires), (_data), 0)
 
#define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data)   __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE)
 
#define DEFINE_TIMER(_name, _function, _expires, _data)
 
#define __init_timer(_timer, _flags)   init_timer_key((_timer), (_flags), NULL, NULL)
 
#define __init_timer_on_stack(_timer, _flags)   init_timer_on_stack_key((_timer), (_flags), NULL, NULL)
 
#define init_timer(timer)   __init_timer((timer), 0)
 
#define init_timer_deferrable(timer)   __init_timer((timer), TIMER_DEFERRABLE)
 
#define init_timer_on_stack(timer)   __init_timer_on_stack((timer), 0)
 
#define __setup_timer(_timer, _fn, _data, _flags)
 
#define __setup_timer_on_stack(_timer, _fn, _data, _flags)
 
#define setup_timer(timer, fn, data)   __setup_timer((timer), (fn), (data), 0)
 
#define setup_timer_on_stack(timer, fn, data)   __setup_timer_on_stack((timer), (fn), (data), 0)
 
#define setup_deferrable_timer_on_stack(timer, fn, data)   __setup_timer_on_stack((timer), (fn), (data), TIMER_DEFERRABLE)
 
#define TIMER_NOT_PINNED   0
 
#define TIMER_PINNED   1
 
#define NEXT_TIMER_MAX_DELTA   ((1UL << 30) - 1)
 
#define del_timer_sync(t)   del_timer(t)
 
#define del_singleshot_timer_sync(t)   del_timer_sync(t)
 

Functions

void init_timer_key (struct timer_list *timer, unsigned int flags, const char *name, struct lock_class_key *key)
 
void add_timer_on (struct timer_list *timer, int cpu)
 
int del_timer (struct timer_list *timer)
 
int mod_timer (struct timer_list *timer, unsigned long expires)
 
int mod_timer_pending (struct timer_list *timer, unsigned long expires)
 
int mod_timer_pinned (struct timer_list *timer, unsigned long expires)
 
void set_timer_slack (struct timer_list *time, int slack_hz)
 
unsigned long get_next_timer_interrupt (unsigned long now)
 
void add_timer (struct timer_list *timer)
 
int try_to_del_timer_sync (struct timer_list *timer)
 
void init_timers (void)
 
void run_local_timers (void)
 
enum hrtimer_restart it_real_fn (struct hrtimer *)
 
unsigned long __round_jiffies (unsigned long j, int cpu)
 
unsigned long __round_jiffies_relative (unsigned long j, int cpu)
 
unsigned long round_jiffies (unsigned long j)
 
unsigned long round_jiffies_relative (unsigned long j)
 
unsigned long __round_jiffies_up (unsigned long j, int cpu)
 
unsigned long __round_jiffies_up_relative (unsigned long j, int cpu)
 
unsigned long round_jiffies_up (unsigned long j)
 
unsigned long round_jiffies_up_relative (unsigned long j)
 

Variables

struct tvec_base boot_tvec_bases
 

Macro Definition Documentation

#define __init_timer (   _timer,
  _flags 
)    init_timer_key((_timer), (_flags), NULL, NULL)

Definition at line 125 of file timer.h.

#define __init_timer_on_stack (   _timer,
  _flags 
)    init_timer_on_stack_key((_timer), (_flags), NULL, NULL)

Definition at line 127 of file timer.h.

#define __setup_timer (   _timer,
  _fn,
  _data,
  _flags 
)
Value:
do { \
__init_timer((_timer), (_flags)); \
(_timer)->function = (_fn); \
(_timer)->data = (_data); \
} while (0)

Definition at line 138 of file timer.h.

#define __setup_timer_on_stack (   _timer,
  _fn,
  _data,
  _flags 
)
Value:
do { \
__init_timer_on_stack((_timer), (_flags)); \
(_timer)->function = (_fn); \
(_timer)->data = (_data); \
} while (0)

Definition at line 145 of file timer.h.

#define __TIMER_INITIALIZER (   _function,
  _expires,
  _data,
  _flags 
)
Value:
{ \
.entry = { .prev = TIMER_ENTRY_STATIC }, \
.function = (_function), \
.expires = (_expires), \
.data = (_data), \
.base = (void *)((unsigned long)&boot_tvec_bases + (_flags)), \
.slack = -1, \
__FILE__ ":" __stringify(__LINE__)) \
}

Definition at line 73 of file timer.h.

#define __TIMER_LOCKDEP_MAP_INITIALIZER (   _kn)

Definition at line 48 of file timer.h.

#define DEFINE_TIMER (   _name,
  _function,
  _expires,
  _data 
)
Value:
struct timer_list _name = \
TIMER_INITIALIZER(_function, _expires, _data)

Definition at line 90 of file timer.h.

#define del_singleshot_timer_sync (   t)    del_timer_sync(t)

Definition at line 250 of file timer.h.

#define del_timer_sync (   t)    del_timer(t)

Definition at line 247 of file timer.h.

#define init_timer (   timer)    __init_timer((timer), 0)

Definition at line 131 of file timer.h.

#define init_timer_deferrable (   timer)    __init_timer((timer), TIMER_DEFERRABLE)

Definition at line 133 of file timer.h.

#define init_timer_on_stack (   timer)    __init_timer_on_stack((timer), 0)

Definition at line 135 of file timer.h.

#define NEXT_TIMER_MAX_DELTA   ((1UL << 30) - 1)

Definition at line 188 of file timer.h.

#define setup_deferrable_timer_on_stack (   timer,
  fn,
  data 
)    __setup_timer_on_stack((timer), (fn), (data), TIMER_DEFERRABLE)

Definition at line 156 of file timer.h.

#define setup_timer (   timer,
  fn,
  data 
)    __setup_timer((timer), (fn), (data), 0)

Definition at line 152 of file timer.h.

#define setup_timer_on_stack (   timer,
  fn,
  data 
)    __setup_timer_on_stack((timer), (fn), (data), 0)

Definition at line 154 of file timer.h.

#define TIMER_DEFERRABLE   0x1LU

Definition at line 68 of file timer.h.

#define TIMER_DEFERRED_INITIALIZER (   _function,
  _expires,
  _data 
)    __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE)

Definition at line 87 of file timer.h.

#define TIMER_FLAG_MASK   0x3LU

Definition at line 71 of file timer.h.

#define TIMER_INITIALIZER (   _function,
  _expires,
  _data 
)    __TIMER_INITIALIZER((_function), (_expires), (_data), 0)

Definition at line 84 of file timer.h.

#define TIMER_IRQSAFE   0x2LU

Definition at line 69 of file timer.h.

#define TIMER_NOT_PINNED   0

Definition at line 182 of file timer.h.

#define TIMER_PINNED   1

Definition at line 183 of file timer.h.

Function Documentation

unsigned long __round_jiffies ( unsigned long  j,
int  cpu 
)

__round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen

__round_jiffies() rounds an absolute time in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.

The return value is the rounded version of the parameter.

Definition at line 175 of file timer.c.

unsigned long __round_jiffies_relative ( unsigned long  j,
int  cpu 
)

__round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen

__round_jiffies_relative() rounds a time delta in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The exact rounding is skewed for each processor to avoid all processors firing at the exact same time, which could lead to lock contention or spurious cache line bouncing.

The return value is the rounded version of the parameter.

Definition at line 201 of file timer.c.

unsigned long __round_jiffies_up ( unsigned long  j,
int  cpu 
)

__round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded : the processor number on which the timeout will happen

This is the same as __round_jiffies() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 262 of file timer.c.

unsigned long __round_jiffies_up_relative ( unsigned long  j,
int  cpu 
)

__round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded : the processor number on which the timeout will happen

This is the same as __round_jiffies_relative() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 278 of file timer.c.

void add_timer ( struct timer_list timer)

add_timer - start a timer : the timer to be added

The kernel will do a ->function(->data) callback from the timer interrupt at the ->expires point in the future. The current time is 'jiffies'.

The timer's ->expires, ->function (and if the handler uses it, ->data) fields must be set prior calling this function.

Timers with an ->expires field in the past will be executed in the next timer tick.

Definition at line 906 of file timer.c.

void add_timer_on ( struct timer_list timer,
int  cpu 
)

add_timer_on - start a timer on a particular CPU : the timer to be added : the CPU to start it on

This is not very scalable on SMP. Double adds are not possible.

Definition at line 920 of file timer.c.

int del_timer ( struct timer_list timer)

del_timer - deactive a timer. : the timer to be deactivated

del_timer() deactivates a timer - this works on both active and inactive timers.

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.)

Definition at line 955 of file timer.c.

unsigned long get_next_timer_interrupt ( unsigned long  now)
void init_timer_key ( struct timer_list timer,
unsigned int  flags,
const char name,
struct lock_class_key key 
)

Definition at line 644 of file timer.c.

void init_timers ( void  )

Definition at line 1780 of file timer.c.

enum hrtimer_restart it_real_fn ( struct hrtimer )

Definition at line 121 of file itimer.c.

int mod_timer ( struct timer_list timer,
unsigned long  expires 
)

mod_timer - modify a timer's timeout : the timer to be modified : new timeout in jiffies

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_timer(timer, expires) is equivalent to:

del_timer(timer); timer->expires = expires; add_timer(timer);

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.

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.)

Definition at line 848 of file timer.c.

int mod_timer_pending ( struct timer_list timer,
unsigned long  expires 
)

mod_timer_pending - modify a pending timer's timeout : the pending timer to be modified : new timeout in jiffies

mod_timer_pending() is the same for pending timers as mod_timer(), but will not re-activate and modify already deleted timers.

It is useful for unserialized use of timers.

Definition at line 783 of file timer.c.

int mod_timer_pinned ( struct timer_list timer,
unsigned long  expires 
)

mod_timer_pinned - modify a timer's timeout : the timer to be modified : new timeout in jiffies

mod_timer_pinned() is a way to update the expire field of an active timer (if the timer is inactive it will be activated) and to ensure that the timer is scheduled on the current CPU.

Note that this does not prevent the timer from being migrated when the current CPU goes offline. If this is a problem for you, use CPU-hotplug notifiers to handle it correctly, for example, cancelling the timer when the corresponding CPU goes offline.

mod_timer_pinned(timer, expires) is equivalent to:

del_timer(timer); timer->expires = expires; add_timer(timer);

Definition at line 883 of file timer.c.

unsigned long round_jiffies ( unsigned long  j)

round_jiffies - function to round jiffies to a full second : the time in (absolute) jiffies that should be rounded

round_jiffies() rounds an absolute time in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The return value is the rounded version of the parameter.

Definition at line 225 of file timer.c.

unsigned long round_jiffies_relative ( unsigned long  j)

round_jiffies_relative - function to round jiffies to a full second : the time in (relative) jiffies that should be rounded

round_jiffies_relative() rounds a time delta in the future (in jiffies) up or down to (approximately) full seconds. This is useful for timers for which the exact time they fire does not matter too much, as long as they fire approximately every X seconds.

By rounding these timers to whole seconds, all such timers will fire at the same time, rather than at various times spread out. The goal of this is to have the CPU wake up less, which saves power.

The return value is the rounded version of the parameter.

Definition at line 246 of file timer.c.

unsigned long round_jiffies_up ( unsigned long  j)

round_jiffies_up - function to round jiffies up to a full second : the time in (absolute) jiffies that should be rounded

This is the same as round_jiffies() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 296 of file timer.c.

unsigned long round_jiffies_up_relative ( unsigned long  j)

round_jiffies_up_relative - function to round jiffies up to a full second : the time in (relative) jiffies that should be rounded

This is the same as round_jiffies_relative() except that it will never round down. This is useful for timeouts for which the exact time of firing does not matter too much, as long as they don't fire too early.

Definition at line 311 of file timer.c.

void run_local_timers ( void  )

Definition at line 1379 of file timer.c.

void set_timer_slack ( struct timer_list timer,
int  slack_hz 
)

set_timer_slack - set the allowed slack for a timer : the timer to be modified : the amount of time (in jiffies) allowed for rounding

Set the amount of time, in jiffies, that a certain timer has in terms of slack. By setting this value, the timer subsystem will schedule the actual timer somewhere between the time mod_timer() asks for, and that time plus the slack.

By setting the slack to -1, a percentage of the delay is used instead.

Definition at line 330 of file timer.c.

int try_to_del_timer_sync ( struct timer_list timer)

try_to_del_timer_sync - Try to deactivate a timer : timer do del

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.

Definition at line 981 of file timer.c.

Variable Documentation

struct tvec_base boot_tvec_bases

Definition at line 89 of file timer.c.