BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] expose number of map entries to userspace
@ 2025-01-06 14:53 Charalampos Stylianopoulos
  2025-01-06 14:53 ` [PATCH bpf-next 1/4] bpf: Add map_num_entries map op Charalampos Stylianopoulos
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Charalampos Stylianopoulos @ 2025-01-06 14:53 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Nick Zavaritsky,
	Charalampos Stylianopoulos

This patch series provides an easy way for userspace applications to
query the number of entries currently present in a map.

Currently, the number of entries in a map is accessible only from kernel space
and eBPF programs. A userspace program that wants to track map utilization has to
create and attach an eBPF program solely for that purpose.

This series makes the number of entries in a map easily accessible, by extending the
main bpf syscall with a new command. The command supports only maps that already
track utilization, namely hash maps, LPM maps and queue/stack maps.

Charalampos Stylianopoulos (4):
  bpf: Add map_num_entries map op
  bpf: Add bpf command to get number of map entries
  libbpf: Add support for MAP_GET_NUM_ENTRIES command
  selftests/bpf: Add tests for bpf_map_get_num_entries

 include/linux/bpf.h                           |  3 ++
 include/linux/bpf_local_storage.h             |  1 +
 include/uapi/linux/bpf.h                      | 17 +++++++++
 kernel/bpf/devmap.c                           | 14 ++++++++
 kernel/bpf/hashtab.c                          | 10 ++++++
 kernel/bpf/lpm_trie.c                         |  8 +++++
 kernel/bpf/queue_stack_maps.c                 | 11 +++++-
 kernel/bpf/syscall.c                          | 32 +++++++++++++++++
 tools/include/uapi/linux/bpf.h                | 17 +++++++++
 tools/lib/bpf/bpf.c                           | 16 +++++++++
 tools/lib/bpf/bpf.h                           |  2 ++
 tools/lib/bpf/libbpf.map                      |  1 +
 .../bpf/map_tests/lpm_trie_map_basic_ops.c    |  5 +++
 tools/testing/selftests/bpf/test_maps.c       | 35 +++++++++++++++++++
 14 files changed, 171 insertions(+), 1 deletion(-)

-- 
2.43.0


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

end of thread, other threads:[~2025-01-17 10:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-06 14:53 [PATCH bpf-next 0/4] expose number of map entries to userspace Charalampos Stylianopoulos
2025-01-06 14:53 ` [PATCH bpf-next 1/4] bpf: Add map_num_entries map op Charalampos Stylianopoulos
2025-01-06 14:53 ` [PATCH bpf-next 2/4] bpf: Add bpf command to get number of map entries Charalampos Stylianopoulos
2025-01-07 17:52   ` kernel test robot
2025-01-06 14:53 ` [PATCH bpf-next 3/4] libbpf: Add support for MAP_GET_NUM_ENTRIES command Charalampos Stylianopoulos
2025-01-06 14:53 ` [PATCH bpf-next 4/4] selftests/bpf: Add tests for bpf_map_get_num_entries Charalampos Stylianopoulos
2025-01-06 16:19 ` [PATCH bpf-next 0/4] expose number of map entries to userspace Daniel Borkmann
2025-01-07  7:43   ` Anton Protopopov
2025-01-07  7:48   ` Anton Protopopov
     [not found]     ` <CAAvdH+yNG=GefEd5CcP_52gPzzZexWMMxFAxnM3isX04iErMfQ@mail.gmail.com>
2025-01-07 11:10       ` Charalampos Stylianopoulos
2025-01-09 17:37         ` Anton Protopopov
2025-01-14 11:38           ` Nick Zavaritsky
2025-01-16 14:59             ` Anton Protopopov
2025-01-16 17:52               ` Nick Zavaritsky
2025-01-17 10:35                 ` Anton Protopopov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox