All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] time: posix: Use dedicated helper to access rlimit values
       [not found] <CGME20170705172556epcas1p2ee555e8bfc7ac8b3d37efc2728456ad6@epcas1p2.samsung.com>
@ 2017-07-05 17:25 ` Krzysztof Opasiak
  2017-08-18 10:46   ` Thomas Gleixner
  2017-08-20  9:57   ` [tip:timers/core] posix-cpu-timers: " tip-bot for Krzysztof Opasiak
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Opasiak @ 2017-07-05 17:25 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, Krzysztof Opasiak

Use rlimit() and rlimit_max() helper instead of manually writing
whole chain from task to rlimit value

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
---
 kernel/time/posix-cpu-timers.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index d2a1e6dd0291..51b548c10959 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -790,7 +790,6 @@ static void check_thread_timers(struct task_struct *tsk,
 				struct list_head *firing)
 {
 	struct list_head *timers = tsk->cpu_timers;
-	struct signal_struct *const sig = tsk->signal;
 	struct task_cputime *tsk_expires = &tsk->cputime_expires;
 	u64 expires;
 	unsigned long soft;
@@ -814,10 +813,9 @@ static void check_thread_timers(struct task_struct *tsk,
 	/*
 	 * 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) {
-		unsigned long hard =
-			READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
+		unsigned long hard = task_rlimit_max(tsk, RLIMIT_RTTIME);
 
 		if (hard != RLIM_INFINITY &&
 		    tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
@@ -838,7 +836,8 @@ static void check_thread_timers(struct task_struct *tsk,
 			 */
 			if (soft < hard) {
 				soft += USEC_PER_SEC;
-				sig->rlim[RLIMIT_RTTIME].rlim_cur = soft;
+				tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur =
+					soft;
 			}
 			if (print_fatal_signals) {
 				pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
@@ -929,11 +928,10 @@ static void check_process_timers(struct task_struct *tsk,
 			 SIGPROF);
 	check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
 			 SIGVTALRM);
-	soft = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
+	soft = task_rlimit(tsk, RLIMIT_CPU);
 	if (soft != RLIM_INFINITY) {
 		unsigned long psecs = div_u64(ptime, NSEC_PER_SEC);
-		unsigned long hard =
-			READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
+		unsigned long hard = task_rlimit_max(tsk, RLIMIT_CPU);
 		u64 x;
 		if (psecs >= hard) {
 			/*
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/4] time: posix: Use dedicated helper to access rlimit values
  2017-07-05 17:25 ` [PATCH 2/4] time: posix: Use dedicated helper to access rlimit values Krzysztof Opasiak
@ 2017-08-18 10:46   ` Thomas Gleixner
  2017-08-20  9:57   ` [tip:timers/core] posix-cpu-timers: " tip-bot for Krzysztof Opasiak
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2017-08-18 10:46 UTC (permalink / raw)
  To: Krzysztof Opasiak; +Cc: linux-kernel

On Wed, 5 Jul 2017, Krzysztof Opasiak wrote:

> Use rlimit() and rlimit_max() helper instead of manually writing
> whole chain from task to rlimit value
> 
> Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
> ---
>  kernel/time/posix-cpu-timers.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
> index d2a1e6dd0291..51b548c10959 100644
> --- a/kernel/time/posix-cpu-timers.c
> +++ b/kernel/time/posix-cpu-timers.c
> @@ -790,7 +790,6 @@ static void check_thread_timers(struct task_struct *tsk,
>  				struct list_head *firing)
>  {
>  	struct list_head *timers = tsk->cpu_timers;
> -	struct signal_struct *const sig = tsk->signal;
>  	struct task_cputime *tsk_expires = &tsk->cputime_expires;
>  	u64 expires;
>  	unsigned long soft;
> @@ -814,10 +813,9 @@ static void check_thread_timers(struct task_struct *tsk,
>  	/*
>  	 * 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) {
> -		unsigned long hard =
> -			READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
> +		unsigned long hard = task_rlimit_max(tsk, RLIMIT_RTTIME);
>  
>  		if (hard != RLIM_INFINITY &&
>  		    tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
> @@ -838,7 +836,8 @@ static void check_thread_timers(struct task_struct *tsk,
>  			 */
>  			if (soft < hard) {
>  				soft += USEC_PER_SEC;
> -				sig->rlim[RLIMIT_RTTIME].rlim_cur = soft;
> +				tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur =
> +					soft;

Can you please create a helper for that as well?

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:timers/core] posix-cpu-timers: Use dedicated helper to access rlimit values
  2017-07-05 17:25 ` [PATCH 2/4] time: posix: Use dedicated helper to access rlimit values Krzysztof Opasiak
  2017-08-18 10:46   ` Thomas Gleixner
@ 2017-08-20  9:57   ` tip-bot for Krzysztof Opasiak
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Krzysztof Opasiak @ 2017-08-20  9:57 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: hpa, tglx, mingo, linux-kernel, k.opasiak

Commit-ID:  3cf294962df8fcde710eb5e762e0929e2ba49947
Gitweb:     http://git.kernel.org/tip/3cf294962df8fcde710eb5e762e0929e2ba49947
Author:     Krzysztof Opasiak <k.opasiak@samsung.com>
AuthorDate: Wed, 5 Jul 2017 19:25:48 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 18 Aug 2017 12:44:42 +0200

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: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170705172548.7911-1-k.opasiak@samsung.com

---
 kernel/time/posix-cpu-timers.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index a3bd5db..8585ad6 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -799,7 +799,6 @@ static void check_thread_timers(struct task_struct *tsk,
 				struct list_head *firing)
 {
 	struct list_head *timers = tsk->cpu_timers;
-	struct signal_struct *const sig = tsk->signal;
 	struct task_cputime *tsk_expires = &tsk->cputime_expires;
 	u64 expires;
 	unsigned long soft;
@@ -823,10 +822,9 @@ static void check_thread_timers(struct task_struct *tsk,
 	/*
 	 * 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) {
-		unsigned long hard =
-			READ_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
+		unsigned long hard = task_rlimit_max(tsk, RLIMIT_RTTIME);
 
 		if (hard != RLIM_INFINITY &&
 		    tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
@@ -847,7 +845,8 @@ static void check_thread_timers(struct task_struct *tsk,
 			 */
 			if (soft < hard) {
 				soft += USEC_PER_SEC;
-				sig->rlim[RLIMIT_RTTIME].rlim_cur = soft;
+				tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur =
+					soft;
 			}
 			if (print_fatal_signals) {
 				pr_info("RT Watchdog Timeout (soft): %s[%d]\n",
@@ -938,11 +937,10 @@ static void check_process_timers(struct task_struct *tsk,
 			 SIGPROF);
 	check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
 			 SIGVTALRM);
-	soft = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
+	soft = task_rlimit(tsk, RLIMIT_CPU);
 	if (soft != RLIM_INFINITY) {
 		unsigned long psecs = div_u64(ptime, NSEC_PER_SEC);
-		unsigned long hard =
-			READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
+		unsigned long hard = task_rlimit_max(tsk, RLIMIT_CPU);
 		u64 x;
 		if (psecs >= hard) {
 			/*

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-20  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170705172556epcas1p2ee555e8bfc7ac8b3d37efc2728456ad6@epcas1p2.samsung.com>
2017-07-05 17:25 ` [PATCH 2/4] time: posix: Use dedicated helper to access rlimit values Krzysztof Opasiak
2017-08-18 10:46   ` Thomas Gleixner
2017-08-20  9:57   ` [tip:timers/core] posix-cpu-timers: " tip-bot for Krzysztof Opasiak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.