All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: use task_current() instead of 'rq->curr == p'
@ 2020-10-30 17:32 Hui Su
  2021-01-13 22:38 ` Steven Rostedt
  2021-01-14 11:29 ` [tip: sched/core] sched: Use " tip-bot2 for Hui Su
  0 siblings, 2 replies; 4+ messages in thread
From: Hui Su @ 2020-10-30 17:32 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, linux-kernel

We have supplied the macro: 'task_current()', and we should
all use task_current() instaed of 'rq->curr == p',
which is more readable.

No functional change.

Signed-off-by: Hui Su <sh_def@163.com>
---
 kernel/sched/deadline.c | 2 +-
 kernel/sched/debug.c    | 2 +-
 kernel/sched/fair.c     | 6 +++---
 kernel/sched/rt.c       | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index f232305dcefe..3b335be97952 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2474,7 +2474,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 static void prio_changed_dl(struct rq *rq, struct task_struct *p,
 			    int oldprio)
 {
-	if (task_on_rq_queued(p) || rq->curr == p) {
+	if (task_on_rq_queued(p) || task_current(rq, p)) {
 #ifdef CONFIG_SMP
 		/*
 		 * This might be too much, but unfortunately
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 0655524700d2..1ca554f10901 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -486,7 +486,7 @@ static char *task_group_path(struct task_group *tg)
 static void
 print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 {
-	if (rq->curr == p)
+	if (task_current(rq, p))
 		SEQ_printf(m, ">R");
 	else
 		SEQ_printf(m, " %c", task_state_to_char(p));
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 290f9e38378c..c3e3ae76302e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5399,7 +5399,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
 		s64 delta = slice - ran;
 
 		if (delta < 0) {
-			if (rq->curr == p)
+			if (task_current(rq, p))
 				resched_curr(rq);
 			return;
 		}
@@ -10740,7 +10740,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
 	 * our priority decreased, or if we are not currently running on
 	 * this runqueue and our priority is higher than the current's
 	 */
-	if (rq->curr == p) {
+	if (task_current(rq, p)) {
 		if (p->prio > oldprio)
 			resched_curr(rq);
 	} else
@@ -10873,7 +10873,7 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p)
 		 * kick off the schedule if running, otherwise just see
 		 * if we can still preempt the current task.
 		 */
-		if (rq->curr == p)
+		if (task_current(rq, p))
 			resched_curr(rq);
 		else
 			check_preempt_curr(rq, p, 0);
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 49ec096a8aa1..cd615aace14c 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2317,7 +2317,7 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio)
 	if (!task_on_rq_queued(p))
 		return;
 
-	if (rq->curr == p) {
+	if (task_current(rq, p)) {
 #ifdef CONFIG_SMP
 		/*
 		 * If our priority decreases while running, we
-- 
2.29.0



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

* Re: [PATCH] sched: use task_current() instead of 'rq->curr == p'
  2020-10-30 17:32 [PATCH] sched: use task_current() instead of 'rq->curr == p' Hui Su
@ 2021-01-13 22:38 ` Steven Rostedt
  2021-01-14  9:31   ` Peter Zijlstra
  2021-01-14 11:29 ` [tip: sched/core] sched: Use " tip-bot2 for Hui Su
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2021-01-13 22:38 UTC (permalink / raw)
  To: peterz
  Cc: Hui Su, mingo, juri.lelli, vincent.guittot, dietmar.eggemann,
	bsegall, mgorman, bristot, linux-kernel


Peter,

This is a simple clean up patch that makes sense to me. Want to take it?

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve


On Sat, 31 Oct 2020 01:32:23 +0800
Hui Su <sh_def@163.com> wrote:

> We have supplied the macro: 'task_current()', and we should
> all use task_current() instaed of 'rq->curr == p',
> which is more readable.
> 
> No functional change.
> 
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
>  kernel/sched/deadline.c | 2 +-
>  kernel/sched/debug.c    | 2 +-
>  kernel/sched/fair.c     | 6 +++---
>  kernel/sched/rt.c       | 2 +-
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index f232305dcefe..3b335be97952 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2474,7 +2474,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
>  static void prio_changed_dl(struct rq *rq, struct task_struct *p,
>  			    int oldprio)
>  {
> -	if (task_on_rq_queued(p) || rq->curr == p) {
> +	if (task_on_rq_queued(p) || task_current(rq, p)) {
>  #ifdef CONFIG_SMP
>  		/*
>  		 * This might be too much, but unfortunately
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index 0655524700d2..1ca554f10901 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -486,7 +486,7 @@ static char *task_group_path(struct task_group *tg)
>  static void
>  print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
>  {
> -	if (rq->curr == p)
> +	if (task_current(rq, p))
>  		SEQ_printf(m, ">R");
>  	else
>  		SEQ_printf(m, " %c", task_state_to_char(p));
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 290f9e38378c..c3e3ae76302e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5399,7 +5399,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
>  		s64 delta = slice - ran;
>  
>  		if (delta < 0) {
> -			if (rq->curr == p)
> +			if (task_current(rq, p))
>  				resched_curr(rq);
>  			return;
>  		}
> @@ -10740,7 +10740,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
>  	 * our priority decreased, or if we are not currently running on
>  	 * this runqueue and our priority is higher than the current's
>  	 */
> -	if (rq->curr == p) {
> +	if (task_current(rq, p)) {
>  		if (p->prio > oldprio)
>  			resched_curr(rq);
>  	} else
> @@ -10873,7 +10873,7 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p)
>  		 * kick off the schedule if running, otherwise just see
>  		 * if we can still preempt the current task.
>  		 */
> -		if (rq->curr == p)
> +		if (task_current(rq, p))
>  			resched_curr(rq);
>  		else
>  			check_preempt_curr(rq, p, 0);
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 49ec096a8aa1..cd615aace14c 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2317,7 +2317,7 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio)
>  	if (!task_on_rq_queued(p))
>  		return;
>  
> -	if (rq->curr == p) {
> +	if (task_current(rq, p)) {
>  #ifdef CONFIG_SMP
>  		/*
>  		 * If our priority decreases while running, we


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

* Re: [PATCH] sched: use task_current() instead of 'rq->curr == p'
  2021-01-13 22:38 ` Steven Rostedt
@ 2021-01-14  9:31   ` Peter Zijlstra
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2021-01-14  9:31 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Hui Su, mingo, juri.lelli, vincent.guittot, dietmar.eggemann,
	bsegall, mgorman, bristot, linux-kernel

On Wed, Jan 13, 2021 at 05:38:43PM -0500, Steven Rostedt wrote:
> 
> Peter,
> 
> This is a simple clean up patch that makes sense to me. Want to take it?
> 
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Might as well I suppose.. Thanks!

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

* [tip: sched/core] sched: Use task_current() instead of 'rq->curr == p'
  2020-10-30 17:32 [PATCH] sched: use task_current() instead of 'rq->curr == p' Hui Su
  2021-01-13 22:38 ` Steven Rostedt
@ 2021-01-14 11:29 ` tip-bot2 for Hui Su
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Hui Su @ 2021-01-14 11:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Hui Su, Peter Zijlstra (Intel), Steven Rostedt (VMware), x86,
	linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     65bcf072e20ed7597caa902f170f293662b0af3c
Gitweb:        https://git.kernel.org/tip/65bcf072e20ed7597caa902f170f293662b0af3c
Author:        Hui Su <sh_def@163.com>
AuthorDate:    Sat, 31 Oct 2020 01:32:23 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 14 Jan 2021 11:20:11 +01:00

sched: Use task_current() instead of 'rq->curr == p'

Use the task_current() function where appropriate.

No functional change.

Signed-off-by: Hui Su <sh_def@163.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lkml.kernel.org/r/20201030173223.GA52339@rlk
---
 kernel/sched/deadline.c | 2 +-
 kernel/sched/debug.c    | 2 +-
 kernel/sched/fair.c     | 6 +++---
 kernel/sched/rt.c       | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 75686c6..5421782 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2514,7 +2514,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 static void prio_changed_dl(struct rq *rq, struct task_struct *p,
 			    int oldprio)
 {
-	if (task_on_rq_queued(p) || rq->curr == p) {
+	if (task_on_rq_queued(p) || task_current(rq, p)) {
 #ifdef CONFIG_SMP
 		/*
 		 * This might be too much, but unfortunately
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 2357921..486f403 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -486,7 +486,7 @@ static char *task_group_path(struct task_group *tg)
 static void
 print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
 {
-	if (rq->curr == p)
+	if (task_current(rq, p))
 		SEQ_printf(m, ">R");
 	else
 		SEQ_printf(m, " %c", task_state_to_char(p));
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 53802b7..197a514 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5430,7 +5430,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
 		s64 delta = slice - ran;
 
 		if (delta < 0) {
-			if (rq->curr == p)
+			if (task_current(rq, p))
 				resched_curr(rq);
 			return;
 		}
@@ -10829,7 +10829,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio)
 	 * our priority decreased, or if we are not currently running on
 	 * this runqueue and our priority is higher than the current's
 	 */
-	if (rq->curr == p) {
+	if (task_current(rq, p)) {
 		if (p->prio > oldprio)
 			resched_curr(rq);
 	} else
@@ -10962,7 +10962,7 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p)
 		 * kick off the schedule if running, otherwise just see
 		 * if we can still preempt the current task.
 		 */
-		if (rq->curr == p)
+		if (task_current(rq, p))
 			resched_curr(rq);
 		else
 			check_preempt_curr(rq, p, 0);
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index dbe4629..8f720b7 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2357,7 +2357,7 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio)
 	if (!task_on_rq_queued(p))
 		return;
 
-	if (rq->curr == p) {
+	if (task_current(rq, p)) {
 #ifdef CONFIG_SMP
 		/*
 		 * If our priority decreases while running, we

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

end of thread, other threads:[~2021-01-14 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 17:32 [PATCH] sched: use task_current() instead of 'rq->curr == p' Hui Su
2021-01-13 22:38 ` Steven Rostedt
2021-01-14  9:31   ` Peter Zijlstra
2021-01-14 11:29 ` [tip: sched/core] sched: Use " tip-bot2 for Hui Su

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.