Subject: [cpuops inc_return V1 6/9] Taskstats: Use this_cpu_ops

Use this_cpu_inc_return in one place and avoid ugly __raw_get_cpu in another.

V3->V4:
- Fix off by one.

Cc: Michael Holzheu <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>

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

Index: linux-2.6/kernel/taskstats.c
===================================================================
--- linux-2.6.orig/kernel/taskstats.c 2010-11-30 10:06:35.000000000 -0600
+++ linux-2.6/kernel/taskstats.c 2010-11-30 10:10:14.000000000 -0600
@@ -89,8 +89,7 @@ static int prepare_reply(struct genl_inf
return -ENOMEM;

if (!info) {
- int seq = get_cpu_var(taskstats_seqnum)++;
- put_cpu_var(taskstats_seqnum);
+ int seq = this_cpu_inc_return(taskstats_seqnum) - 1;

reply = genlmsg_put(skb, 0, seq, &family, 0, cmd);
} else
@@ -581,7 +580,7 @@ void taskstats_exit(struct task_struct *
fill_tgid_exit(tsk);
}

- listeners = &__raw_get_cpu_var(listener_array);
+ listeners = __this_cpu_ptr(listener_array);
if (list_empty(&listeners->list))
return;


2010-12-07 09:35:15

by Michael Holzheu

[permalink] [raw]
Subject: Re: [cpuops inc_return V1 6/9] Taskstats: Use this_cpu_ops

Hello Christoph,

On Mon, 2010-12-06 at 11:40 -0600, Christoph Lameter wrote:
> plain text document attachment (cpuops_inc_return_taskstats)
> Use this_cpu_inc_return in one place and avoid ugly __raw_get_cpu in another.
>
> V3->V4:
> - Fix off by one.
>
> Cc: Michael Holzheu <[email protected]>
> Signed-off-by: Christoph Lameter <[email protected]>
>
> ---
> kernel/taskstats.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> Index: linux-2.6/kernel/taskstats.c
> ===================================================================
> --- linux-2.6.orig/kernel/taskstats.c 2010-11-30 10:06:35.000000000 -0600
> +++ linux-2.6/kernel/taskstats.c 2010-11-30 10:10:14.000000000 -0600
> @@ -89,8 +89,7 @@ static int prepare_reply(struct genl_inf
> return -ENOMEM;
>
> if (!info) {
> - int seq = get_cpu_var(taskstats_seqnum)++;
> - put_cpu_var(taskstats_seqnum);
> + int seq = this_cpu_inc_return(taskstats_seqnum) - 1;

This looks good now.

> reply = genlmsg_put(skb, 0, seq, &family, 0, cmd);
> } else
> @@ -581,7 +580,7 @@ void taskstats_exit(struct task_struct *
> fill_tgid_exit(tsk);
> }
>
> - listeners = &__raw_get_cpu_var(listener_array);
> + listeners = __this_cpu_ptr(listener_array);

I think this is wrong and should be:

- listeners = &__raw_get_cpu_var(listener_array);
+ listeners = __this_cpu_ptr(>>>> & <<< listener_array);

Michael

Subject: Re: [cpuops inc_return V1 6/9] Taskstats: Use this_cpu_ops


On Tue, 7 Dec 2010, Michael Holzheu wrote:

> I think this is wrong and should be:
>
> - listeners = &__raw_get_cpu_var(listener_array);
> + listeners = __this_cpu_ptr(>>>> & <<< listener_array);
>

Correct. CONFIG_TASKSTATS was not set. Thus



Subject: Taskstats: Use this_cpu_ops

Use this_cpu_inc_return in one place and avoid ugly __raw_get_cpu in another.

V3->V4:
- Fix off by one.

V4-V4f:
- Use &listener_array

Cc: Michael Holzheu <[email protected]>
Signed-off-by: Christoph Lameter <[email protected]>

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

Index: linux-2.6/kernel/taskstats.c
===================================================================
--- linux-2.6.orig/kernel/taskstats.c 2010-12-06 11:30:01.000000000 -0600
+++ linux-2.6/kernel/taskstats.c 2010-12-07 08:43:32.000000000 -0600
@@ -89,8 +89,7 @@ static int prepare_reply(struct genl_inf
return -ENOMEM;

if (!info) {
- int seq = get_cpu_var(taskstats_seqnum)++;
- put_cpu_var(taskstats_seqnum);
+ int seq = this_cpu_inc_return(taskstats_seqnum) - 1;

reply = genlmsg_put(skb, 0, seq, &family, 0, cmd);
} else
@@ -581,7 +580,7 @@ void taskstats_exit(struct task_struct *
fill_tgid_exit(tsk);
}

- listeners = &__raw_get_cpu_var(listener_array);
+ listeners = __this_cpu_ptr(&listener_array);
if (list_empty(&listeners->list))
return;