Linux Kernel
3.7.1
|
#include <linux/kernel_stat.h>
#include <linux/export.h>
#include <linux/interrupt.h>
#include <linux/percpu.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/pid_namespace.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 <linux/delay.h>
#include <linux/tick.h>
#include <linux/kallsyms.h>
#include <linux/irq_work.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/div64.h>
#include <asm/timex.h>
#include <asm/io.h>
#include <trace/events/timer.h>
Go to the source code of this file.
Data Structures | |
struct | tvec |
struct | tvec_root |
struct | tvec_base |
Macros | |
#define | CREATE_TRACE_POINTS |
#define | TVN_BITS (CONFIG_BASE_SMALL ? 4 : 6) |
#define | TVR_BITS (CONFIG_BASE_SMALL ? 6 : 8) |
#define | TVN_SIZE (1 << TVN_BITS) |
#define | TVR_SIZE (1 << TVR_BITS) |
#define | TVN_MASK (TVN_SIZE - 1) |
#define | TVR_MASK (TVR_SIZE - 1) |
#define | MAX_TVAL ((unsigned long)((1ULL << (TVR_BITS + 4*TVN_BITS)) - 1)) |
Functions | |
EXPORT_SYMBOL (jiffies_64) | |
EXPORT_SYMBOL (boot_tvec_bases) | |
unsigned long | __round_jiffies (unsigned long j, int cpu) |
EXPORT_SYMBOL_GPL (__round_jiffies) | |
unsigned long | __round_jiffies_relative (unsigned long j, int cpu) |
EXPORT_SYMBOL_GPL (__round_jiffies_relative) | |
unsigned long | round_jiffies (unsigned long j) |
EXPORT_SYMBOL_GPL (round_jiffies) | |
unsigned long | round_jiffies_relative (unsigned long j) |
EXPORT_SYMBOL_GPL (round_jiffies_relative) | |
unsigned long | __round_jiffies_up (unsigned long j, int cpu) |
EXPORT_SYMBOL_GPL (__round_jiffies_up) | |
unsigned long | __round_jiffies_up_relative (unsigned long j, int cpu) |
EXPORT_SYMBOL_GPL (__round_jiffies_up_relative) | |
unsigned long | round_jiffies_up (unsigned long j) |
EXPORT_SYMBOL_GPL (round_jiffies_up) | |
unsigned long | round_jiffies_up_relative (unsigned long j) |
EXPORT_SYMBOL_GPL (round_jiffies_up_relative) | |
void | set_timer_slack (struct timer_list *timer, int slack_hz) |
EXPORT_SYMBOL_GPL (set_timer_slack) | |
Variables | |
u64 jiffies_64 | __cacheline_aligned_in_smp = INITIAL_JIFFIES |
struct tvec_base | ____cacheline_aligned |
struct tvec_base | boot_tvec_bases |
#define MAX_TVAL ((unsigned long)((1ULL << (TVR_BITS + 4*TVN_BITS)) - 1)) |
__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.
__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.
__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.
__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.
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.
void add_timer_on | ( | struct timer_list * | timer, |
int | cpu | ||
) |
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.)
EXPORT_SYMBOL | ( | jiffies_64 | ) |
EXPORT_SYMBOL | ( | boot_tvec_bases | ) |
EXPORT_SYMBOL | ( | init_timer_key | ) |
EXPORT_SYMBOL | ( | mod_timer_pending | ) |
EXPORT_SYMBOL | ( | mod_timer | ) |
EXPORT_SYMBOL | ( | mod_timer_pinned | ) |
EXPORT_SYMBOL | ( | add_timer | ) |
EXPORT_SYMBOL | ( | del_timer | ) |
EXPORT_SYMBOL | ( | try_to_del_timer_sync | ) |
EXPORT_SYMBOL | ( | schedule_timeout | ) |
EXPORT_SYMBOL | ( | schedule_timeout_interruptible | ) |
EXPORT_SYMBOL | ( | schedule_timeout_killable | ) |
EXPORT_SYMBOL | ( | schedule_timeout_uninterruptible | ) |
EXPORT_SYMBOL | ( | msleep | ) |
EXPORT_SYMBOL | ( | msleep_interruptible | ) |
EXPORT_SYMBOL | ( | usleep_range | ) |
EXPORT_SYMBOL_GPL | ( | __round_jiffies | ) |
EXPORT_SYMBOL_GPL | ( | __round_jiffies_relative | ) |
EXPORT_SYMBOL_GPL | ( | round_jiffies | ) |
EXPORT_SYMBOL_GPL | ( | round_jiffies_relative | ) |
EXPORT_SYMBOL_GPL | ( | __round_jiffies_up | ) |
EXPORT_SYMBOL_GPL | ( | __round_jiffies_up_relative | ) |
EXPORT_SYMBOL_GPL | ( | round_jiffies_up | ) |
EXPORT_SYMBOL_GPL | ( | round_jiffies_up_relative | ) |
EXPORT_SYMBOL_GPL | ( | set_timer_slack | ) |
EXPORT_SYMBOL_GPL | ( | add_timer_on | ) |
void init_timer_key | ( | struct timer_list * | timer, |
unsigned int | flags, | ||
const char * | name, | ||
struct lock_class_key * | key | ||
) |
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.)
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.
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);
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.
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.
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.
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.
schedule_timeout - sleep until timeout : timeout value in jiffies
Make the current task sleep until jiffies have elapsed. The routine will return immediately unless the current task state has been set (see set_current_state()).
You can set the task state as follows -
TASK_UNINTERRUPTIBLE - at least jiffies are guaranteed to pass before the routine returns. The routine will return 0
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
The current task state is guaranteed to be TASK_RUNNING when this routine returns.
Specifying a value of MAX_SCHEDULE_TIMEOUT will schedule the CPU away without a bound on the timeout. In this case the return value will be MAX_SCHEDULE_TIMEOUT.
In all cases the return value is guaranteed to be non-negative.
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.
SYSCALL_DEFINE0 | ( | getpid | ) |
sys_getpid - return the thread group id of the current process
Note, despite the name, this returns the tgid not the pid. The tgid and the pid are identical unless CLONE_THREAD was specified on clone() in which case the tgid is the same in all threads of the same group.
This is SMP safe as current->tgid does not change.
int try_to_del_timer_sync | ( | struct timer_list * | timer | ) |
u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES |