From: Jakub Kicinski <kuba@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: "Yunsheng Lin" <linyunsheng@huawei.com>,
"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: Fri, 14 May 2021 17:17:59 -0700 [thread overview]
Message-ID: <20210514171759.5572c8f0@kicinski-fedora-PC1C0HJN> (raw)
In-Reply-To: <CAM_iQpXZNASp7+kA=OoCVbXuReAtOzHnqMn8kFUVfi9_qWe_kw@mail.gmail.com>
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
> }
>
> This is why __netif_schedule() uses test_and_set_bit() instead of
> test_bit()+set_bit().
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.
next prev parent reply other threads:[~2021-05-15 0:18 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 [this message]
2021-05-15 2:25 ` Yunsheng Lin
2021-05-18 0:49 ` Cong Wang
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=20210514171759.5572c8f0@kicinski-fedora-PC1C0HJN \
--to=kuba@kernel.org \
--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=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=xiyou.wangcong@gmail.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).