From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 566AF41CA9; Thu, 16 Feb 2023 02:30:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DE6442DC6; Thu, 16 Feb 2023 02:28:27 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id D78DD42D81 for ; Thu, 16 Feb 2023 02:28:18 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PHHMB6rWYzRq00; Thu, 16 Feb 2023 09:25:42 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Thu, 16 Feb 2023 09:28:17 +0800 Subject: Re: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback From: fengchengwen To: , , CC: , "Richardson, Bruce" , "Burakov, Anatoly" References: <20230213124452.46536-1-fengchengwen@huawei.com> Message-ID: <506fd32a-1d88-63fd-9fcb-c96a5b1b10b9@huawei.com> Date: Thu, 16 Feb 2023 09:28:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20230213124452.46536-1-fengchengwen@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org add cc maintainer On 2023/2/13 20:44, Chengwen Feng wrote: > The spinlock should unlock when clock_gettime() failed. This patch > fixes it by invoking clock_gettime() before lock. > > Fixes: 26021a715067 ("eal/bsd: support alarm API") > Cc: stable@dpdk.org > > Signed-off-by: Chengwen Feng > --- > lib/eal/freebsd/eal_alarm.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c > index 1023c32937..1a3e6c0aad 100644 > --- a/lib/eal/freebsd/eal_alarm.c > +++ b/lib/eal/freebsd/eal_alarm.c > @@ -171,12 +171,12 @@ eal_alarm_callback(void *arg __rte_unused) > struct timespec now; > struct alarm_entry *ap; > > - rte_spinlock_lock(&alarm_list_lk); > - ap = LIST_FIRST(&alarm_list); > - > if (clock_gettime(CLOCK_TYPE_ID, &now) < 0) > return; > > + rte_spinlock_lock(&alarm_list_lk); > + ap = LIST_FIRST(&alarm_list); > + > while (ap != NULL && timespec_cmp(&now, &ap->time) >= 0) { > ap->executing = 1; > ap->executing_id = pthread_self(); >