eventdev: avoid non-burst shortcut for variable-size bursts

Message ID 20230511064314.6579-1-mattias.ronnblom@ericsson.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers
Series eventdev: avoid non-burst shortcut for variable-size bursts |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Mattias Rönnblom May 11, 2023, 6:43 a.m. UTC
  Use non-burst event enqueue and dequeue calls from burst enqueue and
dequeue only when the burst size is compile-time constant (and equal
to one).

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 lib/eventdev/rte_eventdev.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Morten Brørup May 11, 2023, 7:09 a.m. UTC | #1
> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com]
> Sent: Thursday, 11 May 2023 08.43
> 
> Use non-burst event enqueue and dequeue calls from burst enqueue and
> dequeue only when the burst size is compile-time constant (and equal
> to one).
> 
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> ---
>  lib/eventdev/rte_eventdev.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
> index a90e23ac8b..8af15816db 100644
> --- a/lib/eventdev/rte_eventdev.h
> +++ b/lib/eventdev/rte_eventdev.h
> @@ -1944,7 +1944,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t
> port_id,
>  	 * Allow zero cost non burst mode routine invocation if application
>  	 * requests nb_events as const one
>  	 */
> -	if (nb_events == 1)
> +	if (__builtin_constant_p(nb_events) && nb_events == 1)

In my experience using __builtin_constant_p(), you need __extension__(__builtin_constant_p(nb_events)) to avoid warnings about using this non-standard feature.

>  		return (fp_ops->enqueue)(port, ev);
>  	else
>  		return fn(port, ev, nb_events);
> @@ -2200,7 +2200,7 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id,
> struct rte_event ev[],
>  	 * Allow zero cost non burst mode routine invocation if application
>  	 * requests nb_events as const one
>  	 */
> -	if (nb_events == 1)
> +	if (__builtin_constant_p(nb_events) && nb_events == 1)
>  		return (fp_ops->dequeue)(port, ev, timeout_ticks);
>  	else
>  		return (fp_ops->dequeue_burst)(port, ev, nb_events,
> --
> 2.34.1

With __extension__() added,

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Mattias Rönnblom May 11, 2023, 8:29 a.m. UTC | #2
On 2023-05-11 09:09, Morten Brørup wrote:
>> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com]
>> Sent: Thursday, 11 May 2023 08.43
>>
>> Use non-burst event enqueue and dequeue calls from burst enqueue and
>> dequeue only when the burst size is compile-time constant (and equal
>> to one).
>>
>> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
>> ---
>>   lib/eventdev/rte_eventdev.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
>> index a90e23ac8b..8af15816db 100644
>> --- a/lib/eventdev/rte_eventdev.h
>> +++ b/lib/eventdev/rte_eventdev.h
>> @@ -1944,7 +1944,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t
>> port_id,
>>   	 * Allow zero cost non burst mode routine invocation if application
>>   	 * requests nb_events as const one
>>   	 */
>> -	if (nb_events == 1)
>> +	if (__builtin_constant_p(nb_events) && nb_events == 1)
> 
> In my experience using __builtin_constant_p(), you need __extension__(__builtin_constant_p(nb_events)) to avoid warnings about using this non-standard feature.
> 

Yes, since it's a public header. Thanks.

>>   		return (fp_ops->enqueue)(port, ev);
>>   	else
>>   		return fn(port, ev, nb_events);
>> @@ -2200,7 +2200,7 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id,
>> struct rte_event ev[],
>>   	 * Allow zero cost non burst mode routine invocation if application
>>   	 * requests nb_events as const one
>>   	 */
>> -	if (nb_events == 1)
>> +	if (__builtin_constant_p(nb_events) && nb_events == 1)
>>   		return (fp_ops->dequeue)(port, ev, timeout_ticks);
>>   	else
>>   		return (fp_ops->dequeue_burst)(port, ev, nb_events,
>> --
>> 2.34.1
> 
> With __extension__() added,
> 
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
>
  
Morten Brørup May 11, 2023, 9:06 a.m. UTC | #3
> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com]
> Sent: Thursday, 11 May 2023 10.30
> 
> On 2023-05-11 09:09, Morten Brørup wrote:

[...]

> > In my experience using __builtin_constant_p(), you need
> __extension__(__builtin_constant_p(nb_events)) to avoid warnings about using
> this non-standard feature.
> >
> 
> Yes, since it's a public header. Thanks.

If you run meson with -Dcheck_includes=true, ninja will catch it.

Unfortunately, the build time increases significantly when using this option.
  

Patch

diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index a90e23ac8b..8af15816db 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -1944,7 +1944,7 @@  __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
 	 */
-	if (nb_events == 1)
+	if (__builtin_constant_p(nb_events) && nb_events == 1)
 		return (fp_ops->enqueue)(port, ev);
 	else
 		return fn(port, ev, nb_events);
@@ -2200,7 +2200,7 @@  rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
 	 */
-	if (nb_events == 1)
+	if (__builtin_constant_p(nb_events) && nb_events == 1)
 		return (fp_ops->dequeue)(port, ev, timeout_ticks);
 	else
 		return (fp_ops->dequeue_burst)(port, ev, nb_events,