linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/4] Add BPF htab map's used size for monitoring
@ 2022-11-05  2:51 Ho-Ren (Jack) Chuang
  2022-11-05  2:51 ` [PATCH bpf-next v1 1/4] bpf: Support reporting " Ho-Ren (Jack) Chuang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Ho-Ren (Jack) Chuang @ 2022-11-05  2:51 UTC (permalink / raw)
  To: Alexei Starovoitov, Alexei Starovoitov, Hao Luo, Jiri Olsa,
	Jiri Olsa, Andrii Nakryiko, Daniel Borkmann, John Fastabend,
	Martin KaFai Lau, Song Liu, Yonghong Song, KP Singh,
	Stanislav Fomichev, Quentin Monnet, Mykola Lysenko, Shuah Khan,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Joanne Koong,
	Kui-Feng Lee, Lorenzo Bianconi, Maxim Mikityanskiy, Hao Xiang,
	Punit Agrawal, Yifei Ma, Xiaoning Ding, bpf
  Cc: Ho-Ren Chuang, Ho-Ren Chuang, linux-kernel, linux-kselftest, llvm

Hello everyone,

We have prepared patches to address an issue from a previous discussion.
The previous discussion email thread is here: https://lore.kernel.org/all/CAADnVQLBt0snxv4bKwg1WKQ9wDFbaDCtZ03v1-LjOTYtsKPckQ@mail.gmail.com/

This patch series adds a new field "used_entries" to struct bpf_map_info
and keeps tracking the "count" field in bpf_htab in both the preallocated
and non-preallocated cases.

bpftool is modified to report the newly added "used_entries" field in
struct bpf_map_info and to mark pre-allocated htab maps with "*".
These make it easier to view the current memory situation of a hashmap.

We have added a new interface function map_get_used_elem in bpf_map_ops
to provide an abstraction layer so that other map type implementations can
support the "used_entries" attribute in a future change.

A concurrency testing for pre-allocated and dynamically allocated
htab maps is introduced to test the correctness and performance of
htab map's used size.

Existing unit tests are integrated to test the correctness of
htab map's used size.

Thank you,

Ho-Ren (Jack) Chuang (4):
  bpf: Support reporting BPF htab map's used size for monitoring
  bpftool: Add tools support to show BPF htab map's used size
  samples/bpf: Add concurrency testing for BPF htab map's used size
  selftests/bpf: Add unit tests for BPF htab map's used size

 include/linux/bpf.h                     |   1 +
 include/uapi/linux/bpf.h                |   1 +
 kernel/bpf/hashtab.c                    |  19 +++
 kernel/bpf/syscall.c                    |   2 +
 samples/bpf/Makefile                    |   4 +
 samples/bpf/test_map_used_kern.c        |  65 ++++++++
 samples/bpf/test_map_used_user.c        | 204 ++++++++++++++++++++++++
 tools/bpf/bpftool/map.c                 |   9 +-
 tools/include/uapi/linux/bpf.h          |   1 +
 tools/testing/selftests/bpf/test_maps.c |  74 ++++++++-
 10 files changed, 377 insertions(+), 3 deletions(-)
 create mode 100644 samples/bpf/test_map_used_kern.c
 create mode 100644 samples/bpf/test_map_used_user.c

-- 
Ho-Ren (Jack) Chuang


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

end of thread, other threads:[~2022-11-28 23:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05  2:51 [PATCH bpf-next v1 0/4] Add BPF htab map's used size for monitoring Ho-Ren (Jack) Chuang
2022-11-05  2:51 ` [PATCH bpf-next v1 1/4] bpf: Support reporting " Ho-Ren (Jack) Chuang
2022-11-05  2:51 ` [PATCH bpf-next v1 2/4] bpftool: Add tools support to show BPF htab map's used size Ho-Ren (Jack) Chuang
2022-11-05  2:51 ` [PATCH bpf-next v1 3/4] samples/bpf: Add concurrency testing for " Ho-Ren (Jack) Chuang
2022-11-05  2:51 ` [PATCH bpf-next v1 4/4] selftests/bpf: Add unit tests " Ho-Ren (Jack) Chuang
2022-11-05 16:20 ` [PATCH bpf-next v1 0/4] Add BPF htab map's used size for monitoring Alexei Starovoitov
2022-11-08  0:30   ` [External] " Hao Xiang .
2022-11-28 23:03     ` Hao Xiang .

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).