linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: Francesco Ruggeri <fruggeri@arista.com>
Cc: open list <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Taehee Yoo <ap420073@gmail.com>, Andrii Nakryiko <andriin@fb.com>,
	Jiri Pirko <jiri@mellanox.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH] net: make netdev_wait_allrefs wake-able
Date: Thu, 17 Sep 2020 08:51:45 +0200	[thread overview]
Message-ID: <CANn89iJOO9cbOqCNpRK4OrZy-L6P8aJJcPMjs5=RHF=fsjEe2Q@mail.gmail.com> (raw)
In-Reply-To: <CA+HUmGjX4_4_UXWNn=EehQ_3QtFPZq8RJU146r-nc0nA8apx7w@mail.gmail.com>

On Thu, Sep 17, 2020 at 8:33 AM Francesco Ruggeri <fruggeri@arista.com> wrote:
>
> >  static inline void dev_put(struct net_device *dev)
> >  {
> > +       struct task_struct *destroy_task = dev->destroy_task;
> > +
> >         this_cpu_dec(*dev->pcpu_refcnt);
> > +       if (destroy_task)
> > +               wake_up_process(destroy_task);
> >  }
>
> I just realized that this introduces a race, if dev_put drops the last
> reference, an already running netdev_wait_allrefs runs to completion
> and then dev_put tries to wake it up.
> Any suggestions on how to avoid this without resorting to
> locking?
>

Honestly I would not touch dev_put() at all.

Simply change the msleep(250) to something better, with maybe
exponential backoff.

  reply	other threads:[~2020-09-17  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17  2:00 [PATCH] net: make netdev_wait_allrefs wake-able Francesco Ruggeri
2020-09-17  6:33 ` Francesco Ruggeri
2020-09-17  6:51   ` Eric Dumazet [this message]
2020-09-17 16:17     ` Francesco Ruggeri

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='CANn89iJOO9cbOqCNpRK4OrZy-L6P8aJJcPMjs5=RHF=fsjEe2Q@mail.gmail.com' \
    --to=edumazet@google.com \
    --cc=andriin@fb.com \
    --cc=ap420073@gmail.com \
    --cc=ast@kernel.org \
    --cc=davem@davemloft.net \
    --cc=fruggeri@arista.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.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).