2023-11-04 02:45:22

by Tao Chen

[permalink] [raw]
Subject: [PATCH] bpf: Use E2BIG instead of ENOENT

Use E2BIG instead of ENOENT when the key size beyond the buckets size,
it seems more meaningful.

Signed-off-by: Tao Chen <[email protected]>
---
kernel/bpf/stackmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 458bb80b14d5..b78369bdec8d 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -570,7 +570,7 @@ int bpf_stackmap_copy(struct bpf_map *map, void *key, void *value)
u32 id = *(u32 *)key, trace_len;

if (unlikely(id >= smap->n_buckets))
- return -ENOENT;
+ return -E2BIG;

bucket = xchg(&smap->buckets[id], NULL);
if (!bucket)
--
2.34.1


2023-11-04 20:54:30

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH] bpf: Use E2BIG instead of ENOENT

On Fri, Nov 3, 2023 at 7:44 PM Tao Chen <[email protected]> wrote:
>
> Use E2BIG instead of ENOENT when the key size beyond the buckets size,
> it seems more meaningful.

seems more meaningful?
Sorry. That's hardly a reason to break someone's code.

2023-11-06 16:13:32

by Tao Chen

[permalink] [raw]
Subject: Re: [PATCH] bpf: Use E2BIG instead of ENOENT


Hi, Alexei, the delete element api of stackmap return E2BIG when the key
size beyond the buckets size, so i try to keep the same approach. Maybe
it's not necessary, anyway, thanks for your reply.

在 2023/11/6 下午11:59, Tao Chen 写道:
>
>
> ---------- Forwarded message ---------
> 发件人: *Alexei Starovoitov* <[email protected]
> <mailto:[email protected]>>
> Date: 2023年11月5日周日 04:54
> Subject: Re: [PATCH] bpf: Use E2BIG instead of ENOENT
> To: Tao Chen <[email protected] <mailto:[email protected]>>
> Cc: Song Liu <[email protected] <mailto:[email protected]>>, Jiri Olsa
> <[email protected] <mailto:[email protected]>>, Alexei Starovoitov
> <[email protected] <mailto:[email protected]>>, Daniel Borkmann
> <[email protected] <mailto:[email protected]>>, Andrii Nakryiko
> <[email protected] <mailto:[email protected]>>, Yonghong Song
> <[email protected] <mailto:[email protected]>>, Martin KaFai
> Lau <[email protected] <mailto:[email protected]>>, John Fastabend
> <[email protected] <mailto:[email protected]>>, Hao Luo
> <[email protected] <mailto:[email protected]>>, bpf <[email protected]
> <mailto:[email protected]>>, LKML <[email protected]
> <mailto:[email protected]>>
>
>
> On Fri, Nov 3, 2023 at 7:44 PM Tao Chen <[email protected]
> <mailto:[email protected]>> wrote:
> >
> > Use E2BIG instead of ENOENT when the key size beyond the buckets size,
> > it seems more meaningful.
>
> seems more meaningful?
> Sorry. That's hardly a reason to break someone's code.