* [PATCH trival 1/2] bpf: clean up put_cpu_var usage
@ 2016-09-26 18:14 Shaohua Li
2016-09-26 18:14 ` [PATCH trival 2/2] lib: " Shaohua Li
2016-09-26 23:51 ` [PATCH trival 1/2] bpf: " Alexei Starovoitov
0 siblings, 2 replies; 4+ messages in thread
From: Shaohua Li @ 2016-09-26 18:14 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, Tejun Heo, Alexei Starovoitov
put_cpu_var takes the percpu data, not the data returned from
get_cpu_var.
This doesn't change the behavior.
Cc: Tejun Heo <tj@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Shaohua Li <shli@fb.com>
---
kernel/bpf/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 03fd23d..b73913b 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1031,7 +1031,7 @@ u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
state = &get_cpu_var(bpf_user_rnd_state);
res = prandom_u32_state(state);
- put_cpu_var(state);
+ put_cpu_var(bpf_user_rnd_state);
return res;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH trival 2/2] lib: clean up put_cpu_var usage
2016-09-26 18:14 [PATCH trival 1/2] bpf: clean up put_cpu_var usage Shaohua Li
@ 2016-09-26 18:14 ` Shaohua Li
2016-09-26 23:51 ` [PATCH trival 1/2] bpf: " Alexei Starovoitov
1 sibling, 0 replies; 4+ messages in thread
From: Shaohua Li @ 2016-09-26 18:14 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, Tejun Heo
put_cpu_var takes the percpu data, not the data returned from
get_cpu_var.
This doesn't change the behavior.
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Shaohua Li <shli@fb.com>
---
lib/random32.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/random32.c b/lib/random32.c
index 69ed593..915982b 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -81,7 +81,7 @@ u32 prandom_u32(void)
u32 res;
res = prandom_u32_state(state);
- put_cpu_var(state);
+ put_cpu_var(net_rand_state);
return res;
}
@@ -128,7 +128,7 @@ void prandom_bytes(void *buf, size_t bytes)
struct rnd_state *state = &get_cpu_var(net_rand_state);
prandom_bytes_state(state, buf, bytes);
- put_cpu_var(state);
+ put_cpu_var(net_rand_state);
}
EXPORT_SYMBOL(prandom_bytes);
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH trival 1/2] bpf: clean up put_cpu_var usage
2016-09-26 18:14 [PATCH trival 1/2] bpf: clean up put_cpu_var usage Shaohua Li
2016-09-26 18:14 ` [PATCH trival 2/2] lib: " Shaohua Li
@ 2016-09-26 23:51 ` Alexei Starovoitov
2016-09-27 10:52 ` Daniel Borkmann
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2016-09-26 23:51 UTC (permalink / raw)
To: Shaohua Li
Cc: linux-kernel, akpm, Tejun Heo, Alexei Starovoitov,
Daniel Borkmann
On Mon, Sep 26, 2016 at 11:14:50AM -0700, Shaohua Li wrote:
> put_cpu_var takes the percpu data, not the data returned from
> get_cpu_var.
>
> This doesn't change the behavior.
>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Shaohua Li <shli@fb.com>
Looks good. Nice catch.
Please rebase to net-next tree and send it to netdev list.
Otherwise we'll have conflicts at the time of the merge window.
> ---
> kernel/bpf/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 03fd23d..b73913b 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -1031,7 +1031,7 @@ u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
>
> state = &get_cpu_var(bpf_user_rnd_state);
> res = prandom_u32_state(state);
> - put_cpu_var(state);
> + put_cpu_var(bpf_user_rnd_state);
>
> return res;
> }
> --
> 2.9.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH trival 1/2] bpf: clean up put_cpu_var usage
2016-09-26 23:51 ` [PATCH trival 1/2] bpf: " Alexei Starovoitov
@ 2016-09-27 10:52 ` Daniel Borkmann
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2016-09-27 10:52 UTC (permalink / raw)
To: Alexei Starovoitov, Shaohua Li
Cc: linux-kernel, akpm, Tejun Heo, Alexei Starovoitov
Shaohua,
On 09/27/2016 01:51 AM, Alexei Starovoitov wrote:
> On Mon, Sep 26, 2016 at 11:14:50AM -0700, Shaohua Li wrote:
>> put_cpu_var takes the percpu data, not the data returned from
>> get_cpu_var.
>>
>> This doesn't change the behavior.
>>
>> Cc: Tejun Heo <tj@kernel.org>
>> Cc: Alexei Starovoitov <ast@kernel.org>
>> Signed-off-by: Shaohua Li <shli@fb.com>
>
> Looks good. Nice catch.
> Please rebase to net-next tree and send it to netdev list.
+1
> Otherwise we'll have conflicts at the time of the merge window.
While you're at it, the same kind of cleanup can be done for
prandom_u32() and prandom_bytes(), so you could either squash
that into this patch as well or make it two patches. Both for
netdev.
Thanks,
Daniel
>> ---
>> kernel/bpf/core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
>> index 03fd23d..b73913b 100644
>> --- a/kernel/bpf/core.c
>> +++ b/kernel/bpf/core.c
>> @@ -1031,7 +1031,7 @@ u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
>>
>> state = &get_cpu_var(bpf_user_rnd_state);
>> res = prandom_u32_state(state);
>> - put_cpu_var(state);
>> + put_cpu_var(bpf_user_rnd_state);
>>
>> return res;
>> }
>> --
>> 2.9.3
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-27 10:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-26 18:14 [PATCH trival 1/2] bpf: clean up put_cpu_var usage Shaohua Li
2016-09-26 18:14 ` [PATCH trival 2/2] lib: " Shaohua Li
2016-09-26 23:51 ` [PATCH trival 1/2] bpf: " Alexei Starovoitov
2016-09-27 10:52 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox