diff mbox

[v2,9/9] net: batman-adv: use per_cpu_add helper

Message ID 5093EE7E.6040400@gmail.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

solomon Nov. 2, 2012, 4:02 p.m. UTC
From: Shan Wei <davidshan@tencent.com>


As Christoph Lameter said:

> In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.
>
> cpu=get_cpu()
> ....
> *per_cpu_ptr(p,cpu)
> ....
> ....
> put_cpu()

Right.

Signed-off-by: Shan Wei <davidshan@tencent.com>
---
 net/batman-adv/main.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

Comments

Christoph Lameter (Ampere) Nov. 2, 2012, 5:48 p.m. UTC | #1
On Sat, 3 Nov 2012, Shan Wei wrote:

> diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
> index 897ba6a..3aef5b2 100644
> --- a/net/batman-adv/main.h
> +++ b/net/batman-adv/main.h
> @@ -263,9 +263,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
>  static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
>  				      size_t count)
>  {
> -	int cpu = get_cpu();
> -	per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
> -	put_cpu();
> +	this_cpu_add(bat_priv->bat_counters[idx], count);
>  }

Reviewed-by: Christoph Lameter <cl@linux.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sven Eckelmann Nov. 2, 2012, 5:55 p.m. UTC | #2
On Saturday 03 November 2012 00:02:06 Shan Wei wrote:
> From: Shan Wei <davidshan@tencent.com>
> 
> As Christoph Lameter said:
> > In addition, following usage of per_cpu_ptr can be replaced by
> > this_cpu_read.
> > 
> > cpu=get_cpu()
> > ....
> > *per_cpu_ptr(p,cpu)
> > ....
> > ....
> > put_cpu()
> 
> Right.
> 
> Signed-off-by: Shan Wei <davidshan@tencent.com>
> ---

Is this really supposed to be the commit message?

Kind regards,
	Sven
solomon Nov. 3, 2012, 4:58 a.m. UTC | #3
Sven Eckelmann said, at 2012/11/3 1:55:
> On Saturday 03 November 2012 00:02:06 Shan Wei wrote:
>> From: Shan Wei <davidshan@tencent.com>
>>
>> As Christoph Lameter said:
>>> In addition, following usage of per_cpu_ptr can be replaced by
>>> this_cpu_read.
>>>
>>> cpu=get_cpu()
>>> ....
>>> *per_cpu_ptr(p,cpu)
>>> ....
>>> ....
>>> put_cpu()
>>
>> Right.
>>
>> Signed-off-by: Shan Wei <davidshan@tencent.com>
>> ---
> 
> Is this really supposed to be the commit message?

Maybe it's ok when Linus said this. :-)

Christoph is the maintainer of per-cpu.
So........

PER-CPU MEMORY ALLOCATOR
M:      Tejun Heo <tj@kernel.org>
M:      Christoph Lameter <cl@linux-foundation.org>
T:      git git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git
S:      Maintained
F:      include/linux/percpu*.h
F:      mm/percpu*.c
F:      arch/*/include/asm/percpu.h

> 
> Kind regards,
> 	Sven
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sven Eckelmann Nov. 3, 2012, 10:39 p.m. UTC | #4
On Saturday 03 November 2012 12:58:45 Shan Wei wrote:
> Sven Eckelmann said, at 2012/11/3 1:55:
> > On Saturday 03 November 2012 00:02:06 Shan Wei wrote:
> >> From: Shan Wei <davidshan@tencent.com>
> >> 
> >> As Christoph Lameter said:
> >>> In addition, following usage of per_cpu_ptr can be replaced by
> >>> this_cpu_read.
> >>> 
> >>> cpu=get_cpu()
> >>> ....
> >>> *per_cpu_ptr(p,cpu)
> >>> ....
> >>> ....
> >>> put_cpu()
> >> 
> >> Right.
> >> 
> >> Signed-off-by: Shan Wei <davidshan@tencent.com>
> >> ---
> > 
> > Is this really supposed to be the commit message?
> 
> Maybe it's ok when Linus said this. :-)
> 
> Christoph is the maintainer of per-cpu.
> So........

Hm? This wasn't my question, but ok...

Kind regards,
	Sven
Christoph Lameter (Ampere) Nov. 5, 2012, 3:19 p.m. UTC | #5
On Sat, 3 Nov 2012, Shan Wei wrote:

> > Is this really supposed to be the commit message?
>
> Maybe it's ok when Linus said this. :-)
>
> Christoph is the maintainer of per-cpu.

Well please make the changelog nice and understandable.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 897ba6a..3aef5b2 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -263,9 +263,7 @@  static inline bool batadv_has_timed_out(unsigned long timestamp,
 static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
 				      size_t count)
 {
-	int cpu = get_cpu();
-	per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
-	put_cpu();
+	this_cpu_add(bat_priv->bat_counters[idx], count);
 }
 
 #define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)