From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: Re: [PATCH RFC] virtio_net: fix refill related races Date: Wed, 14 Dec 2011 15:54:12 -0800 Message-ID: <20111214235412.GA29835@google.com> References: <20111207152120.GA23417@redhat.com> <8739cvisqe.fsf@rustcorp.com.au> <20111211144428.GB14381@redhat.com> <878vmioh10.fsf@rustcorp.com.au> <20111212115405.GB7946@redhat.com> <87iplltd0g.fsf@rustcorp.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Amit Shah , netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, "Michael S. Tsirkin" To: Rusty Russell Return-path: Content-Disposition: inline In-Reply-To: <87iplltd0g.fsf@rustcorp.com.au> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: netdev.vger.kernel.org Hello, Rusty. On Tue, Dec 13, 2011 at 01:05:11PM +1030, Rusty Russell wrote: > Both places where we call: > > cancel_delayed_work_sync(&vi->refill); > > Do not actually guarantee that vi->refill isn't running, because it > can requeue itself. A 'bool no_more_refill' field seems like the > simplest fix for this, but I don't think it's sufficient. > > Tejun, is this correct? What's the correct way to synchronously stop a > delayed_work which can "schedule_delayed_work(&vi->refill, HZ/2);" on > itself? cancel_delayed_work_sync() itself should be good enough. It first steals the pending state and then waits for it to finish if in-flight. Queueing itself afterwards becomes noop. Thanks. -- tejun