Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'timers/posixtimers' into timers/tracing

Merge reason: timer tracepoint patches depend on both branches

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+208 -160
+1
arch/ia64/include/asm/cputime.h
··· 30 30 typedef u64 cputime64_t; 31 31 32 32 #define cputime_zero ((cputime_t)0) 33 + #define cputime_one_jiffy jiffies_to_cputime(1) 33 34 #define cputime_max ((~((cputime_t)0) >> 1) - 1) 34 35 #define cputime_add(__a, __b) ((__a) + (__b)) 35 36 #define cputime_sub(__a, __b) ((__a) - (__b))
+13
arch/powerpc/include/asm/cputime.h
··· 18 18 19 19 #ifndef CONFIG_VIRT_CPU_ACCOUNTING 20 20 #include <asm-generic/cputime.h> 21 + #ifdef __KERNEL__ 22 + static inline void setup_cputime_one_jiffy(void) { } 23 + #endif 21 24 #else 22 25 23 26 #include <linux/types.h> ··· 50 47 #define cputime_to_cputime64(__ct) (__ct) 51 48 52 49 #ifdef __KERNEL__ 50 + 51 + /* 52 + * One jiffy in timebase units computed during initialization 53 + */ 54 + extern cputime_t cputime_one_jiffy; 53 55 54 56 /* 55 57 * Convert cputime <-> jiffies ··· 95 87 if (sec) 96 88 ct += (cputime_t) sec * tb_ticks_per_sec; 97 89 return ct; 90 + } 91 + 92 + static inline void setup_cputime_one_jiffy(void) 93 + { 94 + cputime_one_jiffy = jiffies_to_cputime(1); 98 95 } 99 96 100 97 static inline cputime64_t jiffies64_to_cputime64(const u64 jif)
+4
arch/powerpc/kernel/time.c
··· 193 193 DEFINE_PER_CPU(unsigned long, cputime_last_delta); 194 194 DEFINE_PER_CPU(unsigned long, cputime_scaled_last_delta); 195 195 196 + cputime_t cputime_one_jiffy; 197 + 196 198 static void calc_cputime_factors(void) 197 199 { 198 200 struct div_result res; ··· 502 500 tb_to_xs = divres.result_low; 503 501 vdso_data->tb_ticks_per_sec = tb_ticks_per_sec; 504 502 vdso_data->tb_to_xs = tb_to_xs; 503 + setup_cputime_one_jiffy(); 505 504 } 506 505 else { 507 506 printk( "Titan recalibrate: FAILED (difference > 4 percent)\n" ··· 953 950 tb_ticks_per_usec = ppc_tb_freq / 1000000; 954 951 tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); 955 952 calc_cputime_factors(); 953 + setup_cputime_one_jiffy(); 956 954 957 955 /* 958 956 * Calculate the length of each tick in ns. It will not be
+1
arch/s390/include/asm/cputime.h
··· 42 42 #endif /* __s390x__ */ 43 43 44 44 #define cputime_zero (0ULL) 45 + #define cputime_one_jiffy jiffies_to_cputime(1) 45 46 #define cputime_max ((~0UL >> 1) - 1) 46 47 #define cputime_add(__a, __b) ((__a) + (__b)) 47 48 #define cputime_sub(__a, __b) ((__a) - (__b))
+1
include/asm-generic/cputime.h
··· 7 7 typedef unsigned long cputime_t; 8 8 9 9 #define cputime_zero (0UL) 10 + #define cputime_one_jiffy jiffies_to_cputime(1) 10 11 #define cputime_max ((~0UL >> 1) - 1) 11 12 #define cputime_add(__a, __b) ((__a) + (__b)) 12 13 #define cputime_sub(__a, __b) ((__a) - (__b))
+13 -3
include/linux/sched.h
··· 470 470 unsigned long ac_minflt, ac_majflt; 471 471 }; 472 472 473 + struct cpu_itimer { 474 + cputime_t expires; 475 + cputime_t incr; 476 + u32 error; 477 + u32 incr_error; 478 + }; 479 + 473 480 /** 474 481 * struct task_cputime - collected CPU time counts 475 482 * @utime: time spent in user mode, in &cputime_t units ··· 571 564 struct pid *leader_pid; 572 565 ktime_t it_real_incr; 573 566 574 - /* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ 575 - cputime_t it_prof_expires, it_virt_expires; 576 - cputime_t it_prof_incr, it_virt_incr; 567 + /* 568 + * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use 569 + * CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these 570 + * values are defined to 0 and 1 respectively 571 + */ 572 + struct cpu_itimer it[2]; 577 573 578 574 /* 579 575 * Thread group totals for process CPU timers.
+5 -4
kernel/fork.c
··· 62 62 #include <linux/fs_struct.h> 63 63 #include <linux/magic.h> 64 64 #include <linux/perf_counter.h> 65 + #include <linux/posix-timers.h> 65 66 66 67 #include <asm/pgtable.h> 67 68 #include <asm/pgalloc.h> ··· 791 790 thread_group_cputime_init(sig); 792 791 793 792 /* Expiration times and increments. */ 794 - sig->it_virt_expires = cputime_zero; 795 - sig->it_virt_incr = cputime_zero; 796 - sig->it_prof_expires = cputime_zero; 797 - sig->it_prof_incr = cputime_zero; 793 + sig->it[CPUCLOCK_PROF].expires = cputime_zero; 794 + sig->it[CPUCLOCK_PROF].incr = cputime_zero; 795 + sig->it[CPUCLOCK_VIRT].expires = cputime_zero; 796 + sig->it[CPUCLOCK_VIRT].incr = cputime_zero; 798 797 799 798 /* Cached expiration times. */ 800 799 sig->cputime_expires.prof_exp = cputime_zero;
+86 -78
kernel/itimer.c
··· 41 41 return ktime_to_timeval(rem); 42 42 } 43 43 44 + static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, 45 + struct itimerval *const value) 46 + { 47 + cputime_t cval, cinterval; 48 + struct cpu_itimer *it = &tsk->signal->it[clock_id]; 49 + 50 + spin_lock_irq(&tsk->sighand->siglock); 51 + 52 + cval = it->expires; 53 + cinterval = it->incr; 54 + if (!cputime_eq(cval, cputime_zero)) { 55 + struct task_cputime cputime; 56 + cputime_t t; 57 + 58 + thread_group_cputimer(tsk, &cputime); 59 + if (clock_id == CPUCLOCK_PROF) 60 + t = cputime_add(cputime.utime, cputime.stime); 61 + else 62 + /* CPUCLOCK_VIRT */ 63 + t = cputime.utime; 64 + 65 + if (cputime_le(cval, t)) 66 + /* about to fire */ 67 + cval = cputime_one_jiffy; 68 + else 69 + cval = cputime_sub(cval, t); 70 + } 71 + 72 + spin_unlock_irq(&tsk->sighand->siglock); 73 + 74 + cputime_to_timeval(cval, &value->it_value); 75 + cputime_to_timeval(cinterval, &value->it_interval); 76 + } 77 + 44 78 int do_getitimer(int which, struct itimerval *value) 45 79 { 46 80 struct task_struct *tsk = current; 47 - cputime_t cinterval, cval; 48 81 49 82 switch (which) { 50 83 case ITIMER_REAL: ··· 88 55 spin_unlock_irq(&tsk->sighand->siglock); 89 56 break; 90 57 case ITIMER_VIRTUAL: 91 - spin_lock_irq(&tsk->sighand->siglock); 92 - cval = tsk->signal->it_virt_expires; 93 - cinterval = tsk->signal->it_virt_incr; 94 - if (!cputime_eq(cval, cputime_zero)) { 95 - struct task_cputime cputime; 96 - cputime_t utime; 97 - 98 - thread_group_cputimer(tsk, &cputime); 99 - utime = cputime.utime; 100 - if (cputime_le(cval, utime)) { /* about to fire */ 101 - cval = jiffies_to_cputime(1); 102 - } else { 103 - cval = cputime_sub(cval, utime); 104 - } 105 - } 106 - spin_unlock_irq(&tsk->sighand->siglock); 107 - cputime_to_timeval(cval, &value->it_value); 108 - cputime_to_timeval(cinterval, &value->it_interval); 58 + get_cpu_itimer(tsk, CPUCLOCK_VIRT, value); 109 59 break; 110 60 case ITIMER_PROF: 111 - spin_lock_irq(&tsk->sighand->siglock); 112 - cval = tsk->signal->it_prof_expires; 113 - cinterval = tsk->signal->it_prof_incr; 114 - if (!cputime_eq(cval, cputime_zero)) { 115 - struct task_cputime times; 116 - cputime_t ptime; 117 - 118 - thread_group_cputimer(tsk, &times); 119 - ptime = cputime_add(times.utime, times.stime); 120 - if (cputime_le(cval, ptime)) { /* about to fire */ 121 - cval = jiffies_to_cputime(1); 122 - } else { 123 - cval = cputime_sub(cval, ptime); 124 - } 125 - } 126 - spin_unlock_irq(&tsk->sighand->siglock); 127 - cputime_to_timeval(cval, &value->it_value); 128 - cputime_to_timeval(cinterval, &value->it_interval); 61 + get_cpu_itimer(tsk, CPUCLOCK_PROF, value); 129 62 break; 130 63 default: 131 64 return(-EINVAL); ··· 127 128 return HRTIMER_NORESTART; 128 129 } 129 130 131 + static inline u32 cputime_sub_ns(cputime_t ct, s64 real_ns) 132 + { 133 + struct timespec ts; 134 + s64 cpu_ns; 135 + 136 + cputime_to_timespec(ct, &ts); 137 + cpu_ns = timespec_to_ns(&ts); 138 + 139 + return (cpu_ns <= real_ns) ? 0 : cpu_ns - real_ns; 140 + } 141 + 142 + static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, 143 + const struct itimerval *const value, 144 + struct itimerval *const ovalue) 145 + { 146 + cputime_t cval, nval, cinterval, ninterval; 147 + s64 ns_ninterval, ns_nval; 148 + struct cpu_itimer *it = &tsk->signal->it[clock_id]; 149 + 150 + nval = timeval_to_cputime(&value->it_value); 151 + ns_nval = timeval_to_ns(&value->it_value); 152 + ninterval = timeval_to_cputime(&value->it_interval); 153 + ns_ninterval = timeval_to_ns(&value->it_interval); 154 + 155 + it->incr_error = cputime_sub_ns(ninterval, ns_ninterval); 156 + it->error = cputime_sub_ns(nval, ns_nval); 157 + 158 + spin_lock_irq(&tsk->sighand->siglock); 159 + 160 + cval = it->expires; 161 + cinterval = it->incr; 162 + if (!cputime_eq(cval, cputime_zero) || 163 + !cputime_eq(nval, cputime_zero)) { 164 + if (cputime_gt(nval, cputime_zero)) 165 + nval = cputime_add(nval, cputime_one_jiffy); 166 + set_process_cpu_timer(tsk, clock_id, &nval, &cval); 167 + } 168 + it->expires = nval; 169 + it->incr = ninterval; 170 + 171 + spin_unlock_irq(&tsk->sighand->siglock); 172 + 173 + if (ovalue) { 174 + cputime_to_timeval(cval, &ovalue->it_value); 175 + cputime_to_timeval(cinterval, &ovalue->it_interval); 176 + } 177 + } 178 + 130 179 /* 131 180 * Returns true if the timeval is in canonical form 132 181 */ ··· 186 139 struct task_struct *tsk = current; 187 140 struct hrtimer *timer; 188 141 ktime_t expires; 189 - cputime_t cval, cinterval, nval, ninterval; 190 142 191 143 /* 192 144 * Validate the timevals in value. ··· 220 174 spin_unlock_irq(&tsk->sighand->siglock); 221 175 break; 222 176 case ITIMER_VIRTUAL: 223 - nval = timeval_to_cputime(&value->it_value); 224 - ninterval = timeval_to_cputime(&value->it_interval); 225 - spin_lock_irq(&tsk->sighand->siglock); 226 - cval = tsk->signal->it_virt_expires; 227 - cinterval = tsk->signal->it_virt_incr; 228 - if (!cputime_eq(cval, cputime_zero) || 229 - !cputime_eq(nval, cputime_zero)) { 230 - if (cputime_gt(nval, cputime_zero)) 231 - nval = cputime_add(nval, 232 - jiffies_to_cputime(1)); 233 - set_process_cpu_timer(tsk, CPUCLOCK_VIRT, 234 - &nval, &cval); 235 - } 236 - tsk->signal->it_virt_expires = nval; 237 - tsk->signal->it_virt_incr = ninterval; 238 - spin_unlock_irq(&tsk->sighand->siglock); 239 - if (ovalue) { 240 - cputime_to_timeval(cval, &ovalue->it_value); 241 - cputime_to_timeval(cinterval, &ovalue->it_interval); 242 - } 177 + set_cpu_itimer(tsk, CPUCLOCK_VIRT, value, ovalue); 243 178 break; 244 179 case ITIMER_PROF: 245 - nval = timeval_to_cputime(&value->it_value); 246 - ninterval = timeval_to_cputime(&value->it_interval); 247 - spin_lock_irq(&tsk->sighand->siglock); 248 - cval = tsk->signal->it_prof_expires; 249 - cinterval = tsk->signal->it_prof_incr; 250 - if (!cputime_eq(cval, cputime_zero) || 251 - !cputime_eq(nval, cputime_zero)) { 252 - if (cputime_gt(nval, cputime_zero)) 253 - nval = cputime_add(nval, 254 - jiffies_to_cputime(1)); 255 - set_process_cpu_timer(tsk, CPUCLOCK_PROF, 256 - &nval, &cval); 257 - } 258 - tsk->signal->it_prof_expires = nval; 259 - tsk->signal->it_prof_incr = ninterval; 260 - spin_unlock_irq(&tsk->sighand->siglock); 261 - if (ovalue) { 262 - cputime_to_timeval(cval, &ovalue->it_value); 263 - cputime_to_timeval(cinterval, &ovalue->it_interval); 264 - } 180 + set_cpu_itimer(tsk, CPUCLOCK_PROF, value, ovalue); 265 181 break; 266 182 default: 267 183 return -EINVAL;
+80 -70
kernel/posix-cpu-timers.c
··· 14 14 */ 15 15 void update_rlimit_cpu(unsigned long rlim_new) 16 16 { 17 - cputime_t cputime; 17 + cputime_t cputime = secs_to_cputime(rlim_new); 18 + struct signal_struct *const sig = current->signal; 18 19 19 - cputime = secs_to_cputime(rlim_new); 20 - if (cputime_eq(current->signal->it_prof_expires, cputime_zero) || 21 - cputime_gt(current->signal->it_prof_expires, cputime)) { 20 + if (cputime_eq(sig->it[CPUCLOCK_PROF].expires, cputime_zero) || 21 + cputime_gt(sig->it[CPUCLOCK_PROF].expires, cputime)) { 22 22 spin_lock_irq(&current->sighand->siglock); 23 23 set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); 24 24 spin_unlock_irq(&current->sighand->siglock); ··· 542 542 now); 543 543 } 544 544 545 + static inline int expires_gt(cputime_t expires, cputime_t new_exp) 546 + { 547 + return cputime_eq(expires, cputime_zero) || 548 + cputime_gt(expires, new_exp); 549 + } 550 + 551 + static inline int expires_le(cputime_t expires, cputime_t new_exp) 552 + { 553 + return !cputime_eq(expires, cputime_zero) && 554 + cputime_le(expires, new_exp); 555 + } 545 556 /* 546 557 * Insert the timer on the appropriate list before any timers that 547 558 * expire later. This must be called with the tasklist_lock held ··· 597 586 */ 598 587 599 588 if (CPUCLOCK_PERTHREAD(timer->it_clock)) { 589 + union cpu_time_count *exp = &nt->expires; 590 + 600 591 switch (CPUCLOCK_WHICH(timer->it_clock)) { 601 592 default: 602 593 BUG(); 603 594 case CPUCLOCK_PROF: 604 - if (cputime_eq(p->cputime_expires.prof_exp, 605 - cputime_zero) || 606 - cputime_gt(p->cputime_expires.prof_exp, 607 - nt->expires.cpu)) 608 - p->cputime_expires.prof_exp = 609 - nt->expires.cpu; 595 + if (expires_gt(p->cputime_expires.prof_exp, 596 + exp->cpu)) 597 + p->cputime_expires.prof_exp = exp->cpu; 610 598 break; 611 599 case CPUCLOCK_VIRT: 612 - if (cputime_eq(p->cputime_expires.virt_exp, 613 - cputime_zero) || 614 - cputime_gt(p->cputime_expires.virt_exp, 615 - nt->expires.cpu)) 616 - p->cputime_expires.virt_exp = 617 - nt->expires.cpu; 600 + if (expires_gt(p->cputime_expires.virt_exp, 601 + exp->cpu)) 602 + p->cputime_expires.virt_exp = exp->cpu; 618 603 break; 619 604 case CPUCLOCK_SCHED: 620 605 if (p->cputime_expires.sched_exp == 0 || 621 - p->cputime_expires.sched_exp > 622 - nt->expires.sched) 606 + p->cputime_expires.sched_exp > exp->sched) 623 607 p->cputime_expires.sched_exp = 624 - nt->expires.sched; 608 + exp->sched; 625 609 break; 626 610 } 627 611 } else { 612 + struct signal_struct *const sig = p->signal; 613 + union cpu_time_count *exp = &timer->it.cpu.expires; 614 + 628 615 /* 629 616 * For a process timer, set the cached expiration time. 630 617 */ ··· 630 621 default: 631 622 BUG(); 632 623 case CPUCLOCK_VIRT: 633 - if (!cputime_eq(p->signal->it_virt_expires, 634 - cputime_zero) && 635 - cputime_lt(p->signal->it_virt_expires, 636 - timer->it.cpu.expires.cpu)) 624 + if (expires_le(sig->it[CPUCLOCK_VIRT].expires, 625 + exp->cpu)) 637 626 break; 638 - p->signal->cputime_expires.virt_exp = 639 - timer->it.cpu.expires.cpu; 627 + sig->cputime_expires.virt_exp = exp->cpu; 640 628 break; 641 629 case CPUCLOCK_PROF: 642 - if (!cputime_eq(p->signal->it_prof_expires, 643 - cputime_zero) && 644 - cputime_lt(p->signal->it_prof_expires, 645 - timer->it.cpu.expires.cpu)) 630 + if (expires_le(sig->it[CPUCLOCK_PROF].expires, 631 + exp->cpu)) 646 632 break; 647 - i = p->signal->rlim[RLIMIT_CPU].rlim_cur; 633 + i = sig->rlim[RLIMIT_CPU].rlim_cur; 648 634 if (i != RLIM_INFINITY && 649 - i <= cputime_to_secs(timer->it.cpu.expires.cpu)) 635 + i <= cputime_to_secs(exp->cpu)) 650 636 break; 651 - p->signal->cputime_expires.prof_exp = 652 - timer->it.cpu.expires.cpu; 637 + sig->cputime_expires.prof_exp = exp->cpu; 653 638 break; 654 639 case CPUCLOCK_SCHED: 655 - p->signal->cputime_expires.sched_exp = 656 - timer->it.cpu.expires.sched; 640 + sig->cputime_expires.sched_exp = exp->sched; 657 641 break; 658 642 } 659 643 } ··· 1073 1071 spin_unlock_irqrestore(&cputimer->lock, flags); 1074 1072 } 1075 1073 1074 + static u32 onecputick; 1075 + 1076 + static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it, 1077 + cputime_t *expires, cputime_t cur_time, int signo) 1078 + { 1079 + if (cputime_eq(it->expires, cputime_zero)) 1080 + return; 1081 + 1082 + if (cputime_ge(cur_time, it->expires)) { 1083 + if (!cputime_eq(it->incr, cputime_zero)) { 1084 + it->expires = cputime_add(it->expires, it->incr); 1085 + it->error += it->incr_error; 1086 + if (it->error >= onecputick) { 1087 + it->expires = cputime_sub(it->expires, 1088 + cputime_one_jiffy); 1089 + it->error -= onecputick; 1090 + } 1091 + } else 1092 + it->expires = cputime_zero; 1093 + 1094 + __group_send_sig_info(signo, SEND_SIG_PRIV, tsk); 1095 + } 1096 + 1097 + if (!cputime_eq(it->expires, cputime_zero) && 1098 + (cputime_eq(*expires, cputime_zero) || 1099 + cputime_lt(it->expires, *expires))) { 1100 + *expires = it->expires; 1101 + } 1102 + } 1103 + 1076 1104 /* 1077 1105 * Check for any per-thread CPU timers that have fired and move them 1078 1106 * off the tsk->*_timers list onto the firing list. Per-thread timers ··· 1122 1090 * Don't sample the current process CPU clocks if there are no timers. 1123 1091 */ 1124 1092 if (list_empty(&timers[CPUCLOCK_PROF]) && 1125 - cputime_eq(sig->it_prof_expires, cputime_zero) && 1093 + cputime_eq(sig->it[CPUCLOCK_PROF].expires, cputime_zero) && 1126 1094 sig->rlim[RLIMIT_CPU].rlim_cur == RLIM_INFINITY && 1127 1095 list_empty(&timers[CPUCLOCK_VIRT]) && 1128 - cputime_eq(sig->it_virt_expires, cputime_zero) && 1096 + cputime_eq(sig->it[CPUCLOCK_VIRT].expires, cputime_zero) && 1129 1097 list_empty(&timers[CPUCLOCK_SCHED])) { 1130 1098 stop_process_timers(tsk); 1131 1099 return; ··· 1185 1153 /* 1186 1154 * Check for the special case process timers. 1187 1155 */ 1188 - if (!cputime_eq(sig->it_prof_expires, cputime_zero)) { 1189 - if (cputime_ge(ptime, sig->it_prof_expires)) { 1190 - /* ITIMER_PROF fires and reloads. */ 1191 - sig->it_prof_expires = sig->it_prof_incr; 1192 - if (!cputime_eq(sig->it_prof_expires, cputime_zero)) { 1193 - sig->it_prof_expires = cputime_add( 1194 - sig->it_prof_expires, ptime); 1195 - } 1196 - __group_send_sig_info(SIGPROF, SEND_SIG_PRIV, tsk); 1197 - } 1198 - if (!cputime_eq(sig->it_prof_expires, cputime_zero) && 1199 - (cputime_eq(prof_expires, cputime_zero) || 1200 - cputime_lt(sig->it_prof_expires, prof_expires))) { 1201 - prof_expires = sig->it_prof_expires; 1202 - } 1203 - } 1204 - if (!cputime_eq(sig->it_virt_expires, cputime_zero)) { 1205 - if (cputime_ge(utime, sig->it_virt_expires)) { 1206 - /* ITIMER_VIRTUAL fires and reloads. */ 1207 - sig->it_virt_expires = sig->it_virt_incr; 1208 - if (!cputime_eq(sig->it_virt_expires, cputime_zero)) { 1209 - sig->it_virt_expires = cputime_add( 1210 - sig->it_virt_expires, utime); 1211 - } 1212 - __group_send_sig_info(SIGVTALRM, SEND_SIG_PRIV, tsk); 1213 - } 1214 - if (!cputime_eq(sig->it_virt_expires, cputime_zero) && 1215 - (cputime_eq(virt_expires, cputime_zero) || 1216 - cputime_lt(sig->it_virt_expires, virt_expires))) { 1217 - virt_expires = sig->it_virt_expires; 1218 - } 1219 - } 1156 + check_cpu_itimer(tsk, &sig->it[CPUCLOCK_PROF], &prof_expires, ptime, 1157 + SIGPROF); 1158 + check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime, 1159 + SIGVTALRM); 1160 + 1220 1161 if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) { 1221 1162 unsigned long psecs = cputime_to_secs(ptime); 1222 1163 cputime_t x; ··· 1462 1457 if (!cputime_eq(*oldval, cputime_zero)) { 1463 1458 if (cputime_le(*oldval, now.cpu)) { 1464 1459 /* Just about to fire. */ 1465 - *oldval = jiffies_to_cputime(1); 1460 + *oldval = cputime_one_jiffy; 1466 1461 } else { 1467 1462 *oldval = cputime_sub(*oldval, now.cpu); 1468 1463 } ··· 1708 1703 .nsleep = thread_cpu_nsleep, 1709 1704 .nsleep_restart = thread_cpu_nsleep_restart, 1710 1705 }; 1706 + struct timespec ts; 1711 1707 1712 1708 register_posix_clock(CLOCK_PROCESS_CPUTIME_ID, &process); 1713 1709 register_posix_clock(CLOCK_THREAD_CPUTIME_ID, &thread); 1710 + 1711 + cputime_to_timespec(cputime_one_jiffy, &ts); 1712 + onecputick = ts.tv_nsec; 1713 + WARN_ON(ts.tv_sec != 0); 1714 1714 1715 1715 return 0; 1716 1716 }
+4 -5
kernel/sched.c
··· 5031 5031 */ 5032 5032 void account_process_tick(struct task_struct *p, int user_tick) 5033 5033 { 5034 - cputime_t one_jiffy = jiffies_to_cputime(1); 5035 - cputime_t one_jiffy_scaled = cputime_to_scaled(one_jiffy); 5034 + cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy); 5036 5035 struct rq *rq = this_rq(); 5037 5036 5038 5037 if (user_tick) 5039 - account_user_time(p, one_jiffy, one_jiffy_scaled); 5038 + account_user_time(p, cputime_one_jiffy, one_jiffy_scaled); 5040 5039 else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) 5041 - account_system_time(p, HARDIRQ_OFFSET, one_jiffy, 5040 + account_system_time(p, HARDIRQ_OFFSET, cputime_one_jiffy, 5042 5041 one_jiffy_scaled); 5043 5042 else 5044 - account_idle_time(one_jiffy); 5043 + account_idle_time(cputime_one_jiffy); 5045 5044 } 5046 5045 5047 5046 /*