From: thinker.li@gmail.com
To: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev,
song@kernel.org, kernel-team@meta.com, andrii@kernel.org,
netdev@vger.kernel.org
Cc: sinquersw@gmail.com, kuifeng@meta.com,
Kui-Feng Lee <thinker.li@gmail.com>
Subject: [PATCH bpf-next] bpf, net: Use bpf mem allocator for sk local storage
Date: Wed, 25 Oct 2023 15:41:51 -0700 [thread overview]
Message-ID: <20231025224151.385719-1-thinker.li@gmail.com> (raw)
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
reply other threads:[~2023-10-25 22:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231025224151.385719-1-thinker.li@gmail.com \
--to=thinker.li@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=kuifeng@meta.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sinquersw@gmail.com \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox