2020
2121static void posix_cpu_timer_rearm (struct k_itimer * timer );
2222
23+ void posix_cputimers_group_init (struct posix_cputimers * pct , u64 cpu_limit )
24+ {
25+ posix_cputimers_init (pct );
26+ if (cpu_limit != RLIM_INFINITY )
27+ pct -> cputime_expires .prof_exp = cpu_limit * NSEC_PER_SEC ;
28+ }
29+
2330/*
2431 * Called after updating RLIMIT_CPU to run cpu timer and update
25- * tsk->signal->cputime_expires expiration cache if necessary. Needs
26- * siglock protection since other code may update expiration cache as
27- * well.
32+ * tsk->signal->posix_cputimers. cputime_expires expiration cache if
33+ * necessary. Needs siglock protection since other code may update
34+ * expiration cache as well.
2835 */
2936void update_rlimit_cpu (struct task_struct * task , unsigned long rlim_new )
3037{
@@ -447,10 +454,10 @@ static void arm_timer(struct k_itimer *timer)
447454
448455 if (CPUCLOCK_PERTHREAD (timer -> it_clock )) {
449456 head = p -> posix_cputimers .cpu_timers ;
450- cputime_expires = & p -> cputime_expires ;
457+ cputime_expires = & p -> posix_cputimers . cputime_expires ;
451458 } else {
452459 head = p -> signal -> posix_cputimers .cpu_timers ;
453- cputime_expires = & p -> signal -> cputime_expires ;
460+ cputime_expires = & p -> signal -> posix_cputimers . cputime_expires ;
454461 }
455462 head += CPUCLOCK_WHICH (timer -> it_clock );
456463
@@ -774,7 +781,7 @@ static void check_thread_timers(struct task_struct *tsk,
774781 struct list_head * firing )
775782{
776783 struct list_head * timers = tsk -> posix_cputimers .cpu_timers ;
777- struct task_cputime * tsk_expires = & tsk -> cputime_expires ;
784+ struct task_cputime * tsk_expires = & tsk -> posix_cputimers . cputime_expires ;
778785 u64 expires , stime , utime ;
779786 unsigned long soft ;
780787
@@ -785,7 +792,7 @@ static void check_thread_timers(struct task_struct *tsk,
785792 * If cputime_expires is zero, then there are no active
786793 * per thread CPU timers.
787794 */
788- if (task_cputime_zero (& tsk -> cputime_expires ))
795+ if (task_cputime_zero (tsk_expires ))
789796 return ;
790797
791798 task_cputime (tsk , & utime , & stime );
@@ -954,10 +961,10 @@ static void check_process_timers(struct task_struct *tsk,
954961 prof_expires = x ;
955962 }
956963
957- sig -> cputime_expires .prof_exp = prof_expires ;
958- sig -> cputime_expires .virt_exp = virt_expires ;
959- sig -> cputime_expires .sched_exp = sched_expires ;
960- if (task_cputime_zero (& sig -> cputime_expires ))
964+ sig -> posix_cputimers . cputime_expires .prof_exp = prof_expires ;
965+ sig -> posix_cputimers . cputime_expires .virt_exp = virt_expires ;
966+ sig -> posix_cputimers . cputime_expires .sched_exp = sched_expires ;
967+ if (task_cputime_zero (& sig -> posix_cputimers . cputime_expires ))
961968 stop_process_timers (sig );
962969
963970 sig -> cputimer .checking_timer = false;
@@ -1058,12 +1065,13 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
10581065{
10591066 struct signal_struct * sig ;
10601067
1061- if (!task_cputime_zero (& tsk -> cputime_expires )) {
1068+ if (!task_cputime_zero (& tsk -> posix_cputimers . cputime_expires )) {
10621069 struct task_cputime task_sample ;
10631070
10641071 task_cputime (tsk , & task_sample .utime , & task_sample .stime );
10651072 task_sample .sum_exec_runtime = tsk -> se .sum_exec_runtime ;
1066- if (task_cputime_expired (& task_sample , & tsk -> cputime_expires ))
1073+ if (task_cputime_expired (& task_sample ,
1074+ & tsk -> posix_cputimers .cputime_expires ))
10671075 return 1 ;
10681076 }
10691077
@@ -1088,7 +1096,8 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
10881096
10891097 sample_cputime_atomic (& group_sample , & sig -> cputimer .cputime_atomic );
10901098
1091- if (task_cputime_expired (& group_sample , & sig -> cputime_expires ))
1099+ if (task_cputime_expired (& group_sample ,
1100+ & sig -> posix_cputimers .cputime_expires ))
10921101 return 1 ;
10931102 }
10941103
@@ -1204,12 +1213,12 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
12041213 */
12051214 switch (clock_idx ) {
12061215 case CPUCLOCK_PROF :
1207- if (expires_gt (tsk -> signal -> cputime_expires .prof_exp , * newval ))
1208- tsk -> signal -> cputime_expires .prof_exp = * newval ;
1216+ if (expires_gt (tsk -> signal -> posix_cputimers . cputime_expires .prof_exp , * newval ))
1217+ tsk -> signal -> posix_cputimers . cputime_expires .prof_exp = * newval ;
12091218 break ;
12101219 case CPUCLOCK_VIRT :
1211- if (expires_gt (tsk -> signal -> cputime_expires .virt_exp , * newval ))
1212- tsk -> signal -> cputime_expires .virt_exp = * newval ;
1220+ if (expires_gt (tsk -> signal -> posix_cputimers . cputime_expires .virt_exp , * newval ))
1221+ tsk -> signal -> posix_cputimers . cputime_expires .virt_exp = * newval ;
12131222 break ;
12141223 }
12151224
0 commit comments