2009-06-17 13:21:08

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH] Hiding runqueues from direct refer at source code level



Hi,

I found a trivial problem in sched.c and sched_debug.c .
There are some points which refer the per-cpu value "runqueues" directly.
sched.c provides nice abstraction, such as cpu_rq() and this_rq(),
so we should use these macros when looking runqueues.

I fixed these points and made patch.
If there is a reason to refer runqueues directly, sorry,
this patch doesn't make sense.
But I think that someday the abstraction will help someone.

one-line description: Hiding runqueues from direct refer at source code level

Signed-off-by: Hitoshi Mitake <[email protected]>

diff --git a/kernel/sched.c b/kernel/sched.c
index 8ec9d13..60dc315 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6625,7 +6625,7 @@ EXPORT_SYMBOL(yield);
*/
void __sched io_schedule(void)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = this_rq();

delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
@@ -6637,7 +6637,7 @@ EXPORT_SYMBOL(io_schedule);

long __sched io_schedule_timeout(long timeout)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = this_rq();
long ret;

delayacct_blkio_start();
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 467ca72..70c7e0b 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -162,7 +162,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
spread, rq0_min_vruntime, spread0;
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);
struct sched_entity *last;
unsigned long flags;

@@ -191,7 +191,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
if (last)
max_vruntime = last->vruntime;
min_vruntime = cfs_rq->min_vruntime;
- rq0_min_vruntime = per_cpu(runqueues, 0).cfs.min_vruntime;
+ rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
spin_unlock_irqrestore(&rq->lock, flags);
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
SPLIT_NS(MIN_vruntime));
@@ -248,7 +248,7 @@ void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)

static void print_cpu(struct seq_file *m, int cpu)
{
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);

#ifdef CONFIG_X86
{


2009-06-17 15:04:26

by Hitoshi Mitake

[permalink] [raw]
Subject: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level

Commit-ID: d11ad9b3631b942b0d2e5b754a6c62158efb799f
Gitweb: http://git.kernel.org/tip/d11ad9b3631b942b0d2e5b754a6c62158efb799f
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Wed, 17 Jun 2009 22:20:55 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Wed, 17 Jun 2009 17:02:38 +0200

sched: Hide runqueues from direct refer at source code level

There are some points which refer the per-cpu value "runqueues" directly.
sched.c provides nice abstraction, such as cpu_rq() and this_rq(),
so we should use these macros when looking runqueues.

Signed-off-by: Hitoshi Mitake <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
kernel/sched.c | 4 ++--
kernel/sched_debug.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 0056795..6240309 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6630,7 +6630,7 @@ EXPORT_SYMBOL(yield);
*/
void __sched io_schedule(void)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = this_rq();

delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
@@ -6642,7 +6642,7 @@ EXPORT_SYMBOL(io_schedule);

long __sched io_schedule_timeout(long timeout)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = this_rq();
long ret;

delayacct_blkio_start();
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 467ca72..70c7e0b 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -162,7 +162,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
spread, rq0_min_vruntime, spread0;
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);
struct sched_entity *last;
unsigned long flags;

@@ -191,7 +191,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
if (last)
max_vruntime = last->vruntime;
min_vruntime = cfs_rq->min_vruntime;
- rq0_min_vruntime = per_cpu(runqueues, 0).cfs.min_vruntime;
+ rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
spin_unlock_irqrestore(&rq->lock, flags);
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
SPLIT_NS(MIN_vruntime));
@@ -248,7 +248,7 @@ void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)

static void print_cpu(struct seq_file *m, int cpu)
{
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);

