netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Amit Shah <amit.shah@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH RFC] virtio_net: fix refill related races
Date: Mon, 12 Dec 2011 13:54:06 +0200	[thread overview]
Message-ID: <20111212115405.GB7946@redhat.com> (raw)
In-Reply-To: <878vmioh10.fsf@rustcorp.com.au>

On Mon, Dec 12, 2011 at 09:25:07AM +1030, Rusty Russell wrote:
> On Sun, 11 Dec 2011 16:44:29 +0200, "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > On Thu, Dec 08, 2011 at 03:07:29PM +1030, Rusty Russell wrote:
> > > On Wed, 7 Dec 2011 17:21:22 +0200, "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > > > Fix theoretical races related to refill work:
> > > > 1. After napi is disabled by ndo_stop, refill work
> > > >    can run and re-enable it.
> > > > 2. Refill can reschedule itself, if this happens
> > > >    it can run after cancel_delayed_work_sync,
> > > >    and will access device after it is destroyed.
> > > > 
> > > > As a solution, add flags to track napi state and
> > > > to disable refill, and toggle them on start, stop
> > > > and remove; check these flags on refill.
> > > 
> > > Why isn't a "dont-readd" flag sufficient?
> > > 
> > > Cheers,
> > > Rusty.
> > 
> > I started with that, but here's the problem I wanted to
> > address:
> > 
> > - we run out of descriptors and schedule refill work
> > - ndo_close runs
> > - refill work runs
> > - ndo_open runs
> 
> (s/ndo_close/ndo_stop/)
> 
> You don't think we should do any refills on a closed device?  If so, we
> simply move the refill-stop code into ndo_stop (aka virtnet_close), and
> the refill-start code into ndo_open (aka. virtnet_open).  Right?

We can do that, yes. We'll have to also cancel work if outstanding.
It seems a bigger change though. I'm especially concerned
about putting refill-start in virtnet_open, suddenly
it's always running where it used to only run after
we have consumed some buffers. I'm just concerned about
doing big changes that late in release cycle but maybe
that's OK.

> Orthogonally, the refill-stop code is still buggy, as you noted.

Sorry I don't understand how it's still buggy.

>  And
> for self-rearming timers the pattern I've always used is a flag.
> 
> Or am I being obtuse again? :)
> Rusty.

  reply	other threads:[~2011-12-12 11:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 15:21 [PATCH RFC] virtio_net: fix refill related races Michael S. Tsirkin
2011-12-08  4:37 ` Rusty Russell
2011-12-11 14:44   ` Michael S. Tsirkin
2011-12-11 22:55     ` Rusty Russell
2011-12-12 11:54       ` Michael S. Tsirkin [this message]
2011-12-13  2:35         ` Rusty Russell
2011-12-14 23:54           ` Tejun Heo
2011-12-20 19:09           ` Michael S. Tsirkin
2011-12-20 19:09             ` Tejun Heo
2011-12-20 19:30               ` Michael S. Tsirkin
2011-12-20 19:31                 ` Tejun Heo
2011-12-20 19:45                   ` Michael S. Tsirkin
2011-12-20 23:43                     ` Rusty Russell
2011-12-21  9:06                       ` Michael S. Tsirkin
2011-12-22  3:53                         ` Rusty Russell

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=20111212115405.GB7946@redhat.com \
    --to=mst@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.linux-foundation.org \
    /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).