[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQKJBpvfyvmgM29FLv+KpLwBBRggXWzwKzaCT9U-4bgxjA@mail.gmail.com>
Date: Tue, 19 Dec 2023 16:25:47 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>, "David S. Miller" <davem@...emloft.net>,
Boqun Feng <boqun.feng@...il.com>, Daniel Borkmann <daniel@...earbox.net>,
Eric Dumazet <edumazet@...gle.com>, Frederic Weisbecker <frederic@...nel.org>,
Ingo Molnar <mingo@...hat.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Peter Zijlstra <peterz@...radead.org>, Thomas Gleixner <tglx@...utronix.de>,
Waiman Long <longman@...hat.com>, Will Deacon <will@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>, Cong Wang <xiyou.wangcong@...il.com>,
Hao Luo <haoluo@...gle.com>, Jamal Hadi Salim <jhs@...atatu.com>,
Jesper Dangaard Brouer <hawk@...nel.org>, Jiri Olsa <jolsa@...nel.org>, Jiri Pirko <jiri@...nulli.us>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Ronak Doshi <doshir@...are.com>, Song Liu <song@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>, VMware PV-Drivers Reviewers <pv-drivers@...are.com>,
Yonghong Song <yonghong.song@...ux.dev>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH net-next 15/24] net: Use nested-BH locking for XDP redirect.
On Fri, Dec 15, 2023 at 9:10 AM Sebastian Andrzej Siewior
<bigeasy@...utronix.de> wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 5a0f6da7b3ae5..5ba7509e88752 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3993,6 +3993,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
> *pt_prev = NULL;
> }
>
> + guard(local_lock_nested_bh)(&bpf_run_lock.redirect_lock);
> qdisc_skb_cb(skb)->pkt_len = skb->len;
> tcx_set_ingress(skb, true);
>
> @@ -4045,6 +4046,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
> if (!entry)
> return skb;
>
> + guard(local_lock_nested_bh)(&bpf_run_lock.redirect_lock);
> /* qdisc_skb_cb(skb)->pkt_len & tcx_set_ingress() was
> * already set by the caller.
> */
> @@ -5008,6 +5010,7 @@ int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb)
> u32 act;
> int err;
>
> + guard(local_lock_nested_bh)(&bpf_run_lock.redirect_lock);
> act = netif_receive_generic_xdp(skb, &xdp, xdp_prog);
> if (act != XDP_PASS) {
> switch (act) {
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 7c9653734fb60..72a7812f933a1 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -4241,6 +4241,7 @@ static const struct bpf_func_proto bpf_xdp_adjust_meta_proto = {
> */
> void xdp_do_flush(void)
> {
> + guard(local_lock_nested_bh)(&bpf_run_lock.redirect_lock);
> __dev_flush();
> __cpu_map_flush();
> __xsk_map_flush();
> diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
> index a94943681e5aa..74b88e897a7e3 100644
> --- a/net/core/lwt_bpf.c
> +++ b/net/core/lwt_bpf.c
> @@ -44,6 +44,7 @@ static int run_lwt_bpf(struct sk_buff *skb, struct bpf_lwt_prog *lwt,
> * BPF prog and skb_do_redirect().
> */
> local_bh_disable();
> + local_lock_nested_bh(&bpf_run_lock.redirect_lock);
> bpf_compute_data_pointers(skb);
> ret = bpf_prog_run_save_cb(lwt->prog, skb);
>
> @@ -76,6 +77,7 @@ static int run_lwt_bpf(struct sk_buff *skb, struct bpf_lwt_prog *lwt,
> break;
> }
>
> + local_unlock_nested_bh(&bpf_run_lock.redirect_lock);
> local_bh_enable();
>
> return ret;
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index 1976bd1639863..da61b99bc558f 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -23,6 +23,7 @@
> #include <linux/jhash.h>
> #include <linux/rculist.h>
> #include <linux/rhashtable.h>
> +#include <linux/bpf.h>
> #include <net/net_namespace.h>
> #include <net/sock.h>
> #include <net/netlink.h>
> @@ -3925,6 +3926,7 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru
>
> fl = rcu_dereference_bh(qe->filter_chain);
>
> + guard(local_lock_nested_bh)(&bpf_run_lock.redirect_lock);
> switch (tcf_classify(skb, NULL, fl, &cl_res, false)) {
> case TC_ACT_SHOT:
> qdisc_qstats_drop(sch);
Here and in all other places this patch adds locks that
will kill performance of XDP, tcx and everything else in networking.
I'm surprised Jesper and other folks are not jumping in with nacks.
We measure performance in nanoseconds here.
Extra lock is no go.
Please find a different way without ruining performance.
Powered by blists - more mailing lists