[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YfvHstBs/FCBtVhU@linutronix.de>
Date: Thu, 3 Feb 2022 13:16:50 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Eric Dumazet <edumazet@...gle.com>
Cc: bpf <bpf@...r.kernel.org>, netdev <netdev@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH net-next 1/4] net: dev: Remove the preempt_disable() in
netif_rx_internal().
On 2022-02-02 09:10:10 [-0800], Eric Dumazet wrote:
> On Wed, Feb 2, 2022 at 4:28 AM Sebastian Andrzej Siewior
> <bigeasy@...utronix.de> wrote:
> >
> > The preempt_disable() and rcu_disable() section was introduced in commit
> > bbbe211c295ff ("net: rcu lock and preempt disable missing around generic xdp")
> >
> > The backtrace shows that bottom halves were disabled and so the usage of
> > smp_processor_id() would not trigger a warning.
> > The "suspicious RCU usage" warning was triggered because
> > rcu_dereference() was not used in rcu_read_lock() section (only
> > rcu_read_lock_bh()). A rcu_read_lock() is sufficient.
> >
> > Remove the preempt_disable() statement which is not needed.
>
> I am confused by this changelog/analysis of yours.
>
> According to git blame, you are reverting this patch.
>
> commit cece1945bffcf1a823cdfa36669beae118419351
> Author: Changli Gao <xiaosuo@...il.com>
> Date: Sat Aug 7 20:35:43 2010 -0700
>
> net: disable preemption before call smp_processor_id()
>
> Although netif_rx() isn't expected to be called in process context with
> preemption enabled, it'd better handle this case. And this is why get_cpu()
> is used in the non-RPS #ifdef branch. If tree RCU is selected,
> rcu_read_lock() won't disable preemption, so preempt_disable() should be
> called explictly.
>
> Signed-off-by: Changli Gao <xiaosuo@...il.com>
> Signed-off-by: David S. Miller <davem@...emloft.net>
Nut sure if I ignored it or made a wrong turn somewhere. But I remember
reading it. But here, preempt_disable() was added because
| Although netif_rx() isn't expected to be called in process context with
| preemption enabled, it'd better handle this case.
and this isn't much of a good reason. Simply because netif_rx()
shouldn't not be called from preemptible context.
> But I am not sure we can.
>
> Here is the code in larger context:
>
> #ifdef CONFIG_RPS
> if (static_branch_unlikely(&rps_needed)) {
> struct rps_dev_flow voidflow, *rflow = &voidflow;
> int cpu;
>
> preempt_disable();
> rcu_read_lock();
>
> cpu = get_rps_cpu(skb->dev, skb, &rflow);
> if (cpu < 0)
> cpu = smp_processor_id();
>
> ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
>
> rcu_read_unlock();
> preempt_enable();
> } else
> #endif
>
> This code needs the preempt_disable().
But why? netif_rx_internal() should be invoked with disabled BH so I
don't see a reason why preemption needs additionally be disabled in this
section.
On PREEMPT_RT we can get preempted but the task remains on the CPU and
other network activity will be block on the BH-lock.
Sebastian
Powered by blists - more mailing lists