netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf, net: Use bpf mem allocator for sk local storage
@ 2023-10-25 22:41 thinker.li
  0 siblings, 0 replies; only message in thread
From: thinker.li @ 2023-10-25 22:41 UTC (permalink / raw)
  To: bpf, ast, martin.lau, song, kernel-team, andrii, netdev
  Cc: sinquersw, kuifeng, Kui-Feng Lee

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

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-25 22:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-25 22:41 [PATCH bpf-next] bpf, net: Use bpf mem allocator for sk local storage thinker.li

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).