Skip to contentSkip to conversation

rcu: remove VLAs

PATCH In review Andre Muezerie 2 participants 8 messages Mar 7, 2025 – May 16, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcu: remove VLAs

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

---
 lib/rcu/meson.build    | 7 -------
 lib/rcu/rte_rcu_qsbr.c | 6 +++---
 2 files changed, 3 insertions(+), 10 deletions(-)
lib/rcu/meson.build +0 -7
index fb1f49ba63..71143f5210 100644
@@ -11,10 +11,3 @@ sources = files('rte_rcu_qsbr.c')
 headers = files('rte_rcu_qsbr.h')
 
 deps += ['ring']
-
-# FIXME: this library was enabled for mingw target (a Windows target).
-# Relying on no_wvla_cflag would trigger a build error until the VLA in rte_rcu_qsbr.c is removed.
-# Disable the warning here for now.
-if cc.has_argument('-Wvla')
-    cflags += '-Wno-vla'
-endif
lib/rcu/rte_rcu_qsbr.c +3 -3
index dbf31501a6..3f619e1607 100644
@@ -323,7 +323,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e)
 		return 1;
 	}
 
-	char data[dq->esize];
+	char *data = alloca(dq->esize);
 	dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data;
 	/* Start the grace period */
 	dq_elem->token = rte_rcu_qsbr_start(dq->v);
@@ -386,10 +386,10 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n,
 
 	cnt = 0;
 
-	char data[dq->esize];
+	char *data = alloca(dq->esize);
 	/* Check reader threads quiescent state and reclaim resources */
 	while (cnt < n &&
-		rte_ring_dequeue_bulk_elem_start(dq->r, &data,
+		rte_ring_dequeue_bulk_elem_start(dq->r, data,
 					dq->esize, 1, available) != 0) {
 		dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data;
 
Signature · 1 line
2.48.1.vfs.0.0
#1 lore raw
Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Honnappa, any objection?

Signature · 1 line
David Marchand
#2 lore raw

Hello,

Quoted 22 lines · David Marchand
Quoted 19 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Quoted 3 lines
Quoted 1 line

Honnappa, any objection?

I'll take silence as a no.

Andre, you mention long-term plan, if you plan to do this change in 25.11, now would be a good time to prepare a deprecation notice on this topic.

Signature · 1 line
David Marchand
#3 lore raw
In reply to Andre Muezerie

Andre,

Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Afaiu, enabling RCU with MSVC depends on this current patch and a fix in test/ipfrag:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/.
Is there anything else missing?

If not, then I would be for doing this enabling as part of this current patch (I can do this when applying).
WDYT?

Signature · 1 line
David Marchand
#4 lore raw
Quoted 25 lines · David Marchand

Andre,

Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Quoted 9 lines

Afaiu, enabling RCU with MSVC depends on this current patch and a fix in test/ipfrag:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/.
Is there anything else missing?

If not, then I would be for doing this enabling as part of this current patch (I can do this when applying).
WDYT?

You're correct. When enabling RCU lib, test_ipfrag is build and fails if the mentioned patch is not applied yet. If you apply that patch first, it would be great if you could enable RCU on Windows as part of this patch. Nothing else should be missing.

I had not enabled it before to not break the CI build.

Quoted 3 lines
Signature · 2 lines
-- 
David Marchand
#5 lore raw
Quoted 37 lines · Andre Muezerie
Quoted 25 lines · David Marchand

Andre,

Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Quoted 9 lines

Afaiu, enabling RCU with MSVC depends on this current patch and a fix in test/ipfrag:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/.
Is there anything else missing?

If not, then I would be for doing this enabling as part of this current patch (I can do this when applying).
WDYT?

Quoted 5 lines

You're correct. When enabling RCU lib, test_ipfrag is build and fails if the mentioned patch is not applied yet. If you apply that patch first, it would be great if you could enable RCU on Windows as part of this patch. Nothing else should be missing.

I had not enabled it before to not break the CI build.

Ok, I did my checks and it looks fine, so I squashed the mention change as part of this patch.

I see patches on lpm and fib library for which I have similar questions. I must stop merging for today but could you double check those libraries can be enabled too?

This way it will be easier for me next week.

Thanks.

Signature · 1 line
David Marchand
#6 lore raw
Quoted 45 lines · David Marchand
Quoted 37 lines · Andre Muezerie
Quoted 25 lines · David Marchand

Andre,

Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Quoted 9 lines

Afaiu, enabling RCU with MSVC depends on this current patch and a fix in test/ipfrag:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/.
Is there anything else missing?

If not, then I would be for doing this enabling as part of this current patch (I can do this when applying).
WDYT?

Quoted 5 lines

You're correct. When enabling RCU lib, test_ipfrag is build and fails if the mentioned patch is not applied yet. If you apply that patch first, it would be great if you could enable RCU on Windows as part of this patch. Nothing else should be missing.

I had not enabled it before to not break the CI build.

Quoted 9 lines

Ok, I did my checks and it looks fine, so I squashed the mention change as part of this patch.

I see patches on lpm and fib library for which I have similar questions. I must stop merging for today but could you double check those libraries can be enabled too?

This way it will be easier for me next week.

I updated both patches to also enable the build when using MSVC since there's nothing blocking that anymore.

Quoted 5 lines

Thanks.

Signature · 1 line
David Marchand
#7 lore raw
In reply to Andre Muezerie
Quoted 13 lines · Andre Muezerie

There are two lines that were using VLAs, which are not supported by MSVC.

1)
../lib/rcu/rte_rcu_qsbr.c:326:12: warning: variable length array used [-Wvla]

  326 |         char data[dq->esize];
      |                   ^~~~~~~~~
2)
../lib/rcu/rte_rcu_qsbr.c:389:12: warning: variable length array used [-Wvla]
  389 |         char data[dq->esize];
      |                   ^~~~~~~~~
Quoted 7 lines

The short-term fix is to use alloca, to allow progress with the msvc compatibility work.
The long-term plan involves API changes and therefore can only be applied with a new release. This long-term plan consists of introducing some reasonable limitation on RCU DQ element size.

Applied with enabling RCU compilation on MSVC.
Thanks.

Signature · 1 line
David Marchand