* [PATCH] sched: use this_rq() helper
@ 2013-05-09 16:24 Nathan Zimmer
2013-05-10 10:40 ` Peter Zijlstra
2013-05-10 12:07 ` [tip:sched/core] sched: Use " tip-bot for Nathan Zimmer
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Zimmer @ 2013-05-09 16:24 UTC (permalink / raw)
To: linux-kernel; +Cc: Nathan Zimmer, Ingo Molnar, Peter Zijlstra
It is a few instructions more efficent to and slightly more readable to use
this_rq()-> instead of cpu_rq(smp_processor_id()->
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
---
kernel/sched/fair.c | 6 ++----
kernel/sched/rt.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c61a614..f2c9c0c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5418,10 +5418,9 @@ static inline void nohz_balance_exit_idle(int cpu)
static inline void set_cpu_sd_state_busy(void)
{
struct sched_domain *sd;
- int cpu = smp_processor_id();
rcu_read_lock();
- sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd);
+ sd = rcu_dereference_check_sched_domain(this_rq()->sd);
if (!sd || !sd->nohz_idle)
goto unlock;
@@ -5436,10 +5435,9 @@ unlock:
void set_cpu_sd_state_idle(void)
{
struct sched_domain *sd;
- int cpu = smp_processor_id();
rcu_read_lock();
- sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd);
+ sd = rcu_dereference_check_sched_domain(this_rq()->sd);
if (!sd || sd->nohz_idle)
goto unlock;
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 127a2c4..7aced2e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -472,7 +472,7 @@ static int rt_se_boosted(struct sched_rt_entity *rt_se)
#ifdef CONFIG_SMP
static inline const struct cpumask *sched_rt_period_mask(void)
{
- return cpu_rq(smp_processor_id())->rd->span;
+ return this_rq()->rd->span;
}
#else
static inline const struct cpumask *sched_rt_period_mask(void)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: use this_rq() helper
2013-05-09 16:24 [PATCH] sched: use this_rq() helper Nathan Zimmer
@ 2013-05-10 10:40 ` Peter Zijlstra
2013-05-10 12:07 ` [tip:sched/core] sched: Use " tip-bot for Nathan Zimmer
1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2013-05-10 10:40 UTC (permalink / raw)
To: Nathan Zimmer; +Cc: linux-kernel, Ingo Molnar
On Thu, May 09, 2013 at 11:24:03AM -0500, Nathan Zimmer wrote:
> It is a few instructions more efficent to and slightly more readable to use
> this_rq()-> instead of cpu_rq(smp_processor_id()->
If you've taken the trouble of actually measuring this, including the
measurement results is appreciated.
But yes, it also makes the code slightly smaller.
Thanks!
Acked-by: Peter Zijlstra <peterz@infradead.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:sched/core] sched: Use this_rq() helper
2013-05-09 16:24 [PATCH] sched: use this_rq() helper Nathan Zimmer
2013-05-10 10:40 ` Peter Zijlstra
@ 2013-05-10 12:07 ` tip-bot for Nathan Zimmer
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Nathan Zimmer @ 2013-05-10 12:07 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, nzimmer, tglx
Commit-ID: 424c93fe4cbe719e7fd7169248d2b648c493b68d
Gitweb: http://git.kernel.org/tip/424c93fe4cbe719e7fd7169248d2b648c493b68d
Author: Nathan Zimmer <nzimmer@sgi.com>
AuthorDate: Thu, 9 May 2013 11:24:03 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 10 May 2013 10:35:56 +0200
sched: Use this_rq() helper
It is a few instructions more efficent to and slightly more
readable to use this_rq()-> instead of cpu_rq(smp_processor_id())-> .
Size comparison of kernel/sched/fair.o:
text data bss dec hex filename
27972 122 26 28120 6dd8 fair.o.before
27956 122 26 28104 6dc8 fair.o.after
Signed-off-by: Nathan Zimmer <nzimmer@sgi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1368116643-87971-1-git-send-email-nzimmer@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/fair.c | 6 ++----
kernel/sched/rt.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c61a614..f2c9c0c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5418,10 +5418,9 @@ static inline void nohz_balance_exit_idle(int cpu)
static inline void set_cpu_sd_state_busy(void)
{
struct sched_domain *sd;
- int cpu = smp_processor_id();
rcu_read_lock();
- sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd);
+ sd = rcu_dereference_check_sched_domain(this_rq()->sd);
if (!sd || !sd->nohz_idle)
goto unlock;
@@ -5436,10 +5435,9 @@ unlock:
void set_cpu_sd_state_idle(void)
{
struct sched_domain *sd;
- int cpu = smp_processor_id();
rcu_read_lock();
- sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd);
+ sd = rcu_dereference_check_sched_domain(this_rq()->sd);
if (!sd || sd->nohz_idle)
goto unlock;
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 127a2c4..7aced2e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -472,7 +472,7 @@ static int rt_se_boosted(struct sched_rt_entity *rt_se)
#ifdef CONFIG_SMP
static inline const struct cpumask *sched_rt_period_mask(void)
{
- return cpu_rq(smp_processor_id())->rd->span;
+ return this_rq()->rd->span;
}
#else
static inline const struct cpumask *sched_rt_period_mask(void)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-10 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-09 16:24 [PATCH] sched: use this_rq() helper Nathan Zimmer
2013-05-10 10:40 ` Peter Zijlstra
2013-05-10 12:07 ` [tip:sched/core] sched: Use " tip-bot for Nathan Zimmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).