[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87bkhydilw.fsf@toke.dk>
Date: Thu, 01 Jun 2023 22:37:31 +0200
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Jesper Dangaard Brouer <brouer@...hat.com>, Tariq Toukan
<ttoukan.linux@...il.com>, Daniel Borkmann <borkmann@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko
<andrii.nakryiko@...il.com>, bpf@...r.kernel.org
Cc: Jesper Dangaard Brouer <brouer@...hat.com>, Tariq Toukan
<tariqt@...dia.com>, gal@...dia.com, lorenzo@...nel.org,
netdev@...r.kernel.org, echaudro@...hat.com,
andrew.gospodarek@...adcom.com
Subject: Re: [PATCH bpf-next V2] bpf/xdp: optimize bpf_xdp_pointer to avoid
reading sinfo
Jesper Dangaard Brouer <brouer@...hat.com> writes:
> Currently we observed a significant performance degradation in
> samples/bpf xdp1 and xdp2, due XDP multibuffer "xdp.frags" handling,
> added in commit 772251742262 ("samples/bpf: fixup some tools to be able
> to support xdp multibuffer").
>
> This patch reduce the overhead by avoiding to read/load shared_info
> (sinfo) memory area, when XDP packet don't have any frags. This improves
> performance because sinfo is located in another cacheline.
>
> Function bpf_xdp_pointer() is used by BPF helpers bpf_xdp_load_bytes()
> and bpf_xdp_store_bytes(). As a help to reviewers, xdp_get_buff_len() can
> potentially access sinfo, but it uses xdp_buff_has_frags() flags bit check
> to avoid accessing sinfo in no-frags case.
>
> The likely/unlikely instrumentation lays out asm code such that sinfo
> access isn't interleaved with no-frags case (checked on GCC 12.2.1-4).
> The generated asm code is more compact towards the no-frags case.
>
> The BPF kfunc bpf_dynptr_slice() also use bpf_xdp_pointer(). Thus, it
> should also take effect for that.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@...hat.com>
Thanks for fixing this!
Acked-by: Toke Høiland-Jørgensen <toke@...hat.com>
Powered by blists - more mailing lists