From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 5CB19A09E4;
	Thu, 21 Jan 2021 11:46:19 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id CE4AD140CF7;
	Thu, 21 Jan 2021 11:46:18 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [216.205.24.124])
 by mails.dpdk.org (Postfix) with ESMTP id F071E140CEF
 for <dev@dpdk.org>; Thu, 21 Jan 2021 11:46:16 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1611225976;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=4Wz/adDg9K9SE9zdVKdfBQF5+QFBwLHqy3FOLLWJ9lw=;
 b=ij7in+PeJ4ybbkS/2IUxzJqK5UoXH+VXXzETzOInPv2On8m33Aj8aPpagHudU+4w8LdxOP
 u9TN01fb0NSuCqgT1qFMzVBqBEd6++qx9zXypxCtzDOLN20TSK620xXeeIOfr3guA3XZVT
 4ZUhlDOWwJDusZOf3DKKPMjBed/90/4=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
 [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id
 us-mta-91-mU5TrYB3Mwy6ZYKlNFIeJQ-1; Thu, 21 Jan 2021 05:46:14 -0500
X-MC-Unique: mU5TrYB3Mwy6ZYKlNFIeJQ-1
Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com
 [10.5.11.14])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A176E743;
 Thu, 21 Jan 2021 10:46:13 +0000 (UTC)
Received: from [10.36.110.29] (unknown [10.36.110.29])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id 132FC5D9D5;
 Thu, 21 Jan 2021 10:46:08 +0000 (UTC)
To: Matan Azrad <matan@nvidia.com>, David Marchand <david.marchand@redhat.com>
Cc: dev <dev@dpdk.org>, dpdk stable <stable@dpdk.org>
References: <1609915409-272126-1-git-send-email-matan@nvidia.com>
 <746e905a-c394-44df-2c49-2afd59c05d9f@redhat.com>
 <CAJFAV8zi8aYPryqA2W4XUH9O-wxP=8RKGB3F=6+7dVyjmrRa9Q@mail.gmail.com>
 <CAJFAV8xbtAPrZdv4kJcUs85fDdfAvRpmnsdGP=C0DAYsWbbzFw@mail.gmail.com>
 <MW2PR12MB24924AA868DBA3ACB1103513DFA80@MW2PR12MB2492.namprd12.prod.outlook.com>
 <1052520c-61e9-2135-bbad-9d009f52ce4b@redhat.com>
 <MW2PR12MB24925426B28403DD6BE92BB1DFA80@MW2PR12MB2492.namprd12.prod.outlook.com>
 <1c1fdabf-2588-2fd7-f5c4-dcb4e029ac35@redhat.com>
 <MW2PR12MB249203CB1495DD64F04A2689DFA80@MW2PR12MB2492.namprd12.prod.outlook.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
Message-ID: <c574b1ba-10d5-3fa6-c3bb-5300758114ae@redhat.com>
Date: Thu, 21 Jan 2021 11:46:07 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.6.0
MIME-Version: 1.0
In-Reply-To: <MW2PR12MB249203CB1495DD64F04A2689DFA80@MW2PR12MB2492.namprd12.prod.outlook.com>
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] vdpa/mlx5: fix configuration
 mutex cleanup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>



On 1/14/21 4:23 PM, Matan Azrad wrote:
> 
> 
> From: Maxime Coquelin
>> On 1/14/21 2:09 PM, Matan Azrad wrote:
>>>
>>>
>>> From: Maxime Coquelin
>>>> Hi Matan,
>>>>
>>>> On 1/14/21 12:49 PM, Matan Azrad wrote:
>>>>> Hi Maxime and David
>>>>>
>>>>> Thank you for Review.
>>>>>
>>>>> From: David Marchand
>>>>>> On Fri, Jan 8, 2021 at 9:48 AM David Marchand
>>>>>> <david.marchand@redhat.com> wrote:
>>>>>>>> I wonder if it would be possible and cleaner to disable
>>>>>>>> cancellation on the thread while the mutex is held?
>>>>>
>>>>> Yes, we can cause thread to return by some global variable sync.
>>>>> It is the same logic.
>>>>
>>>> No, that was not my suggestion. My suggestion is to block the thread
>>>> cancellation while in the critical section, using pthread_setcancelstate().
>>>
>>> Yes, Generally it is better to let the thread control his cancellation, either
>> cancel itself or enabling\disabling cancellations.
>>>
>>> I don't see a reason to wait for the thread in current logic - the critical section
>> is not important to be completed here.
>>
>> The reason I see is there are quite a few things done in this critical section. And
>> if tomorrow someone add new things in it, he may not know the thread can be
>> cancelled at any time, which could cause hard to debug issues.
> 
> As I said, here it is not needed, this thread designed just to cause guest notifications.
> 
> The optional future developer mistake can be done also outside the critical section in in any other place - we cannot protect it.
> 
> The design choice is to close the thread fast.

But why is it so urgent that it cannot been stopped cleanly?
I don't think it would add seconds delay by doing it in a clean way.

Thanks,
Maxime

>>> We just want to close the thread and to clean the mutex.
>>>
>>>>>>> +1
>>>>>>
>>>>>> IEEE Std 1003.1-2001/Cor 2-2004, item XBD/TC2/D6/26 is applied,
>>>>>> adding pthread_t to the list of types that are not required to be
>>>>>> arithmetic types, thus allowing pthread_t to be defined as a structure.
>>>>>>
>>>>>> It would be better to leave pthread_t alone and not interpret it:
>>>>>>
>>>>>> if (priv->timer_tid) {
>>>>>>     pthread_cancel(priv->timer_tid);
>>>>>>     pthread_join(priv->timer_tid, &status); }
>>>>>> priv->timer_tid = 0;
>>>>>
>>>>>
>>>>> I'm not sure why you think it is better in this specific case.
>>>>> The cancellation will close the thread in faster way, no need to
>>>>> wait for the
>>>> thread to close itself.
>>>>>
>>>>>
>>>>>>
>>>>>> --
>>>>>> David Marchand
>>>>>
>>>
>