From: Chengwen Feng <fengchengwen@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@amd.com>,
<andrew.rybchenko@oktetlabs.ru>
Cc: <dev@dpdk.org>
Subject: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback
Date: Mon, 13 Feb 2023 12:44:52 +0000 [thread overview]
Message-ID: <20230213124452.46536-1-fengchengwen@huawei.com> (raw)
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 <fengchengwen@huawei.com>
---
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
next reply other threads:[~2023-02-13 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 12:44 Chengwen Feng [this message]
2023-02-16 1:28 ` fengchengwen
2023-02-16 9:22 ` Bruce Richardson
2023-02-19 22:27 ` Thomas Monjalon
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=20230213124452.46536-1-fengchengwen@huawei.com \
--to=fengchengwen@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=thomas@monjalon.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).