Commit 3cf29496 authored by Krzysztof Opasiak's avatar Krzysztof Opasiak Committed by Thomas Gleixner

posix-cpu-timers: Use dedicated helper to access rlimit values

Use rlimit() and rlimit_max() helper instead of manually writing
whole chain from task to rlimit value
Signed-off-by: default avatarKrzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170705172548.7911-1-k.opasiak@samsung.com
parent ef954844
...@@ -799,7 +799,6 @@ static void check_thread_timers(struct task_struct *tsk, ...@@ -799,7 +799,6 @@ static void check_thread_timers(struct task_struct *tsk,
struct list_head *firing) struct list_head *firing)
{ {
struct list_head *timers = tsk->cpu_timers; struct list_head *timers = tsk->cpu_timers;
struct signal_struct *const sig = tsk->signal;
struct task_cputime *tsk_expires = &tsk->cputime_expires; struct task_cputime *tsk_expires = &tsk->cputime_expires;
u64 expires; u64 expires;
unsigned long soft; unsigned long soft;
...@@ -823,10 +822,9 @@ static void check_thread_timers(struct task_struct *tsk, ...@@ -823,10 +822,9 @@ static void check_thread_timers(struct task_struct *tsk,
/* /*
* Check for the special case thread timers. * Check for the special case thread timers.
*/ */
soft = READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_cur); soft = task_rlimit(tsk, RLIMIT_RTTIME);
if (soft != RLIM_INFINITY) { if (soft != RLIM_INFINITY) {
unsigned long hard = unsigned long hard = task_rlimit_max(tsk, RLIMIT_RTTIME);
READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
if (hard != RLIM_INFINITY && if (hard != RLIM_INFINITY &&
tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) { tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
...@@ -847,7 +845,8 @@ static void check_thread_timers(struct task_struct *tsk, ...@@ -847,7 +845,8 @@ static void check_thread_timers(struct task_struct *tsk,
*/ */
if (soft < hard) { if (soft < hard) {
soft += USEC_PER_SEC; soft += USEC_PER_SEC;
sig->rlim[RLIMIT_RTTIME].rlim_cur = soft; tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur =
soft;
} }
if (print_fatal_signals) { if (print_fatal_signals) {
pr_info("RT Watchdog Timeout (soft): %s[%d]\n", pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
...@@ -938,11 +937,10 @@ static void check_process_timers(struct task_struct *tsk, ...@@ -938,11 +937,10 @@ static void check_process_timers(struct task_struct *tsk,
SIGPROF); SIGPROF);
check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime, check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
SIGVTALRM); SIGVTALRM);
soft = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur); soft = task_rlimit(tsk, RLIMIT_CPU);
if (soft != RLIM_INFINITY) { if (soft != RLIM_INFINITY) {
unsigned long psecs = div_u64(ptime, NSEC_PER_SEC); unsigned long psecs = div_u64(ptime, NSEC_PER_SEC);
unsigned long hard = unsigned long hard = task_rlimit_max(tsk, RLIMIT_CPU);
READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
u64 x; u64 x;
if (psecs >= hard) { if (psecs >= hard) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment