[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0b281dae-3d94-4ac4-ab53-eff6d51a5135@uliege.be>
Date: Tue, 15 Apr 2025 17:12:09 +0200
From: Justin Iurman <justin.iurman@...ege.be>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrea Mayer <andrea.mayer@...roma2.it>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Sebastian Sewior <bigeasy@...utronix.de>,
Stanislav Fomichev <stfomichev@...il.com>,
Network Development <netdev@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Kuniyuki Iwashima <kuniyu@...zon.com>, bpf <bpf@...r.kernel.org>,
Stefano Salsano <stefano.salsano@...roma2.it>,
Paolo Lungaroni <paolo.lungaroni@...roma2.it>
Subject: Re: [PATCH net] net: lwtunnel: disable preemption when required
On 4/15/25 16:38, Jakub Kicinski wrote:
> On Tue, 15 Apr 2025 11:10:01 +0200 Justin Iurman wrote:
>>> However, there is my opinion an issue that can occur: between the check on
>>> in_softirq() and the call to local_bh_disable(), the task may be scheduled on
>>> another CPU. As a result, the check on in_softirq() becomes ineffective because
>>> we may end up disabling BH on a CPU that is not the one we just checked (with
>>> if (in_softirq()) { ... }).
>
> The context is not affected by migration. The context is fully defined
> by the execution stack.
>
>> Hmm, I think it's correct... good catch. I went for this solution to (i)
>> avoid useless nested BHs disable calls; and (ii) avoid ending up with a
>> spaghetti graph of possible paths with or without BHs disabled (i.e.,
>> with single entry points, namely lwtunnel_xmit() and lwtunnel_output()),
>> which otherwise makes it hard to maintain the code IMO.
>>
>> So, if we want to follow what Alexei suggests (see his last response),
>> we'd need to disable BHs in both ip_local_out() and ip6_local_out().
>> These are the common functions which are closest in depth, and so for
>> both lwtunnel_xmit() and lwtunnel_output(). But... at the "cost" of
>> disabling BHs even when it may not be required. Indeed, ip_local_out()
>> and ip6_local_out() both call dst_output(), which one is usually not
>> lwtunnel_output() (and there may not even be a lwtunnel_xmit() to call
>> either).
>>
>> The other solution is to always call local_bh_disable() in both
>> lwtunnel_xmit() and lwtunnel_output(), at the cost of disabling BHs when
>> they were already. Which was basically -v1 and received a NACK from Alexei.
>
> I thought he nacked preempt_disable()
I think I wasn't clear enough, sorry. Alexei explicitly NACK'ed the
initial patch (the one with preempt_disable()) -- you're right. I think
he also (implicitly) NACK'ed the other solution I proposed (see [1]) by
reading his reply. Alexei can clarify if I'm mistaken. He seems to
prefer the solution that disables BHs on specific paths (see [2] for the
other proposal) instead of inside lwtunnel_xmit() and lwtunnel_output().
So, basically, we have a choice to make between [1] and [2], where [1]
IMO is better for the following reasons: (i) no nested calls to disable
BHs, (ii) disable BHs only when they're not already, and (iii) code
clarity, i.e., not overly complexifying the graph of paths w/ or w/o BHs
disabled. While with [2], BHs will be disabled even when not required on
the xmit/output path, and also resulting in an even more complex graph
of paths regarding BHs.
[1]
https://lore.kernel.org/netdev/20250415073818.06ea327c@kernel.org/T/#m5a4e6a56206d9d110a5e4d664ab4ea09e7e9b33e
[2]
https://lore.kernel.org/netdev/20250415073818.06ea327c@kernel.org/T/#m3a88de38eceb0a53e2d173dc3675ecaa37e9d0b4
Powered by blists - more mailing lists