All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: <netdev@vger.kernel.org>, <xen-devel@lists.xen.org>,
	Ian Campbell <ian.campbell@citrix.com>,
	Zoltan Kiss <zoltan.kiss@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:34:48 +0100	[thread overview]
Message-ID: <53E8D488.1020305@citrix.com> (raw)
In-Reply-To: <20140811143107.GH3249@zion.uk.xensource.com>

On 11/08/14 15:31, Wei Liu wrote:
> On Mon, Aug 11, 2014 at 02:58:13PM +0100, David Vrabel wrote:
>> On 11/08/14 14:48, Wei Liu wrote:
>>> On Mon, Aug 11, 2014 at 01:10:12PM +0100, David Vrabel wrote:
>>>> On 08/08/14 17:37, Wei Liu wrote:
>>> [...]
>>>>>  	if (tx_evtchn == rx_evtchn) {
>>>>>  		/* feature-split-event-channels == 0 */
>>>>> @@ -687,6 +700,9 @@ void xenvif_disconnect(struct xenvif *vif)
>>>>>  			queue->task = NULL;
>>>>>  		}
>>>>>  
>>>>> +		wait_event(queue->inflight_wq,
>>>>> +			   atomic_read(&queue->inflight_packets) == 0);
>>>>
>>>> Just make the dealloc task not stop unless it has deallocated all
>>>> outstanding requests.  There's no need for another wait queue here.
>>>>
>>>
>>> Are you suggesting something like
>>>
>>>   while (atomic_read(&queue->inflight_packets) !=0)
>>>   	schedule_timeout(SOME_TIMEOUT);
>>
>> No. That would be awful!
>>
>> Add the test to the kthread itself:
>>
>> int xenvif_dealloc_kthread(void *data)
>> {
>> 	struct xenvif_queue *queue = data;
>>
>> 	while (atomic_read(&queue->inflight_packets) > 0
>>                || !kthread_should_stop()) {
>>             [...]
>>
>> etc.
>>
>> Although, the main loop is a bit confused, so I suggest adding:
>>
>> static bool xenvif_dealloc_thread_should_stop(struct xenvif_queue *q)
>> {
>>     /* Dealloc thread must remain running if there are any inflight
>>      * packets so it can properly dealloc them when they complete.
>>      */
>>     return atomic_read(&queue->inflight_packets) == 0
>>         && kthread_should_stop();
>> }
>>
>> And cleaning it up a bit (the while() could be a for(;;)).
>>
> 
> Unfortunately this approach is bogus. If xenbus thread is not blocked it
> can free up various resources while dealloc thread is running -- queue
> can be gone under dealloc thread's feet.

kthread_stop() waits until the thread exits (like pthread_join()).

/**
 * kthread_stop - stop a thread created by kthread_create().
 * @k: thread created by kthread_create().
 *
 * Sets kthread_should_stop() for @k to return true, wakes it, and
 * waits for it to exit.

David

  parent reply	other threads:[~2014-08-11 14:34 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:37 ` 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 13:59             ` [Xen-devel] " David Vrabel
2014-08-11 14:08               ` Wei Liu
2014-08-11 14:08               ` Wei Liu
2014-08-11 13:43           ` 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:48     ` [Xen-devel] " 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 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:44           ` 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:34           ` David Vrabel [this message]
2014-08-11 14:39             ` [Xen-devel] " Wei Liu
2014-08-11 14:39             ` Wei Liu
2014-08-11 14:31         ` 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=53E8D488.1020305@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=netdev@vger.kernel.org \
    --cc=wei.liu2@citrix.com \
    --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.