DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
@ 2019-06-26 10:40 Thomas Monjalon
  2019-06-26 11:20 ` David Marchand
  2019-06-26 14:02 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
  0 siblings, 2 replies; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-26 10:40 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, stable

When adding an alarm, if an error happen when registering
the common alarm callback, it is not considered as a major failure.
The alarm is then inserted in the list.
However it was returning an error code after inserting the alarm.

The error code is reset to 0 so the behaviour and the return code
are consistent.
Other return code related lines are cleaned up for easier understanding.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/linux/eal/eal_alarm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal_alarm.c b/lib/librte_eal/linux/eal/eal_alarm.c
index 840ede780..d6d70e8c3 100644
--- a/lib/librte_eal/linux/eal/eal_alarm.c
+++ b/lib/librte_eal/linux/eal/eal_alarm.c
@@ -137,9 +137,13 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_lock(&alarm_list_lk);
 	if (!handler_registered) {
-		ret |= rte_intr_callback_register(&intr_handle,
+		ret = rte_intr_callback_register(&intr_handle,
 				eal_alarm_callback, NULL);
-		handler_registered = (ret == 0) ? 1 : 0;
+		if (ret == 0)
+			handler_registered = 1;
+		else
+			/* not fatal, callback can be registered later */
+			ret = 0;
 	}
 
 	if (LIST_EMPTY(&alarm_list))
-- 
2.21.0


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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 10:40 [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure Thomas Monjalon
@ 2019-06-26 11:20 ` David Marchand
  2019-06-26 11:36   ` Thomas Monjalon
  2019-06-26 14:02 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
  1 sibling, 1 reply; 12+ messages in thread
From: David Marchand @ 2019-06-26 11:20 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, dpdk stable

On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
wrote:

> When adding an alarm, if an error happen when registering
> the common alarm callback, it is not considered as a major failure.
> The alarm is then inserted in the list.
> However it was returning an error code after inserting the alarm.
>
> The error code is reset to 0 so the behaviour and the return code
> are consistent.
> Other return code related lines are cleaned up for easier understanding.
>
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  lib/librte_eal/linux/eal/eal_alarm.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/linux/eal/eal_alarm.c
> b/lib/librte_eal/linux/eal/eal_alarm.c
> index 840ede780..d6d70e8c3 100644
> --- a/lib/librte_eal/linux/eal/eal_alarm.c
> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> @@ -137,9 +137,13 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback
> cb_fn, void *cb_arg)
>
>         rte_spinlock_lock(&alarm_list_lk);
>         if (!handler_registered) {
> -               ret |= rte_intr_callback_register(&intr_handle,
> +               ret = rte_intr_callback_register(&intr_handle,
>                                 eal_alarm_callback, NULL);
> -               handler_registered = (ret == 0) ? 1 : 0;
> +               if (ret == 0)
> +                       handler_registered = 1;
> +               else
> +                       /* not fatal, callback can be registered later */
> +                       ret = 0;
>         }
>
>         if (LIST_EMPTY(&alarm_list))
>

Well, then it means that you don't want to touch ret at all.
How about:
if (rte_intr_callback_register(&intr_handle,
                               eal_alarm_callback, NULL) == 0)
        handler_registered = 1;

?


-- 
David Marchand

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 11:20 ` David Marchand
@ 2019-06-26 11:36   ` Thomas Monjalon
  2019-06-26 11:39     ` David Marchand
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-26 11:36 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

26/06/2019 13:20, David Marchand:
> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
> wrote:
> 
> > When adding an alarm, if an error happen when registering
> > the common alarm callback, it is not considered as a major failure.
> > The alarm is then inserted in the list.
> > However it was returning an error code after inserting the alarm.
> >
> > The error code is reset to 0 so the behaviour and the return code
> > are consistent.
> > Other return code related lines are cleaned up for easier understanding.
> >
[...]
> > --- a/lib/librte_eal/linux/eal/eal_alarm.c
> > +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> >         if (!handler_registered) {
> > -               ret |= rte_intr_callback_register(&intr_handle,
> > +               ret = rte_intr_callback_register(&intr_handle,
> >                                 eal_alarm_callback, NULL);
> > -               handler_registered = (ret == 0) ? 1 : 0;
> > +               if (ret == 0)
> > +                       handler_registered = 1;
> > +               else
> > +                       /* not fatal, callback can be registered later */
> > +                       ret = 0;
> >         }
> 
> Well, then it means that you don't want to touch ret at all.
> How about:
> if (rte_intr_callback_register(&intr_handle,
>                                eal_alarm_callback, NULL) == 0)
>         handler_registered = 1;
> 
> ?

Too much simple :)

