mbox series

[bpf-next,v2,0/5] bpf: introduce timeout map

Message ID 20201214201118.148126-1-xiyou.wangcong@gmail.com
Headers show
Series bpf: introduce timeout map | expand

Message

Cong Wang Dec. 14, 2020, 8:11 p.m. UTC
From: Cong Wang <cong.wang@bytedance.com>

This patchset introduces a new bpf hash map which has timeout.
Patch 1 is a preparation, patch 2 is the implementation of timeout
map, patch 3 updates an existing hash map ptr test, patch 4 and
patch 5 contain two test cases for timeout map.

Please check each patch description for more details.

---
v2: fix hashmap ptr test
    add a test case in map ptr test
    factor out htab_timeout_map_alloc()

Cong Wang (5):
  bpf: use index instead of hash for map_locked[]
  bpf: introduce timeout map
  selftests/bpf: update elem_size check in map ptr test
  selftests/bpf: add a test case for bpf timeout map
  selftests/bpf: add timeout map check in map_ptr tests

 include/linux/bpf_types.h                     |   1 +
 include/uapi/linux/bpf.h                      |   3 +-
 kernel/bpf/hashtab.c                          | 301 ++++++++++++++++--
 kernel/bpf/syscall.c                          |   3 +-
 tools/include/uapi/linux/bpf.h                |   1 +
 .../selftests/bpf/progs/map_ptr_kern.c        |  22 +-
 tools/testing/selftests/bpf/test_maps.c       |  41 +++
 7 files changed, 340 insertions(+), 32 deletions(-)

Comments

Andrey Ignatov Dec. 14, 2020, 8:40 p.m. UTC | #1
Cong Wang <xiyou.wangcong@gmail.com> [Mon, 2020-12-14 12:11 -0800]:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> In map ptr test, a hard-coded 64 is used to check hash element size.
> Increase it to 72 as we increase the size of struct htab_elem. It
> seems struct htab_elem is not visible here.
> 
> Cc: Andrey Ignatov <rdna@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Dongdong Wang <wangdongdong.6@bytedance.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>

Acked-by: Andrey Ignatov <rdna@fb.com>

> ---
>  tools/testing/selftests/bpf/progs/map_ptr_kern.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> index d8850bc6a9f1..34f9880a1903 100644
> --- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> +++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> @@ -111,7 +111,7 @@ static inline int check_hash(void)
>  	VERIFY(check_default_noinline(&hash->map, map));
>  
>  	VERIFY(hash->n_buckets == MAX_ENTRIES);
> -	VERIFY(hash->elem_size == 64);
> +	VERIFY(hash->elem_size == 72);
>  
>  	VERIFY(hash->count.counter == 0);
>  	for (i = 0; i < HALF_ENTRIES; ++i) {
> -- 
> 2.25.1
>
Andrii Nakryiko Dec. 15, 2020, 7:28 p.m. UTC | #2
On Mon, Dec 14, 2020 at 12:13 PM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>

> From: Cong Wang <cong.wang@bytedance.com>

>

> This patchset introduces a new bpf hash map which has timeout.


It's a bit too short a cover letter for a pretty major new type of
hash maps. Please expand on the problem it's trying to solve, how you
tested and benchmarked it, etc.

> Patch 1 is a preparation, patch 2 is the implementation of timeout

> map, patch 3 updates an existing hash map ptr test, patch 4 and

> patch 5 contain two test cases for timeout map.

>

> Please check each patch description for more details.

>

> ---

> v2: fix hashmap ptr test

>     add a test case in map ptr test

>     factor out htab_timeout_map_alloc()

>

> Cong Wang (5):

>   bpf: use index instead of hash for map_locked[]

>   bpf: introduce timeout map

>   selftests/bpf: update elem_size check in map ptr test

>   selftests/bpf: add a test case for bpf timeout map

>   selftests/bpf: add timeout map check in map_ptr tests

>

>  include/linux/bpf_types.h                     |   1 +

>  include/uapi/linux/bpf.h                      |   3 +-

>  kernel/bpf/hashtab.c                          | 301 ++++++++++++++++--

>  kernel/bpf/syscall.c                          |   3 +-

>  tools/include/uapi/linux/bpf.h                |   1 +

>  .../selftests/bpf/progs/map_ptr_kern.c        |  22 +-

>  tools/testing/selftests/bpf/test_maps.c       |  41 +++

>  7 files changed, 340 insertions(+), 32 deletions(-)

>

> --

> 2.25.1

>
Cong Wang Dec. 15, 2020, 8:12 p.m. UTC | #3
On Tue, Dec 15, 2020 at 11:29 AM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>

> On Mon, Dec 14, 2020 at 12:13 PM Cong Wang <xiyou.wangcong@gmail.com> wrote:

> >

> > From: Cong Wang <cong.wang@bytedance.com>

> >

> > This patchset introduces a new bpf hash map which has timeout.

>

> It's a bit too short a cover letter for a pretty major new type of

> hash maps. Please expand on the problem it's trying to solve, how you

> tested and benchmarked it, etc.


I prefer to put everything in each patch description, because `git log` is easy
to find it after merging. (I know we can retain this cover letter but
it is not directly
shown in `git log kernel/bpf/hashtab.c`)

Please reply to patch 3 if you think anything is missing in its description.

Thanks!