All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: daniel@iogearbox.net, andrii@kernel.org, void@manifault.com,
	houtao@huaweicloud.com, paulmck@kernel.org
Cc: tj@kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH bpf-next 08/12] bpf: Allow reuse from waiting_for_gp_ttrace list.
Date: Tue, 20 Jun 2023 19:32:34 -0700	[thread overview]
Message-ID: <20230621023238.87079-9-alexei.starovoitov@gmail.com> (raw)
In-Reply-To: <20230621023238.87079-1-alexei.starovoitov@gmail.com>

From: Alexei Starovoitov <ast@kernel.org>

alloc_bulk() can reuse elements from free_by_rcu_ttrace.
Let it reuse from waiting_for_gp_ttrace as well to avoid unnecessary kmalloc().

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/bpf/memalloc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c
index 8b7645bffd1a..10d027674743 100644
--- a/kernel/bpf/memalloc.c
+++ b/kernel/bpf/memalloc.c
@@ -202,6 +202,15 @@ static void alloc_bulk(struct bpf_mem_cache *c, int cnt, int node)
 	if (i >= cnt)
 		return;
 
+	for (; i < cnt; i++) {
+		obj = llist_del_first(&c->waiting_for_gp_ttrace);
+		if (!obj)
+			break;
+		add_obj_to_free_list(c, obj);
+	}
+	if (i >= cnt)
+		return;
+
 	memcg = get_memcg(c);
 	old_memcg = set_active_memcg(memcg);
 	for (; i < cnt; i++) {
-- 
2.34.1


  parent reply	other threads:[~2023-06-21  2:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21  2:32 [PATCH bpf-next 00/12] bpf: Introduce bpf_mem_cache_free_rcu() Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 01/12] bpf: Rename few bpf_mem_alloc fields Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 02/12] bpf: Simplify code of destroy_mem_alloc() with kmemdup() Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 03/12] bpf: Let free_all() return the number of freed elements Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 04/12] bpf: Refactor alloc_bulk() Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 05/12] bpf: Further refactor alloc_bulk() Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 06/12] bpf: Optimize moving objects from free_by_rcu_ttrace to waiting_for_gp_ttrace Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 07/12] bpf: Add a hint to allocated objects Alexei Starovoitov
2023-06-24  3:28   ` Hou Tao
2023-06-24  3:42     ` Alexei Starovoitov
2023-06-24  3:54       ` Hou Tao
2023-06-24  3:57         ` Alexei Starovoitov
2023-06-21  2:32 ` Alexei Starovoitov [this message]
2023-06-21  2:32 ` [PATCH bpf-next 09/12] rcu: Export rcu_request_urgent_qs_task() Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 10/12] selftests/bpf: Improve test coverage of bpf_mem_alloc Alexei Starovoitov
2023-06-21  2:32 ` [PATCH bpf-next 11/12] bpf: Introduce bpf_mem_free_rcu() similar to kfree_rcu() Alexei Starovoitov
2023-06-21 12:26   ` Hou Tao
2023-06-22  3:23     ` Alexei Starovoitov
2023-06-24  9:12       ` Hou Tao
2023-06-21  2:32 ` [PATCH bpf-next 12/12] bpf: Convert bpf_cpumask to bpf_mem_cache_free_rcu Alexei Starovoitov

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=20230621023238.87079-9-alexei.starovoitov@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=houtao@huaweicloud.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.