All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt
@ 2018-04-28  7:32 Teng Qin
  2018-04-28 15:03 ` Alexei Starovoitov
  2018-04-29  6:39 ` [PATCH bpf-next v2] " Teng Qin
  0 siblings, 2 replies; 4+ messages in thread
From: Teng Qin @ 2018-04-28  7:32 UTC (permalink / raw)
  To: netdev; +Cc: ast, daniel, yhs, kernel-team, Teng Qin

Currently, the bpf_current_task_under_cgroup helper has a check where if
the BPF program is running in_interrupt(), it will return -EINVAL. This
prevents the helper to be used in many useful scenarios, particularly
BPF programs attached to Perf Events.

This commit removes the check. Tested a few NMI (Perf Event) and some
softirq context, the helper returns the correct result.
---
 kernel/trace/bpf_trace.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 56ba0f2..f94890c 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -474,8 +474,6 @@ BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx)
 	struct bpf_array *array = container_of(map, struct bpf_array, map);
 	struct cgroup *cgrp;
 
-	if (unlikely(in_interrupt()))
-		return -EINVAL;
 	if (unlikely(idx >= array->map.max_entries))
 		return -E2BIG;
 
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt
  2018-04-28  7:32 [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt Teng Qin
@ 2018-04-28 15:03 ` Alexei Starovoitov
  2018-04-29  6:39 ` [PATCH bpf-next v2] " Teng Qin
  1 sibling, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2018-04-28 15:03 UTC (permalink / raw)
  To: Teng Qin, netdev; +Cc: ast, daniel, yhs, kernel-team

On 4/28/18 12:32 AM, Teng Qin wrote:
> Currently, the bpf_current_task_under_cgroup helper has a check where if
> the BPF program is running in_interrupt(), it will return -EINVAL. This
> prevents the helper to be used in many useful scenarios, particularly
> BPF programs attached to Perf Events.
>
> This commit removes the check. Tested a few NMI (Perf Event) and some
> softirq context, the helper returns the correct result.
> ---
>  kernel/trace/bpf_trace.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 56ba0f2..f94890c 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -474,8 +474,6 @@ BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx)
>  	struct bpf_array *array = container_of(map, struct bpf_array, map);
>  	struct cgroup *cgrp;
>
> -	if (unlikely(in_interrupt()))
> -		return -EINVAL;
>  	if (unlikely(idx >= array->map.max_entries))
>  		return -E2BIG;
>

looks good, but SOB is missing. Please respin.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH bpf-next v2] bpf: Allow bpf_current_task_under_cgroup in interrupt
  2018-04-28  7:32 [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt Teng Qin
  2018-04-28 15:03 ` Alexei Starovoitov
@ 2018-04-29  6:39 ` Teng Qin
  2018-04-29 16:20   ` Alexei Starovoitov
  1 sibling, 1 reply; 4+ messages in thread
From: Teng Qin @ 2018-04-29  6:39 UTC (permalink / raw)
  To: netdev; +Cc: ast, daniel, yhs, kernel-team, Teng Qin

Currently, the bpf_current_task_under_cgroup helper has a check where if
the BPF program is running in_interrupt(), it will return -EINVAL. This
prevents the helper to be used in many useful scenarios, particularly
BPF programs attached to Perf Events.

This commit removes the check. Tested a few NMI (Perf Event) and some
softirq context, the helper returns the correct result.

Signed-off-by: Teng Qin <qinteng@fb.com>
---
 kernel/trace/bpf_trace.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 56ba0f2..f94890c 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -474,8 +474,6 @@ BPF_CALL_2(bpf_current_task_under_cgroup, struct bpf_map *, map, u32, idx)
 	struct bpf_array *array = container_of(map, struct bpf_array, map);
 	struct cgroup *cgrp;
 
-	if (unlikely(in_interrupt()))
-		return -EINVAL;
 	if (unlikely(idx >= array->map.max_entries))
 		return -E2BIG;
 
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v2] bpf: Allow bpf_current_task_under_cgroup in interrupt
  2018-04-29  6:39 ` [PATCH bpf-next v2] " Teng Qin
@ 2018-04-29 16:20   ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2018-04-29 16:20 UTC (permalink / raw)
  To: Teng Qin; +Cc: netdev, ast, daniel, yhs, kernel-team

On Sat, Apr 28, 2018 at 11:39:29PM -0700, Teng Qin wrote:
> Currently, the bpf_current_task_under_cgroup helper has a check where if
> the BPF program is running in_interrupt(), it will return -EINVAL. This
> prevents the helper to be used in many useful scenarios, particularly
> BPF programs attached to Perf Events.
> 
> This commit removes the check. Tested a few NMI (Perf Event) and some
> softirq context, the helper returns the correct result.
> 
> Signed-off-by: Teng Qin <qinteng@fb.com>

Applied, Thanks Teng.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-29 16:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-28  7:32 [PATCH bpf-next] bpf: Allow bpf_current_task_under_cgroup in interrupt Teng Qin
2018-04-28 15:03 ` Alexei Starovoitov
2018-04-29  6:39 ` [PATCH bpf-next v2] " Teng Qin
2018-04-29 16:20   ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.