netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hou Tao <houtao@huaweicloud.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
	rcu@vger.kernel.org, Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, Kernel Team <kernel-team@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	David Vernet <void@manifault.com>,
	"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH v4 bpf-next 12/14] bpf: Introduce bpf_mem_free_rcu() similar to kfree_rcu().
Date: Fri, 7 Jul 2023 12:05:18 +0800	[thread overview]
Message-ID: <205ac9e9-ef8c-2b39-8d76-a937d6fc72d5@huaweicloud.com> (raw)
In-Reply-To: <CAADnVQKea47Q1WPtmVrHEZijb=Ms8QzufVj8eds5HmNXGxSRug@mail.gmail.com>

Hi,

On 7/7/2023 10:10 AM, Alexei Starovoitov wrote:
> On Thu, Jul 6, 2023 at 6:45 PM Hou Tao <houtao@huaweicloud.com> wrote:
>>
>>
>> On 7/6/2023 11:34 AM, Alexei Starovoitov wrote:
>>> From: Alexei Starovoitov <ast@kernel.org>
>>>
>>> Introduce bpf_mem_[cache_]free_rcu() similar to kfree_rcu().
>>> Unlike bpf_mem_[cache_]free() that links objects for immediate reuse into
>>> per-cpu free list the _rcu() flavor waits for RCU grace period and then moves
>>> objects into free_by_rcu_ttrace list where they are waiting for RCU
>>> task trace grace period to be freed into slab.
>>>
>>> The life cycle of objects:
>>> alloc: dequeue free_llist
>>> free: enqeueu free_llist
>>> free_rcu: enqueue free_by_rcu -> waiting_for_gp
>>> free_llist above high watermark -> free_by_rcu_ttrace
>>> after RCU GP waiting_for_gp -> free_by_rcu_ttrace
>>> free_by_rcu_ttrace -> waiting_for_gp_ttrace -> slab
>>>
>>> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>> Acked-by: Hou Tao <houtao1@huawei.com>
> Thank you very much for code reviews and feedback.

You are welcome. I also learn a lot from this great patch set.

>
> btw I still believe that ABA is a non issue and prefer to keep the code as-is,
> but for the sake of experiment I've converted it to spin_lock
> (see attached patch which I think uglifies the code)
> and performance across bench htab-mem and map_perf_test
> seems to be about the same.
> Which was a bit surprising to me.
> Could you please benchmark it on your system?

Will do that later. It seems if there is no cross-CPU allocation and
free, the only possible contention is between __free_rcu() on CPU x and
alloc_bulk()/free_bulk() on a different CPU.


  reply	other threads:[~2023-07-07  4:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06  3:34 [PATCH v4 bpf-next 00/14] bpf: Introduce bpf_mem_cache_free_rcu() Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 01/14] bpf: Rename few bpf_mem_alloc fields Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 02/14] bpf: Simplify code of destroy_mem_alloc() with kmemdup() Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 03/14] bpf: Let free_all() return the number of freed elements Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 04/14] bpf: Refactor alloc_bulk() Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 05/14] bpf: Factor out inc/dec of active flag into helpers Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 06/14] bpf: Further refactor alloc_bulk() Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 07/14] bpf: Change bpf_mem_cache draining process Alexei Starovoitov
2023-07-06 12:55   ` Hou Tao
2023-07-06  3:34 ` [PATCH v4 bpf-next 08/14] bpf: Add a hint to allocated objects Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 09/14] bpf: Allow reuse from waiting_for_gp_ttrace list Alexei Starovoitov
2023-07-07  2:07   ` Hou Tao
2023-07-07  2:12     ` Alexei Starovoitov
2023-07-07  3:38       ` Hou Tao
2023-07-07  4:16         ` Alexei Starovoitov
2023-07-07  4:37           ` Hou Tao
2023-07-07 16:11             ` Alexei Starovoitov
2023-07-07 17:47               ` Paul E. McKenney
2023-07-07 22:22                 ` Joel Fernandes
2023-07-08  7:03                 ` Hou Tao
2023-07-10  4:45                   ` Paul E. McKenney
2023-07-06  3:34 ` [PATCH v4 bpf-next 10/14] rcu: Export rcu_request_urgent_qs_task() Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 11/14] selftests/bpf: Improve test coverage of bpf_mem_alloc Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 12/14] bpf: Introduce bpf_mem_free_rcu() similar to kfree_rcu() Alexei Starovoitov
2023-07-07  1:45   ` Hou Tao
2023-07-07  2:10     ` Alexei Starovoitov
2023-07-07  4:05       ` Hou Tao [this message]
2023-07-08  7:00         ` Hou Tao
2023-07-06  3:34 ` [PATCH v4 bpf-next 13/14] bpf: Convert bpf_cpumask to bpf_mem_cache_free_rcu Alexei Starovoitov
2023-07-06  3:34 ` [PATCH v4 bpf-next 14/14] bpf: Add object leak check Alexei Starovoitov
2023-07-12 21:50 ` [PATCH v4 bpf-next 00/14] bpf: Introduce bpf_mem_cache_free_rcu() patchwork-bot+netdevbpf

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=205ac9e9-ef8c-2b39-8d76-a937d6fc72d5@huaweicloud.com \
    --to=houtao@huaweicloud.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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 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).