I think we try to avoid calling a function in a "if"
per coding style.
And my proposal has the benefit of offering a comment
about the non-fatal error.

After saying these arguments, I have to say I have no strong opinion :)
I'm fine either way.



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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 11:36   ` Thomas Monjalon
@ 2019-06-26 11:39     ` David Marchand
  2019-06-26 11:43       ` Burakov, Anatoly
  0 siblings, 1 reply; 12+ messages in thread
From: David Marchand @ 2019-06-26 11:39 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:

> 26/06/2019 13:20, David Marchand:
> > On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
> > wrote:
> >
> > > When adding an alarm, if an error happen when registering
> > > the common alarm callback, it is not considered as a major failure.
> > > The alarm is then inserted in the list.
> > > However it was returning an error code after inserting the alarm.
> > >
> > > The error code is reset to 0 so the behaviour and the return code
> > > are consistent.
> > > Other return code related lines are cleaned up for easier
> understanding.
> > >
> [...]
> > > --- a/lib/librte_eal/linux/eal/eal_alarm.c
> > > +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> > >         if (!handler_registered) {
> > > -               ret |= rte_intr_callback_register(&intr_handle,
> > > +               ret = rte_intr_callback_register(&intr_handle,
> > >                                 eal_alarm_callback, NULL);
> > > -               handler_registered = (ret == 0) ? 1 : 0;
> > > +               if (ret == 0)
> > > +                       handler_registered = 1;
> > > +               else
> > > +                       /* not fatal, callback can be registered later
> */
> > > +                       ret = 0;
> > >         }
> >
> > Well, then it means that you don't want to touch ret at all.
> > How about:
> > if (rte_intr_callback_register(&intr_handle,
> >                                eal_alarm_callback, NULL) == 0)
> >         handler_registered = 1;
> >
> > ?
>
> Too much simple :)
>
> I think we try to avoid calling a function in a "if"
> per coding style.
> And my proposal has the benefit of offering a comment
> about the non-fatal error.
>

/* not fatal, callback can be registered later */
if (rte_intr_callback_register(&intr_handle,
                              eal_alarm_callback, NULL) == 0)
       handler_registered = 1;



> After saying these arguments, I have to say I have no strong opinion :)
> I'm fine either way.
>

Reviewed-by: David Marchand <david.marchand@redhat.com>
I won't insist either, if you feel like taking my proposal, you can keep
the reviewed-by token.


-- 
David Marchand

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 11:39     ` David Marchand
@ 2019-06-26 11:43       ` Burakov, Anatoly
  2019-06-26 11:55         ` Thomas Monjalon
  0 siblings, 1 reply; 12+ messages in thread
From: Burakov, Anatoly @ 2019-06-26 11:43 UTC (permalink / raw)
  To: David Marchand, Thomas Monjalon; +Cc: dev

On 26-Jun-19 12:39 PM, David Marchand wrote:
> On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> 
>> 26/06/2019 13:20, David Marchand:
>>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
>>> wrote:
>>>
>>>> When adding an alarm, if an error happen when registering
>>>> the common alarm callback, it is not considered as a major failure.
>>>> The alarm is then inserted in the list.
>>>> However it was returning an error code after inserting the alarm.
>>>>
>>>> The error code is reset to 0 so the behaviour and the return code
>>>> are consistent.
>>>> Other return code related lines are cleaned up for easier
>> understanding.
>>>>
>> [...]
>>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c
>>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
>>>>          if (!handler_registered) {
>>>> -               ret |= rte_intr_callback_register(&intr_handle,
>>>> +               ret = rte_intr_callback_register(&intr_handle,
>>>>                                  eal_alarm_callback, NULL);
>>>> -               handler_registered = (ret == 0) ? 1 : 0;
>>>> +               if (ret == 0)
>>>> +                       handler_registered = 1;
>>>> +               else
>>>> +                       /* not fatal, callback can be registered later
>> */
>>>> +                       ret = 0;
>>>>          }
>>>
>>> Well, then it means that you don't want to touch ret at all.
>>> How about:
>>> if (rte_intr_callback_register(&intr_handle,
>>>                                 eal_alarm_callback, NULL) == 0)
>>>          handler_registered = 1;
>>>
>>> ?
>>
>> Too much simple :)
>>
>> I think we try to avoid calling a function in a "if"
>> per coding style.
>> And my proposal has the benefit of offering a comment
>> about the non-fatal error.
>>
> 
> /* not fatal, callback can be registered later */
> if (rte_intr_callback_register(&intr_handle,
>                                eal_alarm_callback, NULL) == 0)
>         handler_registered = 1;
> 

