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 8CE2141C88; Mon, 13 Feb 2023 13:51:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F50640A81; Mon, 13 Feb 2023 13:51:03 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id A618F400D6 for ; Mon, 13 Feb 2023 13:51:01 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PFkfZ25QpznW8y; Mon, 13 Feb 2023 20:48:38 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) 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; Mon, 13 Feb 2023 20:50:56 +0800 From: Chengwen Feng To: , , CC: Subject: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback Date: Mon, 13 Feb 2023 12:44:52 +0000 Message-ID: <20230213124452.46536-1-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 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(); -- 2.17.1