#ifdef CONFIG_X86
{

2009-06-17 16:31:44

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level


* tip-bot for Hitoshi Mitake <[email protected]> wrote:

> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -6630,7 +6630,7 @@ EXPORT_SYMBOL(yield);
> */
> void __sched io_schedule(void)
> {
> - struct rq *rq = &__raw_get_cpu_var(runqueues);
> + struct rq *rq = this_rq();
>
> delayacct_blkio_start();
> atomic_inc(&rq->nr_iowait);
> @@ -6642,7 +6642,7 @@ EXPORT_SYMBOL(io_schedule);
>
> long __sched io_schedule_timeout(long timeout)
> {
> - struct rq *rq = &__raw_get_cpu_var(runqueues);
> + struct rq *rq = this_rq();
> long ret;

I removed these two changes. Did you notice the __raw prefix?

Ingo

2009-06-17 16:34:18

by Hitoshi Mitake

[permalink] [raw]
Subject: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level

Commit-ID: 348ec61e6268c3cd7ee75cfa50e408184a941506
Gitweb: http://git.kernel.org/tip/348ec61e6268c3cd7ee75cfa50e408184a941506
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Wed, 17 Jun 2009 22:20:55 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Wed, 17 Jun 2009 18:29:42 +0200

sched: Hide runqueues from direct refer at source code level

There are some points which refer the per-cpu value "runqueues" directly.
sched.c provides nice abstraction, such as cpu_rq() and this_rq(),
so we should use these macros when looking runqueues.

Signed-off-by: Hitoshi Mitake <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
kernel/sched_debug.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 467ca72..70c7e0b 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -162,7 +162,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
{
s64 MIN_vruntime = -1, min_vruntime, max_vruntime = -1,
spread, rq0_min_vruntime, spread0;
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);
struct sched_entity *last;
unsigned long flags;

@@ -191,7 +191,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
if (last)
max_vruntime = last->vruntime;
min_vruntime = cfs_rq->min_vruntime;
- rq0_min_vruntime = per_cpu(runqueues, 0).cfs.min_vruntime;
+ rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
spin_unlock_irqrestore(&rq->lock, flags);
SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "MIN_vruntime",
SPLIT_NS(MIN_vruntime));
@@ -248,7 +248,7 @@ void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)

static void print_cpu(struct seq_file *m, int cpu)
{
- struct rq *rq = &per_cpu(runqueues, cpu);
+ struct rq *rq = cpu_rq(cpu);

#ifdef CONFIG_X86
{

2009-06-18 10:14:58

by Hitoshi Mitake

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level

From: Ingo Molnar <[email protected]>
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
Date: Wed, 17 Jun 2009 18:31:11 +0200

> ition: inline
> Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> From: Ingo Molnar <[email protected]>
> To: [email protected], [email protected], [email protected],
> [email protected], [email protected]
> Cc: [email protected]
> Date: Wed, 17 Jun 2009 18:31:11 +0200
> User-Agent: Mutt/1.5.18 (2008-05-17)
> Received-SPF: neutral (mx2.mail.elte.hu: 157.181.1.14 is neither permitted nor denied by domain of elte.hu) client-ip=157.181.1.14; [email protected]; helo=elvis.elte.hu;
> X-Mew: tab/spc characters on Subject: are simplified.
>
>
> * tip-bot for Hitoshi Mitake <[email protected]> wrote:
>
> > --- a/kernel/sched.c
> > +++ b/kernel/sched.c
> > @@ -6630,7 +6630,7 @@ EXPORT_SYMBOL(yield);
> > */
> > void __sched io_schedule(void)
> > {
> > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > + struct rq *rq = this_rq();
> >
> > delayacct_blkio_start();
> > atomic_inc(&rq->nr_iowait);
> > @@ -6642,7 +6642,7 @@ EXPORT_SYMBOL(io_schedule);
> >
> > long __sched io_schedule_timeout(long timeout)
> > {
> > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > + struct rq *rq = this_rq();
> > long ret;
>
> I removed these two changes. Did you notice the __raw prefix?
>
> Ingo
>

Thanks for your fix, I didn't notice...
I wrote a patch to fix these two points.

After applying this patch,
all direct reference to runqueues is in macros. How is this?

Signed-off-by: Hitoshi Mitake <[email protected]>

diff --git a/kernel/sched.c b/kernel/sched.c
index 8ec9d13..e2ca8c1 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
#define this_rq() (&__get_cpu_var(runqueues))
#define task_rq(p) cpu_rq(task_cpu(p))
#define cpu_curr(cpu) (cpu_rq(cpu)->curr)
+#define raw_rq() (&__raw_get_cpu_var(runqueues))

inline void update_rq_clock(struct rq *rq)
{
@@ -6625,7 +6626,7 @@ EXPORT_SYMBOL(yield);
*/
void __sched io_schedule(void)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();

delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
@@ -6637,7 +6638,7 @@ EXPORT_SYMBOL(io_schedule);

long __sched io_schedule_timeout(long timeout)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();
long ret;

delayacct_blkio_start();

2009-06-22 15:35:41

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level


* Hitoshi Mitake <[email protected]> wrote:

> From: Ingo Molnar <[email protected]>
> Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> Date: Wed, 17 Jun 2009 18:31:11 +0200
>
> > ition: inline
> > Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> > From: Ingo Molnar <[email protected]>
> > To: [email protected], [email protected], [email protected],
> > [email protected], [email protected]
> > Cc: [email protected]
> > Date: Wed, 17 Jun 2009 18:31:11 +0200
> > User-Agent: Mutt/1.5.18 (2008-05-17)
> > Received-SPF: neutral (mx2.mail.elte.hu: 157.181.1.14 is neither permitted nor denied by domain of elte.hu) client-ip=157.181.1.14; [email protected]; helo=elvis.elte.hu;
> > X-Mew: tab/spc characters on Subject: are simplified.
> >
> >
> > * tip-bot for Hitoshi Mitake <[email protected]> wrote:
> >
> > > --- a/kernel/sched.c
> > > +++ b/kernel/sched.c
> > > @@ -6630,7 +6630,7 @@ EXPORT_SYMBOL(yield);
> > > */
> > > void __sched io_schedule(void)
> > > {
> > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > + struct rq *rq = this_rq();
> > >
> > > delayacct_blkio_start();
> > > atomic_inc(&rq->nr_iowait);
> > > @@ -6642,7 +6642,7 @@ EXPORT_SYMBOL(io_schedule);
> > >
> > > long __sched io_schedule_timeout(long timeout)
> > > {
> > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > + struct rq *rq = this_rq();
> > > long ret;
> >
> > I removed these two changes. Did you notice the __raw prefix?
> >
> > Ingo
> >
>
> Thanks for your fix, I didn't notice...
> I wrote a patch to fix these two points.
>
> After applying this patch,
> all direct reference to runqueues is in macros. How is this?
>
> Signed-off-by: Hitoshi Mitake <[email protected]>
>
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 8ec9d13..e2ca8c1 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
> #define this_rq() (&__get_cpu_var(runqueues))
> #define task_rq(p) cpu_rq(task_cpu(p))
> #define cpu_curr(cpu) (cpu_rq(cpu)->curr)
> +#define raw_rq() (&__raw_get_cpu_var(runqueues))
>
> inline void update_rq_clock(struct rq *rq)
> {
> @@ -6625,7 +6626,7 @@ EXPORT_SYMBOL(yield);
> */
> void __sched io_schedule(void)
> {
> - struct rq *rq = &__raw_get_cpu_var(runqueues);
> + struct rq *rq = raw_rq();
>
> delayacct_blkio_start();
> atomic_inc(&rq->nr_iowait);
> @@ -6637,7 +6638,7 @@ EXPORT_SYMBOL(io_schedule);
>
> long __sched io_schedule_timeout(long timeout)
> {
> - struct rq *rq = &__raw_get_cpu_var(runqueues);
> + struct rq *rq = raw_rq();
> long ret;
>
> delayacct_blkio_start();

Looks good - mind submitting a separate patch with a changelog, etc?

Ingo

2009-06-23 04:29:34

by Hitoshi Mitake

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level

From: Ingo Molnar <[email protected]>
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
Date: Mon, 22 Jun 2009 17:35:22 +0200

> >
> > Thanks for your fix, I didn't notice...
> > I wrote a patch to fix these two points.
> >
> > After applying this patch,
> > all direct reference to runqueues is in macros. How is this?
> >
> > Signed-off-by: Hitoshi Mitake <[email protected]>
> >
> > diff --git a/kernel/sched.c b/kernel/sched.c
> > index 8ec9d13..e2ca8c1 100644
> > --- a/kernel/sched.c
> > +++ b/kernel/sched.c
> > @@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
> > #define this_rq() (&__get_cpu_var(runqueues))
> > #define task_rq(p) cpu_rq(task_cpu(p))
> > #define cpu_curr(cpu) (cpu_rq(cpu)->curr)
> > +#define raw_rq() (&__raw_get_cpu_var(runqueues))
> >
> > inline void update_rq_clock(struct rq *rq)
> > {
> > @@ -6625,7 +6626,7 @@ EXPORT_SYMBOL(yield);
> > */
> > void __sched io_schedule(void)
> > {
> > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > + struct rq *rq = raw_rq();
> >
> > delayacct_blkio_start();
> > atomic_inc(&rq->nr_iowait);
> > @@ -6637,7 +6638,7 @@ EXPORT_SYMBOL(io_schedule);
> >
> > long __sched io_schedule_timeout(long timeout)
> > {
> > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > + struct rq *rq = raw_rq();
> > long ret;
> >
> > delayacct_blkio_start();
>
> Looks good - mind submitting a separate patch with a changelog, etc?
>
> Ingo
>

No, I have no fix to post now. Thanks.

2009-06-29 03:59:27

by Hitoshi Mitake

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level

From: Hitoshi Mitake <[email protected]>
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
Date: Tue, 23 Jun 2009 13:29:20 +0900 (JST)

> From: Ingo Molnar <[email protected]>
> Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> Date: Mon, 22 Jun 2009 17:35:22 +0200
>
> > >
> > > Thanks for your fix, I didn't notice...
> > > I wrote a patch to fix these two points.
> > >
> > > After applying this patch,
> > > all direct reference to runqueues is in macros. How is this?
> > >
> > > Signed-off-by: Hitoshi Mitake <[email protected]>
> > >
> > > diff --git a/kernel/sched.c b/kernel/sched.c
> > > index 8ec9d13..e2ca8c1 100644
> > > --- a/kernel/sched.c
> > > +++ b/kernel/sched.c
> > > @@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
> > > #define this_rq() (&__get_cpu_var(runqueues))
> > > #define task_rq(p) cpu_rq(task_cpu(p))
> > > #define cpu_curr(cpu) (cpu_rq(cpu)->curr)
> > > +#define raw_rq() (&__raw_get_cpu_var(runqueues))
> > >
> > > inline void update_rq_clock(struct rq *rq)
> > > {
> > > @@ -6625,7 +6626,7 @@ EXPORT_SYMBOL(yield);
> > > */
> > > void __sched io_schedule(void)
> > > {
> > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > + struct rq *rq = raw_rq();
> > >
> > > delayacct_blkio_start();
> > > atomic_inc(&rq->nr_iowait);
> > > @@ -6637,7 +6638,7 @@ EXPORT_SYMBOL(io_schedule);
> > >
> > > long __sched io_schedule_timeout(long timeout)
> > > {
> > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > + struct rq *rq = raw_rq();
> > > long ret;
> > >
> > > delayacct_blkio_start();
> >
> > Looks good - mind submitting a separate patch with a changelog, etc?
> >
> > Ingo
> >
>
> No, I have no fix to post now. Thanks.
>

I felt that I misunderstood what you said.
Are you requiring me a content for changelog?
Sorry for my poor English skill...

2009-06-29 04:11:24

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level


* Hitoshi Mitake <[email protected]> wrote:

> From: Hitoshi Mitake <[email protected]>
> Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> Date: Tue, 23 Jun 2009 13:29:20 +0900 (JST)
>
> > From: Ingo Molnar <[email protected]>
> > Subject: Re: [tip:sched/urgent] sched: Hide runqueues from direct refer at source code level
> > Date: Mon, 22 Jun 2009 17:35:22 +0200
> >
> > > >
> > > > Thanks for your fix, I didn't notice...
> > > > I wrote a patch to fix these two points.
> > > >
> > > > After applying this patch,
> > > > all direct reference to runqueues is in macros. How is this?
> > > >
> > > > Signed-off-by: Hitoshi Mitake <[email protected]>
> > > >
> > > > diff --git a/kernel/sched.c b/kernel/sched.c
> > > > index 8ec9d13..e2ca8c1 100644
> > > > --- a/kernel/sched.c
> > > > +++ b/kernel/sched.c
> > > > @@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
> > > > #define this_rq() (&__get_cpu_var(runqueues))
> > > > #define task_rq(p) cpu_rq(task_cpu(p))
> > > > #define cpu_curr(cpu) (cpu_rq(cpu)->curr)
> > > > +#define raw_rq() (&__raw_get_cpu_var(runqueues))
> > > >
> > > > inline void update_rq_clock(struct rq *rq)
> > > > {
> > > > @@ -6625,7 +6626,7 @@ EXPORT_SYMBOL(yield);
> > > > */
> > > > void __sched io_schedule(void)
> > > > {
> > > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > > + struct rq *rq = raw_rq();
> > > >
> > > > delayacct_blkio_start();
> > > > atomic_inc(&rq->nr_iowait);
> > > > @@ -6637,7 +6638,7 @@ EXPORT_SYMBOL(io_schedule);
> > > >
> > > > long __sched io_schedule_timeout(long timeout)
> > > > {
> > > > - struct rq *rq = &__raw_get_cpu_var(runqueues);
> > > > + struct rq *rq = raw_rq();
> > > > long ret;
> > > >
> > > > delayacct_blkio_start();
> > >
> > > Looks good - mind submitting a separate patch with a changelog, etc?
> > >
> > > Ingo
> > >
> >
> > No, I have no fix to post now. Thanks.
> >
>
> I felt that I misunderstood what you said.
> Are you requiring me a content for changelog?

Yes, please send a full patch with a new subject line and a
changelog - as your previous patch has already been applied.

Ingo

2009-06-29 05:45:21

by Hitoshi Mitake

[permalink] [raw]
Subject: [PATCH] sched: Hide runqueues from direct refer at source code level for __raw_get_cpu_var()


description:

My previous patch (Commit-ID of tip tree d11ad9b3631b942b0d2e5b754a6c62158efb799f) hides
direct refers at source code level into macros.
This will hide the rest part, __raw_get_cpu_var().
After appling this, all of the direct refer to runqueues will be in macros in the close place.

Signed-off-by: Hitoshi Mitake <[email protected]>

diff --git a/kernel/sched.c b/kernel/sched.c
index 7c9098d..d1d3599 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
#define this_rq() (&__get_cpu_var(runqueues))
#define task_rq(p) cpu_rq(task_cpu(p))
#define cpu_curr(cpu) (cpu_rq(cpu)->curr)
+#define raw_rq() (&__raw_get_cpu_var(runqueues))

inline void update_rq_clock(struct rq *rq)
{
@@ -6631,7 +6632,7 @@ EXPORT_SYMBOL(yield);
*/
void __sched io_schedule(void)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();

delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
@@ -6643,7 +6644,7 @@ EXPORT_SYMBOL(io_schedule);

long __sched io_schedule_timeout(long timeout)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();
long ret;

delayacct_blkio_start();

2009-06-29 07:25:37

by Hitoshi Mitake

[permalink] [raw]
Subject: [tip:sched/core] sched: Hide runqueues from direct reference at source code level for __raw_get_cpu_var()

Commit-ID: 54d35f29f49224d86b994acb6e5969b9ba09022d
Gitweb: http://git.kernel.org/tip/54d35f29f49224d86b994acb6e5969b9ba09022d
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Mon, 29 Jun 2009 14:44:57 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 29 Jun 2009 09:19:27 +0200

sched: Hide runqueues from direct reference at source code level for __raw_get_cpu_var()

Hide __raw_get_cpu_var() as well - thus all the direct
references to runqueues will abstracted out.

Signed-off-by: Hitoshi Mitake <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>


---
kernel/sched.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 168b268..ebc5151 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -692,6 +692,7 @@ static inline int cpu_of(struct rq *rq)
#define this_rq() (&__get_cpu_var(runqueues))
#define task_rq(p) cpu_rq(task_cpu(p))
#define cpu_curr(cpu) (cpu_rq(cpu)->curr)
+#define raw_rq() (&__raw_get_cpu_var(runqueues))

inline void update_rq_clock(struct rq *rq)
{
@@ -6669,7 +6670,7 @@ EXPORT_SYMBOL(yield);
*/
void __sched io_schedule(void)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();

delayacct_blkio_start();
atomic_inc(&rq->nr_iowait);
@@ -6681,7 +6682,7 @@ EXPORT_SYMBOL(io_schedule);

long __sched io_schedule_timeout(long timeout)
{
- struct rq *rq = &__raw_get_cpu_var(runqueues);
+ struct rq *rq = raw_rq();
long ret;

delayacct_blkio_start();