I prefer the original. It's more explicit and conveys the intention 
better. Did i break the tie? :)

-- 
Thanks,
Anatoly

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 11:43       ` Burakov, Anatoly
@ 2019-06-26 11:55         ` Thomas Monjalon
  2019-06-26 12:36           ` Bruce Richardson
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-26 11:55 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: David Marchand, dev

26/06/2019 13:43, Burakov, Anatoly:
> On 26-Jun-19 12:39 PM, David Marchand wrote:
> > On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > 
> >> 26/06/2019 13:20, David Marchand:
> >>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
> >>> wrote:
> >>>
> >>>> When adding an alarm, if an error happen when registering
> >>>> the common alarm callback, it is not considered as a major failure.
> >>>> The alarm is then inserted in the list.
> >>>> However it was returning an error code after inserting the alarm.
> >>>>
> >>>> The error code is reset to 0 so the behaviour and the return code
> >>>> are consistent.
> >>>> Other return code related lines are cleaned up for easier
> >> understanding.
> >>>>
> >> [...]
> >>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c
> >>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> >>>>          if (!handler_registered) {
> >>>> -               ret |= rte_intr_callback_register(&intr_handle,
> >>>> +               ret = rte_intr_callback_register(&intr_handle,
> >>>>                                  eal_alarm_callback, NULL);
> >>>> -               handler_registered = (ret == 0) ? 1 : 0;
> >>>> +               if (ret == 0)
> >>>> +                       handler_registered = 1;
> >>>> +               else
> >>>> +                       /* not fatal, callback can be registered later
> >> */
> >>>> +                       ret = 0;
> >>>>          }
> >>>
> >>> Well, then it means that you don't want to touch ret at all.
> >>> How about:
> >>> if (rte_intr_callback_register(&intr_handle,
> >>>                                 eal_alarm_callback, NULL) == 0)
> >>>          handler_registered = 1;
> >>>
> >>> ?
> >>
> >> Too much simple :)
> >>
> >> I think we try to avoid calling a function in a "if"
> >> per coding style.
> >> And my proposal has the benefit of offering a comment
> >> about the non-fatal error.
> >>
> > 
> > /* not fatal, callback can be registered later */
> > if (rte_intr_callback_register(&intr_handle,
> >                                eal_alarm_callback, NULL) == 0)
> >         handler_registered = 1;
> > 
> 
> I prefer the original. It's more explicit and conveys the intention 
> better. Did i break the tie? :)

I was going to send a v2 with David's suggestion.
Now I'm confused.




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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 11:55         ` Thomas Monjalon
@ 2019-06-26 12:36           ` Bruce Richardson
  2019-06-26 12:52             ` Burakov, Anatoly
  0 siblings, 1 reply; 12+ messages in thread
From: Bruce Richardson @ 2019-06-26 12:36 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Burakov, Anatoly, David Marchand, dev

