[PATCH bpf-next] bpf, net: Use bpf mem allocator for sk local storage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kui-Feng Lee <thinker.li@xxxxxxxxx>

Switching to BPF memory allocator improve the performance
of sk local storage in terms of creating and destroying.

Here is numbers w/ and w/o this changes.

 - ./bench local-storage-create --storage-type=socket
   - w/ change
     - creates  552.474 ± 1.186k/s (552.474k/prod), 2.10 kmallocs/create
   - w/o change
     - creates  469.960 ± 2.501k/s (469.960k/prod), 4.18 kmallocs/create
 - ./bench -p 4 local-storage-create --storage-type=socket
   - w/ change
     - creates 1236.614 ± 2.833k/s (309.153k/prod), 2.09 kmallocs/create
   - w/o change
     - creates 1120.524 ± 1.527k/s (280.131k/prod), 4.16 kmallocs/create
 - ./bench -p 4 local-storage-create --storage-type=socket \
      --batch-size=1024
   - w/ change
     - creates 1416.437 ± 37.679k/s (354.109k/prod), 2.06 kmallocs/create
   - w/o change
     - creates 1302.636 ± 13.649k/s (325.659k/prod), 4.12 kmallocs/create

Overall, with bpf memory allocator, it improves
 - 17% for single thread and with batch size 32,
 - 10% for 4 threads and with batch size 32, and
 - 8% for 4 threads and with batch size 1024.

Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
---
 net/core/bpf_sk_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index cca7594be92e..fdd9ad15cfe9 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -68,7 +68,7 @@ static void bpf_sk_storage_map_free(struct bpf_map *map)
 
 static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
 {
-	return bpf_local_storage_map_alloc(attr, &sk_cache, false);
+	return bpf_local_storage_map_alloc(attr, &sk_cache, true);
 }
 
 static int notsupp_get_next_key(struct bpf_map *map, void *key,
-- 
2.34.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux