aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_time.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix VIRTUAL and PROF interval timers for short intervals, broken at r247903.Alexander Motin2014-04-161-0/+8
| | | | | | | | | | | | Due to the way those timers are implemented, we can't handle very short intervals. In addition to that mentioned patch caused math overflows for short intervals. To avoid that round those intervals to 1 tick. PR: kern/187668 MFC after: 1 week Notes: svn path=/head/; revision=264550
* Implement compat32 wrappers for the ktimer_* syscalls.Konstantin Belousov2013-07-211-40/+50
| | | | | | | | | Reported, reviewed and tested by: Petr Salinger <Petr.Salinger@seznam.cz> Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=253530
* id_t is 64bit, provide the compat32 wrapper for clock_getcpuclockid2(2).Konstantin Belousov2013-07-201-14/+22
| | | | | | | | | Reported and tested by: Petr Salinger <Petr.Salinger@seznam.cz> PR: threads/180652 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=253494
* Allow to call clock_gettime() on the clock id for zombie process.Konstantin Belousov2013-07-131-7/+2
| | | | | | | | | Reported by: Petr Salinger <Petr.Salinger@seznam.cz> PR: threads/180496 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=253325
* Make kern_nanosleep() and pause_sbt() to use per-CPU sleep queues.Alexander Motin2013-03-121-3/+3
| | | | | | | | This removes significant sleep queue lock congestion on multithreaded microbenchmarks, making them scale to multiple CPUs almost linearly. Notes: svn path=/head/; revision=248186
* Reduce minimal time intervals of setitimer(2) from 1/HZ to 1/(16*HZ) byAlexander Motin2013-03-061-20/+25
| | | | | | | | | | | | | using callout_reset_sbt() instead of callout_reset(). We can't remove lower limit completely in this case because of significant processing overhead, caused by unability to use direct callout execution due to using process mutex in callout handler for sending SEGALRM signal. With support of periodic events that would allow unprivileged user to abuse the system. Reviewed by: davide Notes: svn path=/head/; revision=247903
* Fix time math overflows and improve zero intervals handling in poll(),Alexander Motin2013-03-061-1/+9
| | | | | | | | | select(), nanosleep() and kevent() functions after calloutng changes. Reported by: bde Notes: svn path=/head/; revision=247898
* MFcalloutng:Davide Italiano2013-03-041-23/+23
| | | | | | | | | | | | | | | kern_nanosleep() is now converted to use tsleep_sbt(). With this change nanosleep() and usleep() can handle sub-tick precision for timeouts. Also, try to help coalesce of events passing as argument to tsleep_bt() a precision value calculated as a percentage of the sleep time. This percentage is default 5%, but it can tuned according to users need via the sysctl interface. Sponsored by: Google Summer of Code 2012, iXsystems inc. Tested by: flo, marius, ian, markj, Fabian Keil Notes: svn path=/head/; revision=247797
* Fix a race between kern_setitimer() and realitexpire(), where theKonstantin Belousov2012-12-041-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | callout is started before kern_setitimer() acquires process mutex, but looses a race and kern_setitimer() gets the process mutex before the callout. Then, assuming that new specified struct itimerval has it_interval zero, but it_value non-zero, the callout, after it starts executing again, clears p->p_realtimer.it_value, but kern_setitimer() already rescheduled the callout. As the result of the race, both p_realtimer is zero, and the callout is rescheduled. Then, in the exit1(), the exit code sees that it_value is zero and does not even try to stop the callout. This allows the struct proc to be reused and eventually the armed callout is re-initialized. The consequence is the corrupted callwheel tailq. Use process mutex to interlock the callout start, which fixes the race. Reported and tested by: pho Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=243869
* Implement syscall clock_getcpuclockid2, so we can get a clock idDavid Xu2012-08-171-10/+139
| | | | | | | | | | | for process, thread or others we want to support. Use the syscall to implement POSIX API clock_getcpuclock and pthread_getcpuclockid. PR: 168417 Notes: svn path=/head/; revision=239347
* In order to maximize the re-usability of kernel code in user space thisKip Macy2011-09-161-15/+15
| | | | | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz) Notes: svn path=/head/; revision=225617
* Create a global thread hash table to speed up thread lookup, useDavid Xu2010-10-091-17/+11
| | | | | | | | | | | | | rwlock to protect the table. In old code, thread lookup is done with process lock held, to find a thread, kernel has to iterate through process and thread list, this is quite inefficient. With this change, test shows in extreme case performance is dramatically improved. Earlier patch was reviewed by: jhb, julian Notes: svn path=/head/; revision=213642
* Remove VOP_LEASE and supporting functions. This hasn't been used sinceRobert Watson2009-04-101-12/+0
| | | | | | | | | | | | | | | | | the removal of NQNFS, but was left in in case it was required for NFSv4. Since our new NFSv4 client and server can't use it for their requirements, GC the old mechanism, as well as other unused lease- related code and interfaces. Due to its impact on kernel programming and binary interfaces, this change should not be MFC'd. Proposed by: jeff Reviewed by: jeff Discussed with: rmacklem, zach loafman @ isilon Notes: svn path=/head/; revision=190888
* Correctly sanity-check timer IDs. [SA-09:06]Colin Percival2009-03-231-1/+2
| | | | | | | | | | | | | Limit the size of malloced buffer when dumping environment variables. [EN-09:01] Approved by: so (cperciva) Approved by: re (kensmith) Security: FreeBSD-SA-09:06.ktimer Errata: FreeBSD-EN-09:01.kenv Notes: svn path=/head/; revision=190301
* Remove even more unneeded variable assignments.Ed Schouten2009-02-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | kern_time.c: - Unused variable `p'. kern_thr.c: - Variable `error' is always caught immediately, so no reason to initialize it. There is no way that error != 0 at the end of create_thread(). kern_sig.c: - Unused variable `code'. kern_synch.c: - `rval' is always assigned in all different cases. kern_rwlock.c: - `v' is always overwritten with RW_UNLOCKED further on. kern_malloc.c: - `size' is always initialized with the proper value before being used. kern_exit.c: - `error' is always caught and returned immediately. abort2() never returns a non-zero value. kern_exec.c: - `len' is always assigned inside the if-statement right below it. tty_info.c: - `td' is always overwritten by FOREACH_THREAD_IN_PROC(). Found by: LLVM's scan-build Notes: svn path=/head/; revision=189074
* In realtimer_delete(), clear timer's value and interval to tellDavid Xu2008-10-201-0/+8
| | | | | | | | | | realtimer_expire() to not rearm the timer, otherwise there is a chance that a callout will be left there and be tiggered in future unexpectly. Bug reported by: tegge@ Notes: svn path=/head/; revision=184067
* Make sure reading td_runtime in critical section since thread may beDavid Xu2008-01-181-1/+2
| | | | | | | preempted and td_runtime will be modified. Notes: svn path=/head/; revision=175439
* Add POSIX clock id CLOCK_THREAD_CPUTIME_ID, this can be used to measureDavid Xu2008-01-181-0/+16
| | | | | | | per-thread runtime in user code. Notes: svn path=/head/; revision=175429
* rufetch and calcru sometimes should be called atomically together.Attilio Rao2007-06-091-0/+4
| | | | | | | | | | | | | This patch fixes places where they should be called atomically changing their locking requirements (both assume per-proc spinlock held) and introducing rufetchcalc which wrappers both calls to be performed in atomic way. Reviewed by: jeff Approved by: jeff (mentor) Notes: svn path=/head/; revision=170472
* Commit 14/14 of sched_lock decomposition.Jeff Roberson2007-06-051-4/+4
| | | | | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each) Notes: svn path=/head/; revision=170307
* Remove MAC Framework access control check entry points made redundant withRobert Watson2007-04-221-14/+0
| | | | | | | | | | | | | | | | | | | | | the introduction of priv(9) and MAC Framework entry points for privilege checking/granting. These entry points exactly aligned with privileges and provided no additional security context: - mac_check_sysarch_ioperm() - mac_check_kld_unload() - mac_check_settime() - mac_check_system_nfsd() Add mpo_priv_check() implementations to Biba and LOMAC policies, which, for each privilege, determine if they can be granted to processes considered unprivileged by those two policies. These mostly, but not entirely, align with the set of privileges granted in jails. Obtained from: TrustedBSD Project Notes: svn path=/head/; revision=168951
* Further system call comment cleanup:Robert Watson2007-03-051-26/+16
| | | | | | | | | | | | | - Remove also "MP SAFE" after prior "MPSAFE" pass. (suggested by bde) - Remove extra blank lines in some cases. - Add extra blank lines in some cases. - Remove no-op comments consisting solely of the function name, the word "syscall", or the system call name. - Add punctuation. - Re-wrap some comments. Notes: svn path=/head/; revision=167232
* Remove 'MPSAFE' annotations from the comments above most system calls: allRobert Watson2007-03-041-21/+0
| | | | | | | | | | | system calls now enter without Giant held, and then in some cases, acquire Giant explicitly. Remove a number of other MPSAFE annotations in the credential code and tweak one or two other adjacent comments. Notes: svn path=/head/; revision=167211
* - Remove third parameter of itimer_find, the parameter is always zero.David Xu2006-11-281-46/+16
| | | | | | | | - Call callout_drain on deleting POSIX timer. - Use kern_timer_delete in exiting hook. Notes: svn path=/head/; revision=164713
* Merge posix4/* into normal kernel hierarchy.Tom Rhodes2006-11-111-2/+1
| | | | | | | | Reviewed by: glanced at by jhb Approved by: silence on -arch@ and -standards@ Notes: svn path=/head/; revision=164184
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningRobert Watson2006-11-061-2/+3
| | | | | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net> Notes: svn path=/head/; revision=164033
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hRobert Watson2006-10-221-1/+2
| | | | | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA Notes: svn path=/head/; revision=163606
* Move tz_minuteswest and tz_dsttime to subr_clock.cPoul-Henning Kamp2006-10-021-3/+0
| | | | Notes: svn path=/head/; revision=162960
* First part of a little cleanup in the calendar/timezone/RTC handling.Poul-Henning Kamp2006-10-021-0/+1
| | | | | | | | | Move relevant variables to <sys/clock.h> and fix #includes as necessary. Use libkern's much more time- & spamce-efficient BCD routines. Notes: svn path=/head/; revision=162954
* - Change process_exec function handlers prototype to include structAlexander Leidinger2006-08-151-4/+11
| | | | | | | | | | | | | | | | image_params arg. - Change struct image_params to include struct sysentvec pointer and initialize it. - Change all consumers of process_exit/process_exec eventhandlers to new prototypes (includes splitting up into distinct exec/exit functions). - Add eventhandler to userret. Sponsored by: Google SoC 2006 Submitted by: rdivacky Parts suggested by: jhb (on hackers@) Notes: svn path=/head/; revision=161302
* INT_MAX is defined in file sys/limits.h, include the file now.David Xu2006-08-021-0/+1
| | | | Notes: svn path=/head/; revision=160910
* Let kernel POSIX timer code and mqueue code to use integer as a resourceDavid Xu2006-03-011-23/+23
| | | | | | | | handle, the timer_t and mqd_t types will be a pointer which userland will define it. Notes: svn path=/head/; revision=156134
* Fix compiling warning on 64 bits system.David Xu2005-12-091-1/+1
| | | | Notes: svn path=/head/; revision=153267
* Register itimers_event_hook as a kernel event handler, so I don'tDavid Xu2005-12-091-2/+9
| | | | | | | have to duplicate code to call it in exec() and exit1(). Notes: svn path=/head/; revision=153259
* 1. Set timer configuration values for sysconf().David Xu2005-12-011-2/+15
| | | | | | | | 2. Set overrun limit to INT_MAX, report ERANGE error if overrun will be greater than INT_MAX. Notes: svn path=/head/; revision=152983
* Add several aliases for existing clockid_t names to indicate that theRobert Watson2005-11-271-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | application wishes to request high precision time stamps be returned: Alias Existing CLOCK_REALTIME_PRECISE CLOCK_REALTIME CLOCK_MONOTONIC_PRECISE CLOCK_MONOTONIC CLOCK_UPTIME_PRECISE CLOCK_UPTIME Add experimental low-precision clockid_t names corresponding to these clocks, but implemented using cached timestamps in kernel rather than a full time counter query. This offers a minimum update rate of 1/HZ, but in practice will often be more frequent due to the frequency of time stamping in the kernel: New clockid_t name Approximates existing clockid_t CLOCK_REALTIME_FAST CLOCK_REALTIME CLOCK_MONOTONIC_FAST CLOCK_MONOTONIC CLOCK_UPTIME_FAST CLOCK_UPTIME Add one additional new clockid_t, CLOCK_SECOND, which returns the current second without performing a full time counter query or cache lookup overhead to make sure the cached timestamp is stable. This is intended to support very low granularity consumers, such as time(3). The names, visibility, and implementation of the above are subject to change, and will not be MFC'd any time soon. The goal is to expose lower quality time measurement to applications willing to sacrifice accuracy in performance critical paths, such as when taking time stamps for the purpose of rescheduling select() and poll() timeouts. Future changes might include retrofitting the time counter infrastructure to allow the "fast" time query mechanisms to use a different time counter, rather than a cached time counter (i.e., TSC). NOTE: With different underlying time mechanisms exposed, using different time query mechanisms in the same application may result in relative non-monoticity or the appearance of clock stalling for a single clockid_t, as a cached time stamp queried after a precision time stamp lookup may be "before" the time returned by the earlier live time counter query. Notes: svn path=/head/; revision=152844
* Add CLOCK_UPTIME to clock_gettime(2) reporting the currentAndre Oppermann2005-11-181-0/+2
| | | | | | | | | uptime measured in SI seconds. Sponsored by: TCP/IP Optimization Fundraise 2005 Notes: svn path=/head/; revision=152585
* Fix name compatible problem with POSIX standard. the sigval_ptr andDavid Xu2005-11-041-1/+1
| | | | | | | | | sigval_int really should be sival_ptr and sival_int. Also sigev_notify_function accepts a union sigval value but not a pointer. Notes: svn path=/head/; revision=152029
* Cleanup some signal interfaces. Now the tdsignal function acceptsDavid Xu2005-11-031-28/+11
| | | | | | | | | | | | both proc pointer and thread pointer, if thread pointer is NULL, tdsignal automatically finds a thread, otherwise it sends signal to given thread. Add utility function psignal_event to send a realtime sigevent to a process according to the delivery requirement specified in struct sigevent. Notes: svn path=/head/; revision=151993
* Let itimer store itimerspec instead of itimerval, so I don't have toDavid Xu2005-10-301-59/+118
| | | | | | | | | | | | | | | | | | | | | | convert to or from timeval frequently. Introduce function itimer_accept() to ack a timer signal in signal acceptance code, this allows us to return more fresh overrun counter than at signal generating time. while POSIX says: "the value returned by timer_getoverrun() shall apply to the most recent expiration signal delivery or acceptance for the timer,.." I prefer returning it at acceptance time. Introduce SIGEV_THREAD_ID notification mode, it is used by thread libary to request kernel to deliver signal to a specified thread, and in turn, the thread library may use the mechanism to implement SIGEV_THREAD which is required by POSIX. Timer signal is managed by timer code, so it can not fail even if signal queue is full filled by sigqueue syscall. Notes: svn path=/head/; revision=151869
* Don't touch last overrun if signal was already on queue.David Xu2005-10-231-2/+0
| | | | Notes: svn path=/head/; revision=151595
* Make p_itimers as a pointer, so file sys/proc.h does not need to includeDavid Xu2005-10-231-28/+25
| | | | | | | sys/timers.h. Notes: svn path=/head/; revision=151585
* Implement POSIX timers. Current only CLOCK_REALTIME and CLOCK_MONOTONICDavid Xu2005-10-231-2/+664
| | | | | | | | | | | | | | | clock are supported. I have plan to merge XSI timer ITIMER_REAL and other two CPU timers into the new code, current three slots are available for the XSI timers. The SIGEV_THREAD notification type is not supported yet because our sigevent struct lacks of two member fields: sigev_notify_function sigev_notify_attributes I have found the sigevent is used in AIO, so I won't add the two members unless the AIO code is adjusted. Notes: svn path=/head/; revision=151576
* Implement 32bit wrappers for clock_gettime, clock_settime, andPaul Saab2005-10-151-19/+51
| | | | | | | clock_getres. Notes: svn path=/head/; revision=151357
* Implement kern_adjtime(), kern_readv(), kern_sched_rr_get_interval(),John Baldwin2005-03-311-17/+34
| | | | | | | | kern_settimeofday(), and kern_writev() to allow for further stackgap reduction in the compat ABIs. Notes: svn path=/head/; revision=144445
* If the pointer to the new itimerval is NULL in kern_setitimer(), justJohn Baldwin2005-02-071-0/+3
| | | | | | | read the old value via kern_getitimer(). Notes: svn path=/head/; revision=141483
* Various and sundry style fixes.John Baldwin2005-02-071-4/+4
| | | | Notes: svn path=/head/; revision=141470
* Split out kernel side of {get,set}itimer(2) into two parts: the first thatMaxim Sobolev2005-01-251-34/+55
| | | | | | | | | | | pops data from the userland and pushes results back and the second which does actual processing. Use the latter to eliminate stackgap in the linux wrappers of those syscalls. MFC after: 2 weeks Notes: svn path=/head/; revision=140832
* move kern_nanosleep to sys/syscallsubr.hPaul Saab2005-01-191-0/+1
| | | | | | | Requested by: jhb Notes: svn path=/head/; revision=140483
* - rename nanosleep1 to kern_nanosleepPaul Saab2005-01-191-5/+3
| | | | | | | | | | - Add a 32bit syscall entry for nanosleep Reviewed by: peter Obtained from: Yahoo! Notes: svn path=/head/; revision=140481