BPF List
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Hou Tao <houtao@huaweicloud.com>, bpf@vger.kernel.org
Cc: "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>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	houtao1@huawei.com, xukuohai@huawei.com
Subject: Re: [PATCH bpf v2 7/9] bpf: Use raw_spinlock_t for LPM trie
Date: Fri, 29 Nov 2024 13:18:17 +0100	[thread overview]
Message-ID: <87frnai67q.fsf@toke.dk> (raw)
In-Reply-To: <20241127004641.1118269-8-houtao@huaweicloud.com>

Hou Tao <houtao@huaweicloud.com> writes:

> From: Hou Tao <houtao1@huawei.com>
>
> After switching from kmalloc() to the bpf memory allocator, there will be
> no blocking operation during the update of LPM trie. Therefore, change
> trie->lock from spinlock_t to raw_spinlock_t to make LPM trie usable in
> atomic context, even on RT kernels.
>
> The max value of prefixlen is 2048. Therefore, update or deletion
> operations will find the target after at most 2048 comparisons.
> Constructing a test case which updates an element after 2048 comparisons
> under a 8 CPU VM, and the average time and the maximal time for such
> update operation is about 210us and 900us.

That is... quite a long time? I'm not sure we have any guidance on what
the maximum acceptable time is (perhaps the RT folks can weigh in
here?), but stalling for almost a millisecond seems long.

Especially doing this unconditionally seems a bit risky; this means that
even a networking program using the lpm map in the data path can stall
the system for that long, even if it would have been perfectly happy to
be preempted.

So one option here could be to make it conditional? As in, have a map
flag (on creation) that switches to raw_spinlock usage, and reject using
the map from atomic context if that flag is not set?

-Toke


  reply	other threads:[~2024-11-29 12:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-27  0:46 [PATCH bpf v2 0/9] Fixes for LPM trie Hou Tao
2024-11-27  0:46 ` [PATCH bpf v2 1/9] bpf: Remove unnecessary check when updating " Hou Tao
2024-12-02 16:08   ` Daniel Borkmann
2024-11-27  0:46 ` [PATCH bpf v2 2/9] bpf: Remove unnecessary kfree(im_node) in lpm_trie_update_elem Hou Tao
2024-12-02 16:10   ` Daniel Borkmann
2024-11-27  0:46 ` [PATCH bpf v2 3/9] bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie Hou Tao
2024-12-02 17:17   ` Daniel Borkmann
2024-11-27  0:46 ` [PATCH bpf v2 4/9] bpf: Handle in-place update for full LPM trie correctly Hou Tao
2024-11-29 11:45   ` Toke Høiland-Jørgensen
2024-11-27  0:46 ` [PATCH bpf v2 5/9] bpf: Fix exact match conditions in trie_get_next_key() Hou Tao
2024-11-27  0:46 ` [PATCH bpf v2 6/9] bpf: Switch to bpf mem allocator for LPM trie Hou Tao
2024-11-27  5:51   ` Alexei Starovoitov
2024-11-28  4:12     ` Hou Tao
2024-11-29 12:01   ` Toke Høiland-Jørgensen
2024-11-27  0:46 ` [PATCH bpf v2 7/9] bpf: Use raw_spinlock_t " Hou Tao
2024-11-29 12:18   ` Toke Høiland-Jørgensen [this message]
2024-12-03  1:42     ` Alexei Starovoitov
2024-12-05  8:52       ` Hou Tao
2024-12-05  9:47         ` Toke Høiland-Jørgensen
2024-12-15  9:37           ` Hou Tao
2024-12-15 16:51             ` Toke Høiland-Jørgensen
2024-12-05 17:06         ` Alexei Starovoitov
2024-12-06  0:48           ` Hou Tao
2024-12-06  1:40             ` Alexei Starovoitov
2024-11-27  0:46 ` [PATCH bpf v2 8/9] selftests/bpf: Move test_lpm_map.c to map_tests Hou Tao
2024-11-27  0:46 ` [PATCH bpf v2 9/9] selftests/bpf: Add more test cases for LPM trie Hou Tao
2024-11-27  5:39   ` Alexei Starovoitov
2024-11-27  8:02     ` 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=87frnai67q.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bigeasy@linutronix.de \
    --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=linux@weissschuh.net \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=tglx@linutronix.de \
    --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