All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sched: fix unlikely use of sched_info_on()
@ 2019-07-05  4:35 Yi Wang
  2019-07-05 11:48 ` Peter Zijlstra
  2019-07-25 16:17 ` [tip:sched/core] sched/stats: Fix unlikely() " tip-bot for Yi Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Yi Wang @ 2019-07-05  4:35 UTC (permalink / raw)
  To: mingo; +Cc: peterz, linux-kernel, xue.zhihong, wang.yi59, up2wing, wang.liang82

sched_info_on() is called with unlikely hint, however, the test
is to be a constant(1) on which compiler will do nothing when
make defconfig, so remove the hint.

Also, fix a lack of {}.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
v2: remove the hint rather than replace with likely, and fix a
coding style.

 kernel/sched/stats.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index aa0de24..ba683fe 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -157,9 +157,10 @@ static inline void sched_info_dequeued(struct rq *rq, struct task_struct *t)
 {
 	unsigned long long now = rq_clock(rq), delta = 0;
 
-	if (unlikely(sched_info_on()))
+	if (sched_info_on()) {
 		if (t->sched_info.last_queued)
 			delta = now - t->sched_info.last_queued;
+	}
 	sched_info_reset_dequeued(t);
 	t->sched_info.run_delay += delta;
 
@@ -192,7 +193,7 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t)
  */
 static inline void sched_info_queued(struct rq *rq, struct task_struct *t)
 {
-	if (unlikely(sched_info_on())) {
+	if (sched_info_on()) {
 		if (!t->sched_info.last_queued)
 			t->sched_info.last_queued = rq_clock(rq);
 	}
@@ -239,7 +240,7 @@ static inline void sched_info_depart(struct rq *rq, struct task_struct *t)
 static inline void
 sched_info_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next)
 {
-	if (unlikely(sched_info_on()))
+	if (sched_info_on())
 		__sched_info_switch(rq, prev, next);
 }
 
-- 
1.8.3.1


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

* Re: [PATCH v2] sched: fix unlikely use of sched_info_on()
  2019-07-05  4:35 [PATCH v2] sched: fix unlikely use of sched_info_on() Yi Wang
@ 2019-07-05 11:48 ` Peter Zijlstra
  2019-07-25 16:17 ` [tip:sched/core] sched/stats: Fix unlikely() " tip-bot for Yi Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2019-07-05 11:48 UTC (permalink / raw)
  To: Yi Wang; +Cc: mingo, linux-kernel, xue.zhihong, up2wing, wang.liang82

On Fri, Jul 05, 2019 at 12:35:07PM +0800, Yi Wang wrote:
> sched_info_on() is called with unlikely hint, however, the test
> is to be a constant(1) on which compiler will do nothing when
> make defconfig, so remove the hint.
> 
> Also, fix a lack of {}.
> 
> Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>

Thanks!

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

* [tip:sched/core] sched/stats: Fix unlikely() use of sched_info_on()
  2019-07-05  4:35 [PATCH v2] sched: fix unlikely use of sched_info_on() Yi Wang
  2019-07-05 11:48 ` Peter Zijlstra
@ 2019-07-25 16:17 ` tip-bot for Yi Wang
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Yi Wang @ 2019-07-25 16:17 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, peterz, tglx, hpa, wang.yi59, mingo, linux-kernel

Commit-ID:  65d74e91694e1afac40c96fb64a9ef120757729e
Gitweb:     https://git.kernel.org/tip/65d74e91694e1afac40c96fb64a9ef120757729e
Author:     Yi Wang <wang.yi59@zte.com.cn>
AuthorDate: Fri, 5 Jul 2019 12:35:07 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 25 Jul 2019 15:51:55 +0200

sched/stats: Fix unlikely() use of sched_info_on()

sched_info_on() is called with unlikely hint, however, the test
is to be a constant(1) on which compiler will do nothing when
make defconfig, so remove the hint.

Also, fix a lack of {}.

Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: up2wing@gmail.com
Cc: wang.liang82@zte.com.cn
Cc: xue.zhihong@zte.com.cn
Link: https://lkml.kernel.org/r/1562301307-43002-1-git-send-email-wang.yi59@zte.com.cn
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/stats.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index aa0de240fb41..ba683fe81a6e 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -157,9 +157,10 @@ static inline void sched_info_dequeued(struct rq *rq, struct task_struct *t)
 {
 	unsigned long long now = rq_clock(rq), delta = 0;
 
-	if (unlikely(sched_info_on()))
+	if (sched_info_on()) {
 		if (t->sched_info.last_queued)
 			delta = now - t->sched_info.last_queued;
+	}
 	sched_info_reset_dequeued(t);
 	t->sched_info.run_delay += delta;
 
@@ -192,7 +193,7 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t)
  */
 static inline void sched_info_queued(struct rq *rq, struct task_struct *t)
 {
-	if (unlikely(sched_info_on())) {
+	if (sched_info_on()) {
 		if (!t->sched_info.last_queued)
 			t->sched_info.last_queued = rq_clock(rq);
 	}
@@ -239,7 +240,7 @@ __sched_info_switch(struct rq *rq, struct task_struct *prev, struct task_struct
 static inline void
 sched_info_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next)
 {
-	if (unlikely(sched_info_on()))
+	if (sched_info_on())
 		__sched_info_switch(rq, prev, next);
 }
 

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

end of thread, other threads:[~2019-07-25 16:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05  4:35 [PATCH v2] sched: fix unlikely use of sched_info_on() Yi Wang
2019-07-05 11:48 ` Peter Zijlstra
2019-07-25 16:17 ` [tip:sched/core] sched/stats: Fix unlikely() " tip-bot for Yi Wang

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.