On Wed, Jun 26, 2019 at 01:55:53PM +0200, Thomas Monjalon wrote:
> 26/06/2019 13:43, Burakov, Anatoly:
> > On 26-Jun-19 12:39 PM, David Marchand wrote:
> > > On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> > > 
> > >> 26/06/2019 13:20, David Marchand:
> > >>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
> > >>> wrote:
> > >>>
> > >>>> When adding an alarm, if an error happen when registering
> > >>>> the common alarm callback, it is not considered as a major failure.
> > >>>> The alarm is then inserted in the list.
> > >>>> However it was returning an error code after inserting the alarm.
> > >>>>
> > >>>> The error code is reset to 0 so the behaviour and the return code
> > >>>> are consistent.
> > >>>> Other return code related lines are cleaned up for easier
> > >> understanding.
> > >>>>
> > >> [...]
> > >>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c
> > >>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> > >>>>          if (!handler_registered) {
> > >>>> -               ret |= rte_intr_callback_register(&intr_handle,
> > >>>> +               ret = rte_intr_callback_register(&intr_handle,
> > >>>>                                  eal_alarm_callback, NULL);
> > >>>> -               handler_registered = (ret == 0) ? 1 : 0;
> > >>>> +               if (ret == 0)
> > >>>> +                       handler_registered = 1;
> > >>>> +               else
> > >>>> +                       /* not fatal, callback can be registered later
> > >> */
> > >>>> +                       ret = 0;
> > >>>>          }
> > >>>
> > >>> Well, then it means that you don't want to touch ret at all.
> > >>> How about:
> > >>> if (rte_intr_callback_register(&intr_handle,
> > >>>                                 eal_alarm_callback, NULL) == 0)
> > >>>          handler_registered = 1;
> > >>>
> > >>> ?
> > >>
> > >> Too much simple :)
> > >>
> > >> I think we try to avoid calling a function in a "if"
> > >> per coding style.
> > >> And my proposal has the benefit of offering a comment
> > >> about the non-fatal error.
> > >>
> > > 
> > > /* not fatal, callback can be registered later */
> > > if (rte_intr_callback_register(&intr_handle,
> > >                                eal_alarm_callback, NULL) == 0)
> > >         handler_registered = 1;
> > > 
> > 
> > I prefer the original. It's more explicit and conveys the intention 
> > better. Did i break the tie? :)
> 
> I was going to send a v2 with David's suggestion.
> Now I'm confused.
> 
I always tend to prefer shorter versions, so +1 for v2 (does that make it a
v3? :-) )

/Bruce

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 12:36           ` Bruce Richardson
@ 2019-06-26 12:52             ` Burakov, Anatoly
  2019-06-26 13:20               ` Thomas Monjalon
  0 siblings, 1 reply; 12+ messages in thread
From: Burakov, Anatoly @ 2019-06-26 12:52 UTC (permalink / raw)
  To: Bruce Richardson, Thomas Monjalon; +Cc: David Marchand, dev

On 26-Jun-19 1:36 PM, Bruce Richardson wrote:
> On Wed, Jun 26, 2019 at 01:55:53PM +0200, Thomas Monjalon wrote:
>> 26/06/2019 13:43, Burakov, Anatoly:
>>> On 26-Jun-19 12:39 PM, David Marchand wrote:
>>>> On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>>>>
>>>>> 26/06/2019 13:20, David Marchand:
>>>>>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
>>>>>> wrote:
>>>>>>
>>>>>>> When adding an alarm, if an error happen when registering
>>>>>>> the common alarm callback, it is not considered as a major failure.
>>>>>>> The alarm is then inserted in the list.
>>>>>>> However it was returning an error code after inserting the alarm.
>>>>>>>
>>>>>>> The error code is reset to 0 so the behaviour and the return code
>>>>>>> are consistent.
>>>>>>> Other return code related lines are cleaned up for easier
>>>>> understanding.
>>>>>>>
>>>>> [...]
>>>>>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c
>>>>>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
>>>>>>>           if (!handler_registered) {
>>>>>>> -               ret |= rte_intr_callback_register(&intr_handle,
>>>>>>> +               ret = rte_intr_callback_register(&intr_handle,
>>>>>>>                                   eal_alarm_callback, NULL);
>>>>>>> -               handler_registered = (ret == 0) ? 1 : 0;
>>>>>>> +               if (ret == 0)
>>>>>>> +                       handler_registered = 1;
>>>>>>> +               else
>>>>>>> +                       /* not fatal, callback can be registered later
>>>>> */
>>>>>>> +                       ret = 0;
>>>>>>>           }
>>>>>>
>>>>>> Well, then it means that you don't want to touch ret at all.
>>>>>> How about:
>>>>>> if (rte_intr_callback_register(&intr_handle,
>>>>>>                                  eal_alarm_callback, NULL) == 0)
>>>>>>           handler_registered = 1;
>>>>>>
>>>>>> ?
>>>>>
>>>>> Too much simple :)
>>>>>
>>>>> I think we try to avoid calling a function in a "if"
>>>>> per coding style.
>>>>> And my proposal has the benefit of offering a comment
>>>>> about the non-fatal error.
>>>>>
>>>>
>>>> /* not fatal, callback can be registered later */
>>>> if (rte_intr_callback_register(&intr_handle,
>>>>                                 eal_alarm_callback, NULL) == 0)
>>>>          handler_registered = 1;
>>>>
>>>
>>> I prefer the original. It's more explicit and conveys the intention
>>> better. Did i break the tie? :)
>>
>> I was going to send a v2 with David's suggestion.
>> Now I'm confused.
>>
> I always tend to prefer shorter versions, so +1 for v2 (does that make it a
> v3? :-) )
> 
> /Bruce
> 

OK, but then the suggested comment needs to be fixed. It makes it seem 
like registering the handler is the "non fatal" part. Perhaps something 
like:

/* failed register is not a fatal error - callback can be registered 
later */

-- 
Thanks,
Anatoly

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

* Re: [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure
  2019-06-26 12:52             ` Burakov, Anatoly
