[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <def859b3-b6ea-7338-38eb-3f18ec3d60c2@huawei.com>
Date: Sat, 15 May 2021 10:25:25 +0800
From: Yunsheng Lin <linyunsheng@...wei.com>
To: Jakub Kicinski <kuba@...nel.org>,
Cong Wang <xiyou.wangcong@...il.com>
CC: David Miller <davem@...emloft.net>,
Vladimir Oltean <olteanv@...il.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andriin@...com>,
Eric Dumazet <edumazet@...gle.com>,
"Wei Wang" <weiwan@...gle.com>,
"Cong Wang ." <cong.wang@...edance.com>,
Taehee Yoo <ap420073@...il.com>,
Linux Kernel Network Developers <netdev@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>, <linuxarm@...neuler.org>,
Marc Kleine-Budde <mkl@...gutronix.de>,
<linux-can@...r.kernel.org>, Jamal Hadi Salim <jhs@...atatu.com>,
Jiri Pirko <jiri@...nulli.us>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
<kpsingh@...nel.org>, bpf <bpf@...r.kernel.org>,
Jonas Bonn <jonas.bonn@...rounds.com>,
Paolo Abeni <pabeni@...hat.com>,
Michael Zhivich <mzhivich@...mai.com>,
Josh Hunt <johunt@...mai.com>, Jike Song <albcamus@...il.com>,
Kehuan Feng <kehuan.feng@...il.com>,
Ahmad Fatoum <a.fatoum@...gutronix.de>, <atenart@...nel.org>,
Alexander Duyck <alexander.duyck@...il.com>,
"Hillf Danton" <hdanton@...a.com>, <jgross@...e.com>,
<JKosina@...e.com>, "Michal Kubecek" <mkubecek@...e.cz>,
Björn Töpel <bjorn@...nel.org>,
Alexander Lobakin <alobakin@...me>
Subject: Re: [PATCH net v8 1/3] net: sched: fix packet stuck problem for
lockless qdisc
On 2021/5/15 8:17, Jakub Kicinski wrote:
> On Fri, 14 May 2021 16:57:29 -0700 Cong Wang wrote:
>> On Fri, May 14, 2021 at 4:39 PM Jakub Kicinski <kuba@...nel.org> wrote:
>>>
>>> On Fri, 14 May 2021 16:36:16 -0700 Cong Wang wrote:
>> [...]
>>>>
>>>> We have test_and_clear_bit() which is atomic, test_bit()+clear_bit()
>>>> is not.
>>>
>>> It doesn't have to be atomic, right? I asked to split the test because
>>> test_and_clear is a locked op on x86, test by itself is not.
>>
>> It depends on whether you expect the code under the true condition
>> to run once or multiple times, something like:
>>
>> if (test_bit()) {
>> clear_bit();
>> // this code may run multiple times
>> }
>>
>> With the atomic test_and_clear_bit(), it only runs once:
>>
>> if (test_and_clear_bit()) {
>> // this code runs once
>> }
I am not sure if the above really matter when the test and clear
does not need to be atomic.
In order for the above to happens, the MISSED has to set between
test and clear, right?
>>
>> This is why __netif_schedule() uses test_and_set_bit() instead of
>> test_bit()+set_bit().
I think test_and_set_bit() is needed in __netif_schedule() mainly
because STATE_SCHED is also used to indicate if the qdisc is in
sd->output_queue, so it has to be atomic.
>
> Thanks, makes sense, so hopefully the MISSED-was-set case is not common
> and we can depend on __netif_schedule() to DTRT, avoiding the atomic op
> in the common case.
>
> .
>
Powered by blists - more mailing lists