From: Martin KaFai Lau <martin.lau@linux.dev>
To: Tonghao Zhang <tong@infragraf.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Hou Tao <houtao1@huawei.com>,
bpf@vger.kernel.org
Subject: Re: [bpf-next v5 3/3] bpf: hash map, suppress false lockdep warning
Date: Sun, 15 Jan 2023 14:51:47 -0800 [thread overview]
Message-ID: <bfa2b221-9ed7-2791-08e2-2e5b29e21dee@linux.dev> (raw)
In-Reply-To: <EE4608EF-84F5-4E4C-967F-37B96D680D2E@infragraf.org>
On 1/13/23 1:15 AM, Tonghao Zhang wrote:
>
>
>> On Jan 13, 2023, at 9:53 AM, Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>
>> On 1/11/23 1:29 AM, tong@infragraf.org wrote:
>>> + /*
>>> + * The lock may be taken in both NMI and non-NMI contexts.
>>> + * There is a false lockdep warning (inconsistent lock state),
>>> + * if lockdep enabled. The potential deadlock happens when the
>>> + * lock is contended from the same cpu. map_locked rejects
>>> + * concurrent access to the same bucket from the same CPU.
>>> + * When the lock is contended from a remote cpu, we would
>>> + * like the remote cpu to spin and wait, instead of giving
>>> + * up immediately. As this gives better throughput. So replacing
>>> + * the current raw_spin_lock_irqsave() with trylock sacrifices
>>> + * this performance gain. atomic map_locked is necessary.
>>> + * lockdep_off is invoked temporarily to fix the false warning.
>>> + */
>>> + lockdep_off();
>>> raw_spin_lock_irqsave(&b->raw_lock, flags);
>>> - *pflags = flags;
>>> + lockdep_on();
>>
>> I am not very sure about the lockdep_off/on. Other than the false warning when using the very same htab map by both NMI and non-NMI context, I think the lockdep will still be useful to catch other potential issues. The commit c50eb518e262 ("bpf: Use separate lockdep class for each hashtab") has already solved this false alarm when NMI happens on one map and non-NMI happens on another map.
>>
>> Alexei, what do you think? May be only land the patch 1 fix for now.
> Hi Martin
> Patch 2 is used for patch 1 to test whether there is a deadlock. We should apply this two patches.
It is too noisy for test_progs that developers routinely run. Lets continue to
explore other ways (or a different test) without this false positive splat.
Patch 1 was applied as already mentioned in the earlier reply.
next prev parent reply other threads:[~2023-01-15 22:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 9:29 [bpf-next v5 1/3] bpf: hash map, avoid deadlock with suitable hash mask tong
2023-01-11 9:29 ` [bpf-next v5 2/3] selftests/bpf: add test case for htab map tong
2023-01-11 9:29 ` [bpf-next v5 3/3] bpf: hash map, suppress false lockdep warning tong
2023-01-13 1:53 ` Martin KaFai Lau
2023-01-13 2:03 ` Alexei Starovoitov
2023-01-13 2:17 ` Tonghao Zhang
2023-01-13 5:14 ` Martin KaFai Lau
2023-01-13 9:15 ` Tonghao Zhang
2023-01-15 22:51 ` Martin KaFai Lau [this message]
2023-02-01 7:12 ` 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=bfa2b221-9ed7-2791-08e2-2e5b29e21dee@linux.dev \
--to=martin.lau@linux.dev \
--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=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tong@infragraf.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.