@ 2019-06-26 13:20               ` Thomas Monjalon
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-26 13:20 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: Bruce Richardson, David Marchand, dev

26/06/2019 14:52, Burakov, Anatoly:
> On 26-Jun-19 1:36 PM, Bruce Richardson wrote:
> > On Wed, Jun 26, 2019 at 01:55:53PM +0200, Thomas Monjalon wrote:
> >> 26/06/2019 13:43, Burakov, Anatoly:
> >>> On 26-Jun-19 12:39 PM, David Marchand wrote:
> >>>> On Wed, Jun 26, 2019 at 1:36 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >>>>
> >>>>> 26/06/2019 13:20, David Marchand:
> >>>>>> On Wed, Jun 26, 2019 at 12:41 PM Thomas Monjalon <thomas@monjalon.net>
> >>>>>> wrote:
> >>>>>>
> >>>>>>> When adding an alarm, if an error happen when registering
> >>>>>>> the common alarm callback, it is not considered as a major failure.
> >>>>>>> The alarm is then inserted in the list.
> >>>>>>> However it was returning an error code after inserting the alarm.
> >>>>>>>
> >>>>>>> The error code is reset to 0 so the behaviour and the return code
> >>>>>>> are consistent.
> >>>>>>> Other return code related lines are cleaned up for easier
> >>>>> understanding.
> >>>>>>>
> >>>>> [...]
> >>>>>>> --- a/lib/librte_eal/linux/eal/eal_alarm.c
> >>>>>>> +++ b/lib/librte_eal/linux/eal/eal_alarm.c
> >>>>>>>           if (!handler_registered) {
> >>>>>>> -               ret |= rte_intr_callback_register(&intr_handle,
> >>>>>>> +               ret = rte_intr_callback_register(&intr_handle,
> >>>>>>>                                   eal_alarm_callback, NULL);
> >>>>>>> -               handler_registered = (ret == 0) ? 1 : 0;
> >>>>>>> +               if (ret == 0)
> >>>>>>> +                       handler_registered = 1;
> >>>>>>> +               else
> >>>>>>> +                       /* not fatal, callback can be registered later
> >>>>> */
> >>>>>>> +                       ret = 0;
> >>>>>>>           }
> >>>>>>
> >>>>>> Well, then it means that you don't want to touch ret at all.
> >>>>>> How about:
> >>>>>> if (rte_intr_callback_register(&intr_handle,
> >>>>>>                                  eal_alarm_callback, NULL) == 0)
> >>>>>>           handler_registered = 1;
> >>>>>>
> >>>>>> ?
> >>>>>
> >>>>> Too much simple :)
> >>>>>
> >>>>> I think we try to avoid calling a function in a "if"
> >>>>> per coding style.
> >>>>> And my proposal has the benefit of offering a comment
> >>>>> about the non-fatal error.
> >>>>>
> >>>>
> >>>> /* not fatal, callback can be registered later */
> >>>> if (rte_intr_callback_register(&intr_handle,
> >>>>                                 eal_alarm_callback, NULL) == 0)
> >>>>          handler_registered = 1;
> >>>>
> >>>
> >>> I prefer the original. It's more explicit and conveys the intention
> >>> better. Did i break the tie? :)
> >>
> >> I was going to send a v2 with David's suggestion.
> >> Now I'm confused.
> >>
> > I always tend to prefer shorter versions, so +1 for v2 (does that make it a
> > v3? :-) )
> > 
> > /Bruce
> > 
> 
> OK, but then the suggested comment needs to be fixed. It makes it seem 
> like registering the handler is the "non fatal" part. Perhaps something 
> like:
> 
> /* failed register is not a fatal error - callback can be registered 
> later */

Of course! I had prepared this:
/* registration can fail, callback can be registered later */




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

* [dpdk-dev] [PATCH v2] eal/linux: fix return after alarm registration failure
  2019-06-26 10:40 [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure Thomas Monjalon
  2019-06-26 11:20 ` David Marchand
