From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Hou Tao <houtao@huaweicloud.com>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <martin.lau@linux.dev>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Hao Luo <haoluo@google.com>,
Yonghong Song <yonghong.song@linux.dev>,
Daniel Borkmann <daniel@iogearbox.net>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
houtao1@huawei.com, xukuohai@huawei.com
Subject: Re: [PATCH bpf-next 0/3] Fix lockdep warning for htab of map
Date: Wed, 6 Nov 2024 11:05:09 +0100 [thread overview]
Message-ID: <20241106100509.7hAottpx@linutronix.de> (raw)
In-Reply-To: <892b3592-0896-7634-ed44-9ba610242eb3@huaweicloud.com>
On 2024-11-06 17:48:59 [+0800], Hou Tao wrote:
> Hi,
Hi,
> Yes. The patch set still invokes check_and_free_fields() under the
> bucket lock when updating an existing element in a pre-allocated htab. I
> missed the hrtimer case. For the sleeping lock, you mean the
> cpu_base->softirq_expiry_lock in hrtimer_cancel_waiting_running(), right
Yes.
> ? Instead of cancelling the timer in workqueue, maybe we could save the
> old value temporarily in the bucket lock, and try to free it outside of
> the bucket lock or disabling the extra_elems logic temporarily for the
> case ?
Well, it is up to you. Either:
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 1a43d06eab286..b077af12fc9b4 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1593,10 +1593,7 @@ void bpf_timer_cancel_and_free(void *val)
* To avoid these issues, punt to workqueue context when we are in a
* timer callback.
*/
- if (this_cpu_read(hrtimer_running))
- queue_work(system_unbound_wq, &t->cb.delete_work);
- else
- bpf_timer_delete_work(&t->cb.delete_work);
+ queue_work(system_unbound_wq, &t->cb.delete_work);
}
/* This function is called by map_delete/update_elem for individual element and
Or something smarter where you cancel the timer outside of the bucket
lock.
Sebastian
next prev parent reply other threads:[~2024-11-06 10:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 6:35 [PATCH bpf-next 0/3] Fix lockdep warning for htab of map Hou Tao
2024-11-06 6:35 ` [PATCH bpf-next 1/3] bpf: Call free_htab_elem() after htab_unlock_bucket() Hou Tao
2024-11-06 9:53 ` Hou Tao
2024-11-08 19:55 ` Alexei Starovoitov
2024-11-09 1:29 ` Hou Tao
2024-11-06 6:35 ` [PATCH bpf-next 2/3] selftests/bpf: Move ENOTSUPP from bpf_util.h Hou Tao
2024-11-06 6:35 ` [PATCH bpf-next 3/3] selftests/bpf: Test the update operations for htab of maps Hou Tao
2024-11-06 8:45 ` [PATCH bpf-next 0/3] Fix lockdep warning for htab of map Sebastian Andrzej Siewior
2024-11-06 9:48 ` Hou Tao
2024-11-06 10:05 ` Sebastian Andrzej Siewior [this message]
2024-11-08 19:52 ` Alexei Starovoitov
2024-11-09 1:48 ` Hou Tao
2024-11-09 1:55 ` Alexei Starovoitov
2024-11-08 19:50 ` 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=20241106100509.7hAottpx@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--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=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=xukuohai@huawei.com \
--cc=yonghong.song@linux.dev \
/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