History

posix-cpu-timers: Get rid of zero checks

Deactivation of the expiry cache is done by setting all clock caches to 0. That requires to have a check for zero in all places which update the expiry cache: if (cache == 0 || new < cache) cache = new; Use U64_MAX as the deactivated value, which allows to remove the zero checks when updating the cache and reduces it to the obvious check: if (new < cache) cache = new; This also removes the weird workaround in do_prlimit() which was required to convert a RLIMIT_CPU value of 0 (immediate expiry) to 1 because handing in 0 to the posix CPU timer code would have effectively disarmed it.

Thomas Gleixner committed 7 years ago

Commit 2bbdbda1 parent 24db4dd3 files · +20 −34Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/posix-timers.h+5−2
@@ -86,7 +86,9 @@ struct posix_cputimers { · 85 unmodified lines
8686
8787 static inline void posix_cputimers_init(struct posix_cputimers *pct)
8888 {
89− memset(pct->bases, 0, sizeof(pct->bases));
89+ pct->bases[0].nextevt = U64_MAX;
90+ pct->bases[1].nextevt = U64_MAX;
91+ pct->bases[2].nextevt = U64_MAX;
9092 INIT_LIST_HEAD(&pct->bases[0].cpu_timers);
9193 INIT_LIST_HEAD(&pct->bases[1].cpu_timers);
9294 INIT_LIST_HEAD(&pct->bases[2].cpu_timers);
@@ -102,7 +104,8 @@ static inline void posix_cputimers_rt_watchdog(struct posix_cputimers *pct, · 9 unmodified lines
102104
103105 /* Init task static initializer */
104106 #define INIT_CPU_TIMERBASE(b) { \
105− .cpu_timers = LIST_HEAD_INIT(b.cpu_timers), \
107+ .nextevt = U64_MAX, \
108+ .cpu_timers = LIST_HEAD_INIT(b.cpu_timers), \
106109 }
107110
108111 #define INIT_CPU_TIMERBASES(b) { \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t