All of lore.kernel.org
 help / color / mirror / Atom feed
From: sdf@google.com
To: Hou Tao <houtao@huaweicloud.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
	Hao Luo <haoluo@google.com>, Yonghong Song <yhs@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	KP Singh <kpsingh@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	houtao1@huawei.com
Subject: Re: [PATCH bpf 2/2] bpf: Use __llist_del_all() whenever possbile during memory draining
Date: Wed, 19 Oct 2022 12:00:45 -0700	[thread overview]
Message-ID: <Y1BJXRgchDcxwKIJ@google.com> (raw)
In-Reply-To: <20221019115539.983394-3-houtao@huaweicloud.com>

On 10/19, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>

> Except for waiting_for_gp list, there are no concurrent operations on
> free_by_rcu, free_llist and free_llist_extra lists, so use
> __llist_del_all() instead of llist_del_all(). waiting_for_gp list can be
> deleted by RCU callback concurrently, so still use llist_del_all().

> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>   kernel/bpf/memalloc.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)

> diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c
> index 48e606aaacf0..7f45744a09f7 100644
> --- a/kernel/bpf/memalloc.c
> +++ b/kernel/bpf/memalloc.c
> @@ -422,14 +422,17 @@ static void drain_mem_cache(struct bpf_mem_cache *c)
>   	/* No progs are using this bpf_mem_cache, but htab_map_free() called
>   	 * bpf_mem_cache_free() for all remaining elements and they can be in
>   	 * free_by_rcu or in waiting_for_gp lists, so drain those lists now.
> +	 *
> +	 * Except for waiting_for_gp list, there are no concurrent operations
> +	 * on these lists, so it is safe to use __llist_del_all().
>   	 */
>   	llist_for_each_safe(llnode, t, __llist_del_all(&c->free_by_rcu))
>   		free_one(c, llnode);
>   	llist_for_each_safe(llnode, t, llist_del_all(&c->waiting_for_gp))
>   		free_one(c, llnode);
> -	llist_for_each_safe(llnode, t, llist_del_all(&c->free_llist))
> +	llist_for_each_safe(llnode, t, __llist_del_all(&c->free_llist))
>   		free_one(c, llnode);
> -	llist_for_each_safe(llnode, t, llist_del_all(&c->free_llist_extra))
> +	llist_for_each_safe(llnode, t, __llist_del_all(&c->free_llist_extra))
>   		free_one(c, llnode);

Acked-by: Stanislav Fomichev <sdf@google.com>

Seems safe even without the previous patch? OTOH, do we really care
about __lllist vs llist in the cleanup path? Might be safer to always
do llist_del_all everywhere?

>   }

> --
> 2.29.2


  reply	other threads:[~2022-10-19 19:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19 11:55 [PATCH bpf 0/2] Wait for busy refill_work when destorying bpf memory allocator Hou Tao
2022-10-19 11:55 ` [PATCH bpf 1/2] bpf: " Hou Tao
2022-10-19 18:38   ` sdf
2022-10-20  1:07     ` Hou Tao
2022-10-20 17:49       ` Stanislav Fomichev
2022-10-21  1:06         ` Hou Tao
2022-10-19 11:55 ` [PATCH bpf 2/2] bpf: Use __llist_del_all() whenever possbile during memory draining Hou Tao
2022-10-19 19:00   ` sdf [this message]
2022-10-20  1:17     ` Hou Tao
2022-10-20 17:52       ` Stanislav Fomichev
2022-10-21  1:09         ` Hou Tao

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=Y1BJXRgchDcxwKIJ@google.com \
    --to=sdf@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=houtao1@huawei.com \
    --cc=houtao@huaweicloud.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=song@kernel.org \
    --cc=yhs@fb.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.