Topics

[RFC PATCH v2 0/3] Implement bpf map queue

Mauricio Vasquez
 

Bpf queue map is a new kind of map that provides a LIFO/FIFO queue
implementation.

In some applications, like a SNAT, it is necessary to keep track of
a pool of free elemenets, network ports in this case, then a queue
can be used for that purpose.

v2:
- precharge memory on map allocation
- add percpu free list when prealloc is enabled

Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@...>

---

Mauricio Vasquez B (3):
bpf: add bpf queue map
selftests/bpf: add test cases for BPF_MAP_TYPE_QUEUE
bpf: add sample for BPF_MAP_TYPE_QUEUE


include/linux/bpf_types.h | 1
include/uapi/linux/bpf.h | 5 +
kernel/bpf/Makefile | 2
kernel/bpf/queuemap.c | 285 +++++++++++++++++++++++++++++++
kernel/bpf/syscall.c | 61 +++++--
kernel/bpf/verifier.c | 10 +
samples/bpf/.gitignore | 1
samples/bpf/Makefile | 3
samples/bpf/test_map_in_map_user.c | 9 -
samples/bpf/test_queuemap.sh | 37 ++++
samples/bpf/test_queuemap_kern.c | 51 ++++++
samples/bpf/test_queuemap_user.c | 53 ++++++
tools/include/uapi/linux/bpf.h | 5 +
tools/testing/selftests/bpf/test_maps.c | 71 ++++++++
14 files changed, 569 insertions(+), 25 deletions(-)
create mode 100644 kernel/bpf/queuemap.c
create mode 100755 samples/bpf/test_queuemap.sh
create mode 100644 samples/bpf/test_queuemap_kern.c
create mode 100644 samples/bpf/test_queuemap_user.c

--
Signature

Yonghong Song
 

On Thu, Aug 2, 2018 at 10:29 AM, Mauricio Vasquez
<mauricio.vasquez@...> wrote:
Bpf queue map is a new kind of map that provides a LIFO/FIFO queue
implementation.

In some applications, like a SNAT, it is necessary to keep track of
a pool of free elemenets, network ports in this case, then a queue
can be used for that purpose.
I did not check the detailed implementation for percpu freelist implementation,
but the general framework looks sound. I think the patch is ready to send
to netdev with "[PATCH bpf-next]" prefix for more review if bpf-next does
not close soon.

Thanks!


v2:
- precharge memory on map allocation
- add percpu free list when prealloc is enabled

Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@...>

---

Mauricio Vasquez B (3):
bpf: add bpf queue map
selftests/bpf: add test cases for BPF_MAP_TYPE_QUEUE
bpf: add sample for BPF_MAP_TYPE_QUEUE


include/linux/bpf_types.h | 1
include/uapi/linux/bpf.h | 5 +
kernel/bpf/Makefile | 2
kernel/bpf/queuemap.c | 285 +++++++++++++++++++++++++++++++
kernel/bpf/syscall.c | 61 +++++--
kernel/bpf/verifier.c | 10 +
samples/bpf/.gitignore | 1
samples/bpf/Makefile | 3
samples/bpf/test_map_in_map_user.c | 9 -
samples/bpf/test_queuemap.sh | 37 ++++
samples/bpf/test_queuemap_kern.c | 51 ++++++
samples/bpf/test_queuemap_user.c | 53 ++++++
tools/include/uapi/linux/bpf.h | 5 +
tools/testing/selftests/bpf/test_maps.c | 71 ++++++++
14 files changed, 569 insertions(+), 25 deletions(-)
create mode 100644 kernel/bpf/queuemap.c
create mode 100755 samples/bpf/test_queuemap.sh
create mode 100644 samples/bpf/test_queuemap_kern.c
create mode 100644 samples/bpf/test_queuemap_user.c

--
Signature


Mauricio Vasquez
 

On 08/04/2018 12:07 AM, Yonghong Song wrote:
On Thu, Aug 2, 2018 at 10:29 AM, Mauricio Vasquez
<mauricio.vasquez@...> wrote:
Bpf queue map is a new kind of map that provides a LIFO/FIFO queue
implementation.

In some applications, like a SNAT, it is necessary to keep track of
a pool of free elemenets, network ports in this case, then a queue
can be used for that purpose.
I did not check the detailed implementation for percpu freelist implementation,
but the general framework looks sound. I think the patch is ready to send
to netdev with "[PATCH bpf-next]" prefix for more review if bpf-next does
not close soon.

Thanks!
Will send to netdev. Thanks!


v2:
- precharge memory on map allocation
- add percpu free list when prealloc is enabled

Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@...>

---

Mauricio Vasquez B (3):
bpf: add bpf queue map
selftests/bpf: add test cases for BPF_MAP_TYPE_QUEUE
bpf: add sample for BPF_MAP_TYPE_QUEUE


include/linux/bpf_types.h | 1
include/uapi/linux/bpf.h | 5 +
kernel/bpf/Makefile | 2
kernel/bpf/queuemap.c | 285 +++++++++++++++++++++++++++++++
kernel/bpf/syscall.c | 61 +++++--
kernel/bpf/verifier.c | 10 +
samples/bpf/.gitignore | 1
samples/bpf/Makefile | 3
samples/bpf/test_map_in_map_user.c | 9 -
samples/bpf/test_queuemap.sh | 37 ++++
samples/bpf/test_queuemap_kern.c | 51 ++++++
samples/bpf/test_queuemap_user.c | 53 ++++++
tools/include/uapi/linux/bpf.h | 5 +
tools/testing/selftests/bpf/test_maps.c | 71 ++++++++
14 files changed, 569 insertions(+), 25 deletions(-)
create mode 100644 kernel/bpf/queuemap.c
create mode 100755 samples/bpf/test_queuemap.sh
create mode 100644 samples/bpf/test_queuemap_kern.c
create mode 100644 samples/bpf/test_queuemap_user.c

--
Signature