All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Zoltan Kiss <zoltan.kiss@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>,
	Wei Liu <wei.liu2@citrix.com>, <netdev@vger.kernel.org>,
	<xen-devel@lists.xen.org>, Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [Xen-devel] [PATCH net v2 2/3] xen-netback: don't stop dealloc kthread too early
Date: Mon, 11 Aug 2014 15:44:41 +0100	[thread overview]
Message-ID: <20140811144440.GJ3249@zion.uk.xensource.com> (raw)
In-Reply-To: <53E8CF95.5050209@citrix.com>

On Mon, Aug 11, 2014 at 03:13:41PM +0100, Zoltan Kiss wrote:
[...]
> > And cleaning it up a bit (the while() could be a for(;;)).
> 
> I would recommend this:
> ---
> @@ -2066,7 +2066,7 @@ int xenvif_dealloc_kthread(void *data)
>  		wait_event_interruptible(queue->dealloc_wq,
>  					 tx_dealloc_work_todo(queue) ||
>  					 kthread_should_stop());
> -		if (kthread_should_stop())
> +		if (kthread_should_stop() && !atomic_read(&queue->inflight_packets))
>  			break;
>  
>  		xenvif_tx_dealloc_action(queue);
> ---
> If kthread_stop called, this will keep the main loop running until all callbacks are called.
> Then it proceeds to the exit branch, otherwise doesn't disrupt normal operation.

This snippet lacks change to while().

I would generally go for a shorter solution if the code is
self-explanatory.

@@ -2078,21 +2066,19 @@ int xenvif_dealloc_kthread(void *data)
 {
        struct xenvif_queue *queue = data;
 
-       while (!kthread_should_stop()) {
+       for (;;) {
                wait_event_interruptible(queue->dealloc_wq,
                                         tx_dealloc_work_todo(queue) ||
                                         kthread_should_stop());
-               if (kthread_should_stop())
+               if (kthread_should_stop() &&
+                   !atomic_read(&queue->inflight_packets) &&
+                   !tx_dealloc_work_todo(queue))
                        break;
 
                xenvif_tx_dealloc_action(queue);
                cond_resched();
        }
 
-       /* Unmap anything remaining*/
-       if (tx_dealloc_work_todo(queue))
-               xenvif_tx_dealloc_action(queue);
-
        return 0;
 }
 

  parent reply	other threads:[~2014-08-11 14:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08 16:37 [PATCH net v2 0/3] xen-netback: synchronisation between core driver and netback Wei Liu
2014-08-08 16:37 ` [PATCH net v2 1/3] xen-netback: move NAPI add/remove calls Wei Liu
2014-08-08 16:49   ` Sergei Shtylyov
2014-08-08 16:49   ` Sergei Shtylyov
2014-08-08 16:52     ` Wei Liu
2014-08-08 16:52     ` Wei Liu
2014-08-11 12:35   ` David Vrabel
2014-08-11 12:35   ` [Xen-devel] " David Vrabel
2014-08-11 12:49     ` Zoltan Kiss
2014-08-11 12:49     ` [Xen-devel] " Zoltan Kiss
2014-08-11 13:01       ` David Vrabel
2014-08-11 13:01       ` [Xen-devel] " David Vrabel
2014-08-11 13:14         ` Zoltan Kiss
2014-08-11 13:14         ` [Xen-devel] " Zoltan Kiss
2014-08-11 13:43           ` Wei Liu
2014-08-11 13:59             ` David Vrabel
2014-08-11 14:08               ` Wei Liu
2014-08-11 14:08               ` Wei Liu
2014-08-11 13:59             ` David Vrabel
2014-08-11 13:43           ` Wei Liu
2014-08-08 16:37 ` Wei Liu
2014-08-08 16:37 ` [PATCH net v2 2/3] xen-netback: don't stop dealloc kthread too early Wei Liu
2014-08-11 12:10   ` David Vrabel
2014-08-11 12:10   ` [Xen-devel] " David Vrabel
2014-08-11 13:48     ` Wei Liu
2014-08-11 13:58       ` David Vrabel
2014-08-11 13:58       ` [Xen-devel] " David Vrabel
2014-08-11 14:13         ` Zoltan Kiss
2014-08-11 14:44           ` Wei Liu
2014-08-11 14:44           ` Wei Liu [this message]
2014-08-11 15:23             ` David Vrabel
2014-08-11 15:23             ` [Xen-devel] " David Vrabel
2014-08-11 20:39               ` Wei Liu
2014-08-11 20:39               ` [Xen-devel] " Wei Liu
2014-08-11 14:13         ` Zoltan Kiss
2014-08-11 14:31         ` [Xen-devel] " Wei Liu
2014-08-11 14:34           ` David Vrabel
2014-08-11 14:39             ` Wei Liu
2014-08-11 14:39             ` Wei Liu
2014-08-11 14:34           ` David Vrabel
2014-08-11 14:31         ` Wei Liu
2014-08-11 13:48     ` Wei Liu
2014-08-08 16:37 ` Wei Liu
2014-08-08 16:37 ` [PATCH net v2 3/3] xen-netback: remove loop waiting function Wei Liu
2014-08-08 16:37 ` Wei Liu

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=20140811144440.GJ3249@zion.uk.xensource.com \
    --to=wei.liu2@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=netdev@vger.kernel.org \
    --cc=xen-devel@lists.xen.org \
    --cc=zoltan.kiss@citrix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.