From: Cong Wang <xiyou.wangcong@gmail.com>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: "Jakub Kicinski" <kuba@kernel.org>,
"David Miller" <davem@davemloft.net>,
"Vladimir Oltean" <olteanv@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andriin@fb.com>,
"Eric Dumazet" <edumazet@google.com>,
"Wei Wang" <weiwan@google.com>,
"Cong Wang ." <cong.wang@bytedance.com>,
"Taehee Yoo" <ap420073@gmail.com>,
"Linux Kernel Network Developers" <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linuxarm@openeuler.org, "Marc Kleine-Budde" <mkl@pengutronix.de>,
linux-can@vger.kernel.org, "Jamal Hadi Salim" <jhs@mojatatu.com>,
"Jiri Pirko" <jiri@resnulli.us>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
kpsingh@kernel.org, bpf <bpf@vger.kernel.org>,
"Jonas Bonn" <jonas.bonn@netrounds.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Michael Zhivich" <mzhivich@akamai.com>,
"Josh Hunt" <johunt@akamai.com>, "Jike Song" <albcamus@gmail.com>,
"Kehuan Feng" <kehuan.feng@gmail.com>,
"Ahmad Fatoum" <a.fatoum@pengutronix.de>,
atenart@kernel.org, "Alexander Duyck" <alexander.duyck@gmail.com>,
"Hillf Danton" <hdanton@sina.com>,
jgross@suse.com, JKosina@suse.com,
"Michal Kubecek" <mkubecek@suse.cz>,
"Björn Töpel" <bjorn@kernel.org>,
"Alexander Lobakin" <alobakin@pm.me>
Subject: Re: [PATCH net v8 1/3] net: sched: fix packet stuck problem for lockless qdisc
Date: Mon, 17 May 2021 17:49:25 -0700 [thread overview]
Message-ID: <CAM_iQpWSvbTzhj5+OFDaiMA+ARthRDb4iNrK37gzVYa3caGC+A@mail.gmail.com> (raw)
In-Reply-To: <def859b3-b6ea-7338-38eb-3f18ec3d60c2@huawei.com>
On Fri, May 14, 2021 at 7:25 PM Yunsheng Lin <linyunsheng@huawei.com> wrote:
>
> 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@kernel.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?
Nope, see the following:
// MISSED bit is already set
CPU0 CPU1
if (test_bit(MISSED) ( //true
if (test_bit(MISSED)) { // also true
clear_bit(MISSED);
do_something();
clear_bit(MISSED);
do_something();
}
}
Now do_something() is called twice instead of once. This may or may
not be a problem, hence I asked this question.
>
> >>
> >> 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.
If you replace the "do_something()" above with __netif_reschedule(),
this is exactly my point. An entry can not be inserted twice into a
list, hence it should never be called twice like above.
Thanks.
next prev parent reply other threads:[~2021-05-18 0:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 2:26 [PATCH net v8 0/3] fix packet stuck problem for lockless qdisc Yunsheng Lin
2021-05-14 2:26 ` [PATCH net v8 1/3] net: sched: " Yunsheng Lin
2021-05-14 23:36 ` Cong Wang
2021-05-14 23:39 ` Jakub Kicinski
2021-05-14 23:57 ` Cong Wang
2021-05-15 0:17 ` Jakub Kicinski
2021-05-15 2:25 ` Yunsheng Lin
2021-05-18 0:49 ` Cong Wang [this message]
2021-05-14 2:26 ` [PATCH net v8 2/3] net: sched: fix tx action rescheduling issue during deactivation Yunsheng Lin
2021-05-14 2:26 ` [PATCH net v8 3/3] net: sched: fix tx action reschedule issue with stopped queue Yunsheng Lin
2021-05-14 2:56 ` [PATCH net v8 0/3] fix packet stuck problem for lockless qdisc Yunsheng Lin
2021-05-14 3:16 Yunsheng Lin
2021-05-14 3:16 ` [PATCH net v8 1/3] net: sched: " Yunsheng Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAM_iQpWSvbTzhj5+OFDaiMA+ARthRDb4iNrK37gzVYa3caGC+A@mail.gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=JKosina@suse.com \
--cc=a.fatoum@pengutronix.de \
--cc=albcamus@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=alobakin@pm.me \
--cc=andrii@kernel.org \
--cc=andriin@fb.com \
--cc=ap420073@gmail.com \
--cc=ast@kernel.org \
--cc=atenart@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hdanton@sina.com \
--cc=jgross@suse.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=johunt@akamai.com \
--cc=jonas.bonn@netrounds.com \
--cc=kafai@fb.com \
--cc=kehuan.feng@gmail.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@openeuler.org \
--cc=linyunsheng@huawei.com \
--cc=mkl@pengutronix.de \
--cc=mkubecek@suse.cz \
--cc=mzhivich@akamai.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=songliubraving@fb.com \
--cc=weiwan@google.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).