aboutsummaryrefslogtreecommitdiff
path: root/kernel/posix-timers.c
AgeCommit message (Collapse)AuthorFilesLines
2013-04-18posix-timers: Remove unused variableThomas Gleixner1-1/+0
Remove the unused variable *node introduced by commit 5ed67f05 (posix timers: Allocate timer id per process) Signed-off-by: Thomas Gleixner <[email protected]> Cc: Pavel Emelyanov <[email protected]>
2013-04-17posix timers: Allocate timer id per process (v2)Pavel Emelyanov1-37/+69
Currently kernel generates IDs for posix timers in a global manner -- there's a kernel-wide IDR tree from which IDs are created. This makes it impossible to recreate a timer with a desired ID (in particular this is done by the CRIU checkpoint-restore project) -- since these IDs are global it may happen, that at the time we recreate a timer, the ID we want for it is already busy by some other timer. In order to address this, replace the IDR tree with a global hash table for timers and makes timer IDs unique per signal_struct (to which timers are linked anyway). With this, two timers belonging to different processes may have equal IDs and we can recreate either of them with the ID we want. Signed-off-by: Pavel Emelyanov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Michael Kerrisk <[email protected]> Cc: Matthew Helsley <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
2013-03-22hrtimer: Add hrtimer support for CLOCK_TAIJohn Stultz1-0/+6
Add hrtimer support for CLOCK_TAI, as well as posix timer interfaces. Signed-off-by: John Stultz <[email protected]>
2013-03-22timekeeping: Add CLOCK_TAI clockidJohn Stultz1-0/+10
This add a CLOCK_TAI clockid and the needed accessors. CC: Thomas Gleixner <[email protected]> CC: Eric Dumazet <[email protected]> CC: Richard Cochran <[email protected]> Signed-off-by: John Stultz <[email protected]>
2013-02-27posix-timers: convert to idr_alloc()Tejun Heo1-10/+8
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2013-02-21posix-timer: Don't call idr_find() with out-of-range IDTejun Heo1-0/+7
When idr_find() was fed a negative ID, it used to look up the ID ignoring the sign bit before recent ("idr: remove MAX_IDR_MASK and move left MAX_IDR_* into idr.c") patch. Now a negative ID triggers a WARN_ON_ONCE(). __lock_timer() feeds timer_id from userland directly to idr_find() without sanitizing it which can trigger the above malfunctions. Add a range check on @timer_id before invoking idr_find() in __lock_timer(). While timer_t is defined as int by all archs at the moment, Andrew worries that it may be defined as a larger type later on. Make the test cover larger integers too so that it at least is guaranteed to not return the wrong timer. Note that WARN_ON_ONCE() in idr_find() on id < 0 is transitional precaution while moving away from ignoring MSB. Once it's gone we can remove the guard as long as timer_t isn't larger than int. Signed-off-by: Tejun Heo <[email protected]>nnn Reported-by: Sasha Levin <[email protected]> Cc: Andrew Morton <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
2013-01-15posix-timers: Fix clock_adjtime to always return timex data on successMiroslav Lichvar1-1/+1
The clock_adj call returns the clock state on success, which may be a non-zero value (e.g. TIME_INS), but the modified timex data is copied back to the user only when zero value (TIME_OK) was returned. Fix the condition to copy the data also with positive return values. Signed-off-by: Miroslav Lichvar <[email protected]> Signed-off-by: John Stultz <[email protected]>
2011-10-31kernel: Map most files to use export.h instead of module.hPaul Gortmaker1-1/+1
The changed files were only including linux/module.h for the EXPORT_SYMBOL infrastructure, and nothing else. Revector them onto the isolated export header for faster compile times. Nothing to see here but a whole lot of instances of: -#include <linux/module.h> +#include <linux/export.h> This commit is only changing the kernel dir; next targets will probably be mm, fs, the arch dirs, etc. Signed-off-by: Paul Gortmaker <[email protected]>
2011-05-24posix-timers: RCU conversionEric Dumazet1-11/+14
Ben Nagy reported a scalability problem with KVM/QEMU that hit very hard a single spinlock (idr_lock) in posix-timers code, on its 48 core machine. Even on a 16 cpu machine (2x4x2), a single test can show 98% of cpu time used in ticket_spin_lock, from lock_timer Ref: http://www.spinics.net/lists/kvm/msg51526.html Switching to RCU is quite easy, IDR being already RCU ready. idr_lock should be locked only for an insert/delete, not a lookup. Benchmark on a 2x4x2 machine, 16 processes calling timer_gettime(). Before : real 1m18.669s user 0m1.346s sys 1m17.180s After : real 0m3.296s user 0m1.366s sys 0m1.926s Reported-by: Ben Nagy <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Tested-by: Ben Nagy <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Avi Kivity <[email protected]> Cc: John Stultz <[email protected]> Cc: Richard Cochran <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2011-05-23hrtimers: Avoid touching inactive timer basesThomas Gleixner1-1/+1
Instead of iterating over all possible timer bases avoid it by marking the active bases in the cpu base. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Peter Zijlstra <[email protected]>
2011-03-31Fix common misspellingsLucas De Marchi1-1/+1
Fixes generated by 'codespell' and manually reviewed. Signed-off-by: Lucas De Marchi <[email protected]>
2011-02-21timers: Export CLOCK_BOOTTIME via the posix timers interfaceJohn Stultz1-1/+20
This patch exports CLOCK_BOOTTIME through the posix timers interface CC: Jamie Lokier <[email protected]> CC: Thomas Gleixner <[email protected]> CC: Alexander Shishkin <[email protected]> CC: Arve Hjønnevåg <[email protected]> Signed-off-by: John Stultz <[email protected]>
2011-02-02posix clocks: Introduce dynamic clocksRichard Cochran1-1/+3
This patch adds support for adding and removing posix clocks. The clock lifetime cycle is patterned after usb devices. Each clock is represented by a standard character device. In addition, the driver may optionally implement custom character device operations. The posix clock and timer system calls listed below now work with dynamic posix clocks, as well as the traditional static clocks. The following system calls are affected: - clock_adjtime (brand new syscall) - clock_gettime - clock_getres - clock_settime - timer_create - timer_delete - timer_gettime - timer_settime [ tglx: Adapted to the posix-timer cleanup. Moved clock_posix_dynamic to posix-clock.c and made all referenced functions static ] Signed-off-by: Richard Cochran <[email protected]> Acked-by: John Stultz <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2011-02-02posix-timers: Cleanup namespaceThomas Gleixner1-7/+8
Rename register_posix_clock() to posix_timers_register_clock(). That's what the function really does. As a side effect this cleans up the posix_clock namespace for the upcoming dynamic posix_clock infrastructure. Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Richard Cochran <[email protected]> Cc: John Stultz <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Add support for fd based clocksRichard Cochran1-1/+1
Extend the negative clockids which are currently used by posix cpu timers to encode the PID with a file descriptor based type which encodes the fd in the upper bits. Originally-from: Richard Cochran <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Introduce a syscall for clock tuning.Richard Cochran1-0/+30
A new syscall is introduced that allows tuning of a POSIX clock. The new call, clock_adjtime, takes two parameters, the clock ID and a pointer to a struct timex. Any ADJTIMEX(2) operation may be requested via this system call, but various POSIX clocks may or may not support tuning. [ tglx: Adapted to the posix-timer cleanup series. Avoid copy_to_user in the error case ] Signed-off-by: Richard Cochran <[email protected]> Acked-by: John Stultz <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2011-02-02posix-timer: Update commentRichard Cochran1-18/+7
Pick the cleanup to the comment in posix-timers.c from Richards all in one conversion patch. Originally-from: Richard Cochran <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Remove CLOCK_DISPATCH leftoversThomas Gleixner1-22/+0
All users gone. Remove the cruft. Huge thanks to Richard Cochran who tackled that maze first. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert timer_delete() to clockid_to_kclock()Thomas Gleixner1-2/+8
Set the common function for CLOCK_MONOTONIC and CLOCK_REALTIME kclocks and use the new decoding function. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert timer_gettime() to clockid_to_kclock()Thomas Gleixner1-4/+12
Set the common function for CLOCK_MONOTONIC and CLOCK_REALTIME kclocks and use the new decoding function. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert timer_settime() to clockid_to_kclock()Thomas Gleixner1-2/+8
Set the common function for CLOCK_MONOTONIC and CLOCK_REALTIME kclocks and use the new decoding function. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert timer_create() to clockid_to_kclock()Thomas Gleixner1-25/+15
Setup timer_create for CLOCK_MONOTONIC and CLOCK_REALTIME kclocks and remove the no_timer_create() implementation. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Remove useless res field from k_clockThomas Gleixner1-2/+0
The res member of kclock is only used by mmtimer.c, but even there it contains redundant information. Remove the field and fixup mmtimer. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert clock_getres() to clockid_to_kclock()Thomas Gleixner1-13/+4
Use the new kclock decoding. Fixup the fallout in mmtimer.c Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Make clock_getres and clock_get mandatoryThomas Gleixner1-3/+12
Richard said: "I would think that we can require k_clocks to provide the read function. This could be checked and enforced in register_posix_clock()." Add checks for clock_getres and clock_get in the register function. Suggested-by: Richard Cochran <[email protected]> Cc: John Stultz <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2011-02-02posix-timers: Convert clock_gettime() to clockid_to_kclock()Thomas Gleixner1-13/+15
Use the new kclock decoding mechanism and rename the misnomed common_clock_get() to posix_clock_realtime_get(). Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert clock_settime to clockid_to_kclock()Thomas Gleixner1-19/+12
Use the new kclock decoding function in clock_settime and cleanup all kclocks which use the default functions. Rename the misnomed common_clock_set() to posix_clock_realtime_set(). Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Cleanup restart_block usageThomas Gleixner1-1/+1
posix timers still use the legacy arg0-arg3 members of restart_block. Use restart_block.nanosleep instead Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert clock_nanosleep_restart to clockid_to_kclock()Thomas Gleixner1-12/+8
Use the new kclock decoding function in clock_nanosleep_restart. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Convert clock_nanosleep to clockid_to_kclock()Thomas Gleixner1-19/+7
Use the new kclock decoding function in clock_nanosleep and cleanup all kclocks which use the default functions. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Introduce clockid_to_kclock()Thomas Gleixner1-0/+10
New function to find the kclock for a given clockid. Returns a pointer to clock_posix_cpu if clockid < 0. If clockid >= MAXCLOCK or if the clock_getres pointer is not set it returns NULL. For valid clocks it returns a pointer to the matching posix_clock. Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Acked-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Cleanup struct initializersThomas Gleixner1-19/+19
Cosmetic. No functional change Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02posix-timers: Define nanosleep not supported error separateThomas Gleixner1-5/+9
Define the conditional nanosleep not supported error value outside of do_posix_clock_nonanosleep(). Preparatory patch for further cleanups. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: John Stultz <[email protected]> Tested-by: Richard Cochran <[email protected]> LKML-Reference: <[email protected]>
2011-02-02time: Correct the *settime* parametersRichard Cochran1-2/+2
Both settimeofday() and clock_settime() promise with a 'const' attribute not to alter the arguments passed in. This patch adds the missing 'const' attribute into the various kernel functions implementing these calls. Signed-off-by: Richard Cochran <[email protected]> Acked-by: John Stultz <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2010-10-21posix-timers: Annotate lock_timer()Namhyung Kim1-2/+8
lock_timer() conditionally grabs it_lock in case of returning non-NULL but unlock_timer() releases it unconditionally. This leads sparse to complain about the lock context imbalance. Rename and wrap lock_timer using __cond_lock() macro to make sparse happy. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2010-07-23posix_timer: Move copy_to_user(created_timer_id) down in timer_create()Andrey Vagin1-5/+6
According to Oleg Nesterov: We can move copy_to_user(created_timer_id) down after "if (timer_event_spec)" block too. (but before CLOCK_DISPATCH(), of course). Signed-off-by: Andrey Vagin <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Stanislaw Gruszka <[email protected]> Cc: Andrey Vagin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2010-05-27posix_timer: Fix error path in timer_createAndrey Vagin1-7/+4
Move CLOCK_DISPATCH(which_clock, timer_create, (new_timer)) after all posible EFAULT erros. *_timer_create may allocate/get resources. (for example posix_cpu_timer_create does get_task_struct) [ tglx: fold the remove crappy comment patch into this ] Signed-off-by: Andrey Vagin <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2010-02-05posix-timers.c: Don't export local functionsH Hartley Sweeten1-1/+1
Signed-off-by: H Hartley Sweeten <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2009-08-21time: Introduce CLOCK_REALTIME_COARSEjohn stultz1-0/+35
After talking with some application writers who want very fast, but not fine-grained timestamps, I decided to try to implement new clock_ids to clock_gettime(): CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE which returns the time at the last tick. This is very fast as we don't have to access any hardware (which can be very painful if you're using something like the acpi_pm clocksource), and we can even use the vdso clock_gettime() method to avoid the syscall. The only trade off is you only get low-res tick grained time resolution. This isn't a new idea, I know Ingo has a patch in the -rt tree that made the vsyscall gettimeofday() return coarse grained time when the vsyscall64 sysctrl was set to 2. However this affects all applications on a system. With this method, applications can choose the proper speed/granularity trade-off for themselves. Signed-off-by: John Stultz <[email protected]> Cc: Andi Kleen <[email protected]> Cc: [email protected] Cc: Darren Hart <[email protected]> Cc: [email protected] Cc: [email protected] LKML-Reference: <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2009-08-04posix-timers: Fix oops in clock_nanosleep() with CLOCK_MONOTONIC_RAWHiroshi Shimamoto1-0/+7
Prevent calling do_nanosleep() with clockid CLOCK_MONOTONIC_RAW, it may cause oops, such as NULL pointer dereference. Signed-off-by: Hiroshi Shimamoto <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2009-01-14[CVE-2009-0029] System call wrappers part 05Heiko Carstens1-24/+19
Signed-off-by: Heiko Carstens <[email protected]>
2008-12-25Merge branches 'timers/clocksource', 'timers/hpet', 'timers/hrtimers', ↵Ingo Molnar1-20/+20
'timers/nohz', 'timers/ntp', 'timers/posixtimers' and 'timers/rtc' into timers/core
2008-12-20Null pointer deref with hrtimer_try_to_cancel()Thomas Gleixner1-0/+6
Impact: Prevent kernel crash with posix timer clockid CLOCK_MONOTONIC_RAW commit 2d42244ae71d6c7b0884b5664cf2eda30fb2ae68 (clocksource: introduce CLOCK_MONOTONIC_RAW) introduced a new clockid, which is only available to read out the raw not NTP adjusted system time. The above commit did not prevent that a posix timer can be created with that clockid. The timer_create() syscall succeeds and initializes the timer to a non existing hrtimer base. When the timer is deleted either by timer_delete() or by the exit() cleanup the kernel crashes. Prevent the creation of timers for CLOCK_MONOTONIC_RAW by setting the posix clock function to no_timer_create which returns an error code. Reported-and-tested-by: Eric Sesterhenn <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-12-12posix-timers: check ->it_signal instead of ->it_pid to validate the timerOleg Nesterov1-10/+7
Impact: clean up, speed up ->it_pid (was ->it_process) has also a special meaning: if it is NULL, the timer is under deletion or it wasn't initialized yet. We can check ->it_signal != NULL instead, this way we can - simplify sys_timer_create() a bit - remove yet another check from lock_timer() - move put_pid(->it_pid) into release_posix_timer() which runs outside of ->it_lock Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2008-12-12posix-timers: use "struct pid*" instead of "struct task_struct*"Oleg Nesterov1-20/+23
Impact: restructure, clean up code k_itimer holds the ref to the ->it_process until sys_timer_delete(). This allows to pin up to RLIMIT_SIGPENDING dead task_struct's. Change the code to use "struct pid *" instead. The patch doesn't kill ->it_process, it places ->it_pid into the union. ->it_process is still used by do_cpu_nanosleep() as before. It would be trivial to change the nanosleep code as well, but since it uses it_process in a special way I think it is better to keep this field for grep. The patch bloats the kernel by 104 bytes and it also adds the new pointer, ->it_signal, to k_itimer. It is used by lock_timer() to verify that the found timer was not created by another process. It is not clear why do we use the global database (and thus the global idr_lock) for posix timers. We still need the signal_struct->posix_timers which contains all useable timers, perhaps it is better to use some form of per-process array instead. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>
2008-10-22Merge branch 'timers/range-hrtimers' into v28-range-hrtimers-for-linus-v2Thomas Gleixner1-6/+4
Conflicts: kernel/time/tick-sched.c Signed-off-by: Thomas Gleixner <[email protected]>
2008-10-20Merge branches 'timers/clocksource', 'timers/hrtimers', 'timers/nohz', ↵Thomas Gleixner1-93/+47
'timers/ntp', 'timers/posixtimers' and 'timers/debug' into v28-timers-for-linus
2008-10-17Merge commit 'linus/master' into merge-linusArjan van de Ven1-1/+1
Conflicts: arch/x86/kvm/i8254.c
2008-10-02fix error-path NULL deref in alloc_posix_timer()Dan Carpenter1-1/+1
Found by static checker (http://repo.or.cz/w/smatch.git). Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2008-09-24posix-timers: lock_timer: make it readableOleg Nesterov1-13/+10
Cleanup. Imho makes the code much more understandable. At least this patch lessens both the source and compiled code. Signed-off-by: Oleg Nesterov <[email protected]> Cc: [email protected] Cc: Roland McGrath <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]>