DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal/bsd: fix spinlock not unlock in alarm callback
@ 2023-02-13 12:44 Chengwen Feng
  2023-02-16  1:28 ` fengchengwen
  0 siblings, 1 reply; 4+ messages in thread
From: Chengwen Feng @ 2023-02-13 12:44 UTC (permalink / raw)
  To: thomas, ferruh.yigit, andrew.rybchenko; +Cc: dev

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback
  2023-02-13 12:44 [PATCH] eal/bsd: fix spinlock not unlock in alarm callback Chengwen Feng
@ 2023-02-16  1:28 ` fengchengwen
  2023-02-16  9:22   ` Bruce Richardson
  0 siblings, 1 reply; 4+ messages in thread
From: fengchengwen @ 2023-02-16  1:28 UTC (permalink / raw)
  To: thomas, ferruh.yigit, andrew.rybchenko
  Cc: dev, Richardson, Bruce, Burakov, Anatoly

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 <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();
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback
  2023-02-16  1:28 ` fengchengwen
@ 2023-02-16  9:22   ` Bruce Richardson
  2023-02-19 22:27     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Richardson @ 2023-02-16  9:22 UTC (permalink / raw)
  To: fengchengwen
  Cc: thomas, ferruh.yigit, andrew.rybchenko, dev, Burakov, Anatoly

On Thu, Feb 16, 2023 at 09:28:17AM +0800, fengchengwen wrote:
> 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 <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();
> > 

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] eal/bsd: fix spinlock not unlock in alarm callback
  2023-02-16  9:22   ` Bruce Richardson
@ 2023-02-19 22:27     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2023-02-19 22:27 UTC (permalink / raw)
  To: fengchengwen
  Cc: ferruh.yigit, andrew.rybchenko, dev, Burakov, Anatoly, Bruce Richardson

16/02/2023 10:22, Bruce Richardson:
> On Thu, Feb 16, 2023 at 09:28:17AM +0800, fengchengwen wrote:
> > 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 <fengchengwen@huawei.com>
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-19 22:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 12:44 [PATCH] eal/bsd: fix spinlock not unlock in alarm callback Chengwen Feng
2023-02-16  1:28 ` fengchengwen
2023-02-16  9:22   ` Bruce Richardson
2023-02-19 22:27     ` Thomas Monjalon

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).