linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francesco Ruggeri <fruggeri@arista.com>
To: open list <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>,
	xiyou.wangcong@gmail.com, ap420073@gmail.com, andriin@fb.com,
	Eric Dumazet <edumazet@google.com>,
	jiri@mellanox.com, ast@kernel.org,
	Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>,
	Francesco Ruggeri <fruggeri@arista.com>
Subject: Re: [PATCH] net: make netdev_wait_allrefs wake-able
Date: Wed, 16 Sep 2020 23:33:21 -0700	[thread overview]
Message-ID: <CA+HUmGjX4_4_UXWNn=EehQ_3QtFPZq8RJU146r-nc0nA8apx7w@mail.gmail.com> (raw)
In-Reply-To: <20200917020021.0860995C06B9@us180.sjc.aristanetworks.com>

>  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?

Thanks,
Francesco

  reply	other threads:[~2020-09-17  6:33 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 [this message]
2020-09-17  6:51   ` Eric Dumazet
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='CA+HUmGjX4_4_UXWNn=EehQ_3QtFPZq8RJU146r-nc0nA8apx7w@mail.gmail.com' \
    --to=fruggeri@arista.com \
    --cc=andriin@fb.com \
    --cc=ap420073@gmail.com \
    --cc=ast@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.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).