@ 2019-06-26 14:02 ` Thomas Monjalon
  2019-06-26 23:09   ` Stephen Hemminger
  1 sibling, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-26 14:02 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, stable

When adding an alarm, if an error happen when registering
the common alarm callback, it is not considered as a major failure.
The alarm is then inserted in the list.
However it was returning an error code after inserting the alarm.

The error code is not set anymore to be consistent with the behaviour.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: do not use variable ret
---
 lib/librte_eal/linux/eal/eal_alarm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal_alarm.c b/lib/librte_eal/linux/eal/eal_alarm.c
index 840ede780..0924c9205 100644
--- a/lib/librte_eal/linux/eal/eal_alarm.c
+++ b/lib/librte_eal/linux/eal/eal_alarm.c
@@ -137,9 +137,10 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 
 	rte_spinlock_lock(&alarm_list_lk);
 	if (!handler_registered) {
-		ret |= rte_intr_callback_register(&intr_handle,
-				eal_alarm_callback, NULL);
-		handler_registered = (ret == 0) ? 1 : 0;
+		/* registration can fail, callback can be registered later */
+		if (rte_intr_callback_register(&intr_handle,
+				eal_alarm_callback, NULL) == 0)
+			handler_registered = 1;
 	}
 
 	if (LIST_EMPTY(&alarm_list))
-- 
2.21.0


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

* Re: [dpdk-dev] [PATCH v2] eal/linux: fix return after alarm registration failure
  2019-06-26 14:02 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
@ 2019-06-26 23:09   ` Stephen Hemminger
  2019-06-27 15:25     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2019-06-26 23:09 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, david.marchand, stable

On Wed, 26 Jun 2019 16:02:34 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> When adding an alarm, if an error happen when registering
> the common alarm callback, it is not considered as a major failure.
> The alarm is then inserted in the list.
> However it was returning an error code after inserting the alarm.
> 
> The error code is not set anymore to be consistent with the behaviour.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: do not use variable ret

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

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

* Re: [dpdk-dev] [dpdk-stable] [PATCH v2] eal/linux: fix return after alarm registration failure
  2019-06-26 23:09   ` Stephen Hemminger
@ 2019-06-27 15:25     ` Thomas Monjalon
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2019-06-27 15:25 UTC (permalink / raw)
  To: Stephen Hemminger, dev, david.marchand; +Cc: stable

27/06/2019 01:09, Stephen Hemminger:
> On Wed, 26 Jun 2019 16:02:34 +0200
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > When adding an alarm, if an error happen when registering
> > the common alarm callback, it is not considered as a major failure.
> > The alarm is then inserted in the list.
> > However it was returning an error code after inserting the alarm.
> > 
> > The error code is not set anymore to be consistent with the behaviour.
> > 
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> > v2: do not use variable ret
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied




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

end of thread, other threads:[~2019-06-27 15:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-26 10:40 [dpdk-dev] [PATCH] eal/linux: fix return after alarm registration failure Thomas Monjalon
2019-06-26 11:20 ` David Marchand
2019-06-26 11:36   ` Thomas Monjalon
2019-06-26 11:39     ` David Marchand
2019-06-26 11:43       ` Burakov, Anatoly
2019-06-26 11:55         ` Thomas Monjalon
2019-06-26 12:36           ` Bruce Richardson
2019-06-26 12:52             ` Burakov, Anatoly
2019-06-26 13:20               ` Thomas Monjalon
2019-06-26 14:02 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2019-06-26 23:09   ` Stephen Hemminger
2019-06-27 15:25     ` [dpdk-dev] [dpdk-stable] " 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).