Skip to contentSkip to conversation

ring: fix build for gcc O1 optimization

PATCH Superseded Ferruh Yigit 5 participants 20 messages May 7, 2020 – May 11, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ring: fix build for gcc O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Two build errors:
1)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../lib/librte_rcu/rte_rcu_qsbr.c:21:

../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’:
.../build/include/rte_ring_peek.h:282:22:
error: ‘avail’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

  282 |   *available = avail - n;
      |                ~~~~~~^~~
./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here
  259 |  uint32_t avail, head, next;
      |           ^~~~~

2)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../build/include/rte_ring.h:405,
                 from .../app/test/test_ring_stress.h:13,
                 from .../app/test/test_ring_stress_impl.h:5,
                 from .../app/test/test_ring_peek_stress.c:5:

.../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’:
.../build/include/rte_ring_peek.h:80:22:
error: ‘free’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   80 |   *free_space = free - n;
      |                 ~~~~~^~~
.../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here
   60 |  uint32_t free, head, next;
      |           ^~~~

The cases shouldn't be hit, and it looks like there is already logic error if it has been hit, but assigning 'avail' & 'free' to '0' to fix the build error.

---
 lib/librte_ring/rte_ring_peek.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ring/rte_ring_peek.h +2 -0
index d5e6ea1cf3..45f707dc7e 100644
@@ -74,6 +74,7 @@ __rte_ring_do_enqueue_start(struct rte_ring *r, uint32_t n,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		free = 0;
 	}
 
 	if (free_space != NULL)
@@ -273,6 +274,7 @@ __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		avail = 0;
 	}
 
 	if (n != 0)
Signature · 1 line
2.25.4
#1 lore raw

PATCH 2/3 mempool/octeontx2: fix build for gcc O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -1
index 162b7f01da..078ffac3e2 100644
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
 	struct otx2_npa_lf *lf;
 	struct npa_aura_s aura;
 	struct npa_pool_s pool;
-	uint64_t aura_handle;
+	uint64_t aura_handle = 0;
 	size_t padding;
 	int rc;
 
Signature · 1 line
2.25.4
#2 lore raw

Re: [dpdk-dev] [PATCH 2/3] mempool/octeontx2: fix build for gcc O1 optimization

Hi Ferruh, Jerin

Quoted 35 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +0 -0
index 162b7f01da..078ffac3e2 100644

drivers/mempool/octeontx2/otx2_mempool_ops.c otx2_npa_alloc(struct rte_mempool *mp)

Quoted 9 lines
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -2
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
 	struct otx2_npa_lf *lf;
 	struct npa_aura_s aura;
 	struct npa_pool_s pool;
-	uint64_t aura_handle;
+	uint64_t aura_handle = 0;
 	size_t padding;
 	int rc;
 
--

Confirm that it helps, though I am seeing one more issue with EXTRA_CFLAGS='-O1' (gcc 7.3.0). This time with drivers/event/octeontx2/otx2_evdev_stats.h:

In file included from /local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/ot
x2_evdev.c:15:0:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h: In function ‘otx2_sso_xstats_get’:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h:124:9: error: ‘xstats’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
xstat = &xstats[ids[i] - start_offset];
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-address-of-packed-member’ [-Werror]
cc1: all warnings being treated as errors

As I can see xtstats is not set for RTE_EVENT_DEV_XSTATS_DEVICE case. Just to make gcc quiet, I added:

drivers/event/octeontx2/otx2_evdev_stats.h +1 -0
@@ -67,6 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
        switch (mode) {
        case RTE_EVENT_DEV_XSTATS_DEVICE:
+               xstats = NULL;
                break;
        case RTE_EVENT_DEV_XSTATS_PORT:
                if (queue_port_id >= (signed int)dev->nb_event_ports)

Konstantin

#3 lore raw

Re: [dpdk-dev] [PATCH 2/3] mempool/octeontx2: fix build for gcc O1 optimization

Quoted 74 lines · Konstantin

Hi Ferruh, Jerin

Quoted 35 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +0 -0
index 162b7f01da..078ffac3e2 100644

drivers/mempool/octeontx2/otx2_mempool_ops.c otx2_npa_alloc(struct rte_mempool *mp)

Quoted 9 lines
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -2
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
 struct otx2_npa_lf *lf;
 struct npa_aura_s aura;
 struct npa_pool_s pool;
-uint64_t aura_handle;
+uint64_t aura_handle = 0;
 size_t padding;
 int rc;
 
--

Confirm that it helps, though I am seeing one more issue with EXTRA_CFLAGS='-O1' (gcc 7.3.0). This time with drivers/event/octeontx2/otx2_evdev_stats.h:

In file included from /local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/ot
x2_evdev.c:15:0:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h: In function ‘otx2_sso_xstats_get’:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h:124:9: error: ‘xstats’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

   xstat = &xstats[ids[i] - start_offset];
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-address-of-packed-member’ [-Werror]
cc1: all warnings being treated as errors

As I can see xtstats is not set for RTE_EVENT_DEV_XSTATS_DEVICE case. Just to make gcc quiet, I added:

drivers/event/octeontx2/otx2_evdev_stats.h +1 -0
@@ -67,6 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
        switch (mode) {
        case RTE_EVENT_DEV_XSTATS_DEVICE:
+               xstats = NULL;
                break;
        case RTE_EVENT_DEV_XSTATS_PORT:
                if (queue_port_id >= (signed int)dev->nb_event_ports)
Quoted 4 lines

Konstantin

Thanks Konstantin,

I will make a v2 including above as you suggested.

#4 lore raw

Re: [dpdk-dev] [PATCH 2/3] mempool/octeontx2: fix build for gcc O1 optimization

Quoted 75 lines · Ferruh Yigit
Quoted 74 lines · Konstantin

Hi Ferruh, Jerin

Quoted 35 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +0 -0
index 162b7f01da..078ffac3e2 100644

drivers/mempool/octeontx2/otx2_mempool_ops.c otx2_npa_alloc(struct rte_mempool *mp)

Quoted 9 lines
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -2
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
 struct otx2_npa_lf *lf;
 struct npa_aura_s aura;
 struct npa_pool_s pool;
-uint64_t aura_handle;
+uint64_t aura_handle = 0;
 size_t padding;
 int rc;
 
--

Confirm that it helps, though I am seeing one more issue with EXTRA_CFLAGS='-O1' (gcc 7.3.0). This time with drivers/event/octeontx2/otx2_evdev_stats.h:

In file included from /local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/ot
x2_evdev.c:15:0:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h: In function ‘otx2_sso_xstats_get’:
/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev_stats.h:124:9: error: ‘xstats’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

   xstat = &xstats[ids[i] - start_offset];
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/local/kananye1/dpdk.2005.rngf1/drivers/event/octeontx2/otx2_evdev.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-address-of-packed-member’ [-Werror]
cc1: all warnings being treated as errors

As I can see xtstats is not set for RTE_EVENT_DEV_XSTATS_DEVICE case. Just to make gcc quiet, I added:

drivers/event/octeontx2/otx2_evdev_stats.h +1 -0
@@ -67,6 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
        switch (mode) {
        case RTE_EVENT_DEV_XSTATS_DEVICE:
+               xstats = NULL;
                break;
        case RTE_EVENT_DEV_XSTATS_PORT:
                if (queue_port_id >= (signed int)dev->nb_event_ports)
Quoted 8 lines
Quoted 4 lines

Konstantin

Thanks Konstantin,

I will make a v2 including above as you suggested.

Thinking twice, if compiler thinks 'xstats' may be used uninitialized, when is assigned to NULL it should complain about null pointer de-reference.

Btw, this is also false positive, 'xstats_mode_count' prevents taking the loop and accessing to 'xstats'. Not sure what is the problem with "-O1" option ...

But for the 'RTE_EVENT_DEV_XSTATS_DEVICE' case, the loop is skipped and functions returns '0', I will update as following to get more close to the intention, also this is less work for function.
Can you please test below when I send the patch, I can't reproduce this?

@@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,

        switch (mode) {
        case RTE_EVENT_DEV_XSTATS_DEVICE:
-               break;
+               return 0;
        case RTE_EVENT_DEV_XSTATS_PORT:
                if (queue_port_id >= (signed int)dev->nb_event_ports)
                        goto invalid_value;
#5 lore raw

PATCH 3/3 net/ena: fix build for O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
.../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
.../drivers/net/ena/ena_ethdev.c:1815:20:
error: ‘wd_state’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

 1815 |  adapter->wd_state = wd_state;
      |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

This looks like false positive, fixing by assigning initial value to 'wd_state' variable.

---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index c3fd3a4ac0..fbddc79f79 100644
@@ -1756,7 +1756,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	int rc;
 	static int adapters_found;
 	bool disable_meta_caching;
-	bool wd_state;
+	bool wd_state = false;
 
 	eth_dev->dev_ops = &ena_dev_ops;
 	eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
Signature · 1 line
2.25.4
Acked-by on v1 3/3
#6 lore raw

Re: [dpdk-dev] [PATCH 3/3] net/ena: fix build for O1 optimization

czw., 7 maj 2020 o 14:03 Ferruh Yigit <[email protected]> napisał(a):

Quoted 9 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
.../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
.../drivers/net/ena/ena_ethdev.c:1815:20:
error: ‘wd_state’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

Quoted 7 lines
 1815 |  adapter->wd_state = wd_state;
      |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

This looks like false positive, fixing by assigning initial value to 'wd_state' variable.

Quoted 20 lines
---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -2
index c3fd3a4ac0..fbddc79f79 100644
@@ -1756,7 +1756,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
        int rc;
        static int adapters_found;
        bool disable_meta_caching;
-       bool wd_state;
+       bool wd_state = false;
 
        eth_dev->dev_ops = &ena_dev_ops;
        eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
--

2.25.4

Acked-by on v1 1/3
#7 lore raw
In reply to Ferruh Yigit
Quoted 58 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Two build errors:
1)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../lib/librte_rcu/rte_rcu_qsbr.c:21:

../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’:
.../build/include/rte_ring_peek.h:282:22:
error: ‘avail’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

  282 |   *available = avail - n;
      |                ~~~~~~^~~
./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here
  259 |  uint32_t avail, head, next;
      |           ^~~~~

2)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../build/include/rte_ring.h:405,
                 from .../app/test/test_ring_stress.h:13,
                 from .../app/test/test_ring_stress_impl.h:5,
                 from .../app/test/test_ring_peek_stress.c:5:

.../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’:
.../build/include/rte_ring_peek.h:80:22:
error: ‘free’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   80 |   *free_space = free - n;
      |                 ~~~~~^~~
.../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here
   60 |  uint32_t free, head, next;
      |           ^~~~

The cases shouldn't be hit, and it looks like there is already logic error if it has been hit, but assigning 'avail' & 'free' to '0' to fix the build error.

---
 lib/librte_ring/rte_ring_peek.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ring/rte_ring_peek.h +1 -0
index d5e6ea1cf3..45f707dc7e 100644
@@ -74,6 +74,7 @@ __rte_ring_do_enqueue_start(struct rte_ring *r, uint32_t n,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		free = 0;
 	}
 
 	if (free_space != NULL)

lib/librte_ring/rte_ring_peek.h __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table,

Quoted 8 lines
lib/librte_ring/rte_ring_peek.h +1 -1
@@ -273,6 +274,7 @@ __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		avail = 0;
 	}
 
 	if (n != 0)
--
Quoted 1 line

2.25.4

#8 lore raw

PATCH v2 1/4 ring: fix build for gcc O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Two build errors:
1)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../lib/librte_rcu/rte_rcu_qsbr.c:21:

../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’:
.../build/include/rte_ring_peek.h:282:22:
error: ‘avail’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

  282 |   *available = avail - n;
      |                ~~~~~~^~~
./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here
  259 |  uint32_t avail, head, next;
      |           ^~~~~

2)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../build/include/rte_ring.h:405,
                 from .../app/test/test_ring_stress.h:13,
                 from .../app/test/test_ring_stress_impl.h:5,
                 from .../app/test/test_ring_peek_stress.c:5:

.../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’:
.../build/include/rte_ring_peek.h:80:22:
error: ‘free’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   80 |   *free_space = free - n;
      |                 ~~~~~^~~
.../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here
   60 |  uint32_t free, head, next;
      |           ^~~~

The cases shouldn't be hit, and it looks like there is already logic error if it has been hit, but assigning 'avail' & 'free' to '0' to fix the build error.

---
 lib/librte_ring/rte_ring_peek.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ring/rte_ring_peek.h +2 -0
index d5e6ea1cf3..45f707dc7e 100644
@@ -74,6 +74,7 @@ __rte_ring_do_enqueue_start(struct rte_ring *r, uint32_t n,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		free = 0;
 	}
 
 	if (free_space != NULL)
@@ -273,6 +274,7 @@ __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		avail = 0;
 	}
 
 	if (n != 0)
Signature · 1 line
2.25.4
#9 lore raw

PATCH v2 2/4 mempool/octeontx2: fix build for gcc O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -1
index 162b7f01da..078ffac3e2 100644
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
 	struct otx2_npa_lf *lf;
 	struct npa_aura_s aura;
 	struct npa_pool_s pool;
-	uint64_t aura_handle;
+	uint64_t aura_handle = 0;
 	size_t padding;
 	int rc;
 
Signature · 1 line
2.25.4
Acked-by on v2 2/4
#10 lore raw

Re: [dpdk-dev] [PATCH v2 2/4] mempool/octeontx2: fix build for gcc O1 optimization

Quoted 36 lines · Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +0 -0
index 162b7f01da..078ffac3e2 100644

drivers/mempool/octeontx2/otx2_mempool_ops.c otx2_npa_alloc(struct rte_mempool *mp) · line 643

Quoted 5 lines
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -1
@@ -640,7 +640,7 @@ otx2_npa_alloc(struct rte_mempool *mp)
        struct otx2_npa_lf *lf;
        struct npa_aura_s aura;
        struct npa_pool_s pool;
-       uint64_t aura_handle;
+       uint64_t aura_handle = 0;

It is a false positive. Since it is on a slow path, This workaround is OK. While merging t this patch, Could you move "uint64_t aura_handle = 0;" just before "struct otx2_npa_lf *lf" as
the variables are ordered in reverse xmas tree format in this file.

With the above change:

Quoted 6 lines
drivers/mempool/octeontx2/otx2_mempool_ops.c +0 -1
        size_t padding;
        int rc;
 
--

2.25.4

#11 lore raw

PATCH v2 3/4 net/ena: fix build for O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
.../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
.../drivers/net/ena/ena_ethdev.c:1815:20:
error: ‘wd_state’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

 1815 |  adapter->wd_state = wd_state;
      |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

This looks like false positive, fixing by assigning initial value to 'wd_state' variable.

---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index c3fd3a4ac0..fbddc79f79 100644
@@ -1756,7 +1756,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	int rc;
 	static int adapters_found;
 	bool disable_meta_caching;
-	bool wd_state;
+	bool wd_state = false;
 
 	eth_dev->dev_ops = &ena_dev_ops;
 	eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
Signature · 1 line
2.25.4
#12 lore raw

PATCH v2 4/4 event/octeontx2: fix build for O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc 7.3.0

Build error
In file included from .../drivers/event/octeontx2/ot x2_evdev.c:15:0:
.../drivers/event/octeontx2/otx2_evdev_stats.h:
In function ‘otx2_sso_xstats_get’:
.../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
error: ‘xstats’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
xstat = &xstats[ids[i] - start_offset]; ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is false positive, 'xstats_mode_count' should be preventing taking the loop and accessing 'xstats'.
Returning in that case to silence the compiler warning.

---
 drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/octeontx2/otx2_evdev_stats.h +1 -1
index 9d7c694ee6..74fcec8a07 100644
@@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
 	switch (mode) {
 	case RTE_EVENT_DEV_XSTATS_DEVICE:
-		break;
+		return 0;
 	case RTE_EVENT_DEV_XSTATS_PORT:
 		if (queue_port_id >= (signed int)dev->nb_event_ports)
 			goto invalid_value;
Signature · 1 line
2.25.4
Tested-by Acked-by on v2 4/4
#13 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization

Quoted 33 lines

Subject: [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc 7.3.0

Build error
In file included from .../drivers/event/octeontx2/ot x2_evdev.c:15:0:
.../drivers/event/octeontx2/otx2_evdev_stats.h:
In function ‘otx2_sso_xstats_get’:
.../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
error: ‘xstats’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   xstat = &xstats[ids[i] - start_offset];
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is false positive, 'xstats_mode_count' should be preventing taking the loop and accessing 'xstats'.
Returning in that case to silence the compiler warning.

---
 drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/octeontx2/otx2_evdev_stats.h +0 -0
index 9d7c694ee6..74fcec8a07 100644

drivers/event/octeontx2/otx2_evdev_stats.h otx2_sso_xstats_get(const struct rte_eventdev *event_dev,

Quoted 9 lines
drivers/event/octeontx2/otx2_evdev_stats.h +1 -2
@@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
 	switch (mode) {
 	case RTE_EVENT_DEV_XSTATS_DEVICE:
-		break;
+		return 0;
 	case RTE_EVENT_DEV_XSTATS_PORT:
 		if (queue_port_id >= (signed int)dev->nb_event_ports)
 			goto invalid_value;
--
Quoted 1 line

2.25.4

Acked-by
#14 lore raw

Re: [dpdk-dev] [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization

Quoted 35 lines · Konstantin
Quoted 35 lines

Subject: [PATCH v2 4/4] event/octeontx2: fix build for O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc 7.3.0

Build error
In file included from .../drivers/event/octeontx2/ot x2_evdev.c:15:0:
.../drivers/event/octeontx2/otx2_evdev_stats.h:
In function ‘otx2_sso_xstats_get’:
.../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
error: ‘xstats’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   xstat = &xstats[ids[i] - start_offset];
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is false positive, 'xstats_mode_count' should be preventing taking the loop and accessing 'xstats'.
Returning in that case to silence the compiler warning.

---
 drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/octeontx2/otx2_evdev_stats.h +0 -0
index 9d7c694ee6..74fcec8a07 100644
@@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
Quoted 11 lines

drivers/event/octeontx2/otx2_evdev_stats.h otx2_sso_xstats_get(const struct rte_eventdev *event_dev,

Quoted 8 lines
drivers/event/octeontx2/otx2_evdev_stats.h +1 -2
      switch (mode) {
      case RTE_EVENT_DEV_XSTATS_DEVICE:
-             break;
+             return 0;
      case RTE_EVENT_DEV_XSTATS_PORT:
              if (queue_port_id >= (signed int)dev->nb_event_ports)
                      goto invalid_value;
--
Quoted 3 lines
Quoted 2 lines

2.25.4

#15 lore raw

PATCH v3 1/4 ring: fix build for gcc O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Two build errors:
1)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../lib/librte_rcu/rte_rcu_qsbr.c:21:

../lib/librte_rcu/rte_rcu_qsbr.c: In function ‘rte_rcu_qsbr_dq_reclaim’:
.../build/include/rte_ring_peek.h:282:22:
error: ‘avail’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

  282 |   *available = avail - n;
      |                ~~~~~~^~~
./build/include/rte_ring_peek.h:259:11: note: ‘avail’ was declared here
  259 |  uint32_t avail, head, next;
      |           ^~~~~

2)
In file included from .../build/include/rte_ring_elem.h:1093,

                 from .../build/include/rte_ring.h:405,
                 from .../app/test/test_ring_stress.h:13,
                 from .../app/test/test_ring_stress_impl.h:5,
                 from .../app/test/test_ring_peek_stress.c:5:

.../app/test/test_ring_peek_stress.c: In function ‘_st_ring_enqueue_bulk’:
.../build/include/rte_ring_peek.h:80:22:
error: ‘free’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   80 |   *free_space = free - n;
      |                 ~~~~~^~~
.../build/include/rte_ring_peek.h:60:11: note: ‘free’ was declared here
   60 |  uint32_t free, head, next;
      |           ^~~~

The cases shouldn't be hit, and it looks like there is already logic error if it has been hit, but assigning 'avail' & 'free' to '0' to fix the build error.

---
 lib/librte_ring/rte_ring_peek.h | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ring/rte_ring_peek.h +2 -0
index d5e6ea1cf3..45f707dc7e 100644
@@ -74,6 +74,7 @@ __rte_ring_do_enqueue_start(struct rte_ring *r, uint32_t n,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		free = 0;
 	}
 
 	if (free_space != NULL)
@@ -273,6 +274,7 @@ __rte_ring_do_dequeue_start(struct rte_ring *r, void *obj_table,
 		/* unsupported mode, shouldn't be here */
 		RTE_ASSERT(0);
 		n = 0;
+		avail = 0;
 	}
 
 	if (n != 0)
Signature · 1 line
2.25.4
#16 lore raw

PATCH v3 2/4 mempool/octeontx2: fix build for gcc O1 optimization

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
In file included from .../drivers/mempool/octeontx2/otx2_mempool.h:13,

                from .../drivers/mempool/octeontx2/otx2_mempool_ops.c:8:

.../drivers/mempool/octeontx2/otx2_mempool_ops.c:
In function ‘otx2_npa_alloc’:
.../drivers/common/octeontx2/otx2_common.h:94:2:
error: ‘aura_handle’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

   94 |  rte_log(RTE_LOG_DEBUG, otx2_logtype_ ## subsystem,  \
      |  ^~~~~~~
.../drivers/mempool/octeontx2/otx2_mempool_ops.c:643:11:
    note: ‘aura_handle’ was declared here
  643 |  uint64_t aura_handle;
      |           ^~~~~~~~~~~

This looks like false positive, assigning an initial value to 'aura_handle' to fix the build error.

---
This is assuming assigning initial value won't have a performance affect if it does, we need to find another fix.
And overall not sure why this false positive warning is generated.

---
 drivers/mempool/octeontx2/otx2_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mempool/octeontx2/otx2_mempool_ops.c +1 -1
index 162b7f01da..a14c9c5e94 100644
@@ -637,10 +637,10 @@ static int
 otx2_npa_alloc(struct rte_mempool *mp)
 {
 	uint32_t block_size, block_count;
+	uint64_t aura_handle = 0;
 	struct otx2_npa_lf *lf;
 	struct npa_aura_s aura;
 	struct npa_pool_s pool;
-	uint64_t aura_handle;
 	size_t padding;
 	int rc;
 
Signature · 1 line
2.25.4
#17 lore raw

PATCH v3 3/4 net/ena: fix build for O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Build error:
.../drivers/net/ena/ena_ethdev.c: In function ‘eth_ena_dev_init’:
.../drivers/net/ena/ena_ethdev.c:1815:20:
error: ‘wd_state’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]

 1815 |  adapter->wd_state = wd_state;
      |  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~

This looks like false positive, fixing by assigning initial value to 'wd_state' variable.

---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index c3fd3a4ac0..fbddc79f79 100644
@@ -1756,7 +1756,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	int rc;
 	static int adapters_found;
 	bool disable_meta_caching;
-	bool wd_state;
+	bool wd_state = false;
 
 	eth_dev->dev_ops = &ena_dev_ops;
 	eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
Signature · 1 line
2.25.4
#18 lore raw

PATCH v3 4/4 event/octeontx2: fix build for O1 optimization

In reply to Ferruh Yigit

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc 7.3.0

Build error
In file included from .../drivers/event/octeontx2/ot x2_evdev.c:15:0:
.../drivers/event/octeontx2/otx2_evdev_stats.h:
In function ‘otx2_sso_xstats_get’:
.../drivers/event/octeontx2/otx2_evdev_stats.h:124:9:
error: ‘xstats’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
xstat = &xstats[ids[i] - start_offset]; ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is false positive, 'xstats_mode_count' should be preventing taking the loop and accessing 'xstats'.
Returning in that case to silence the compiler warning.

---
 drivers/event/octeontx2/otx2_evdev_stats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/octeontx2/otx2_evdev_stats.h +1 -1
index 9d7c694ee6..74fcec8a07 100644
@@ -67,7 +67,7 @@ otx2_sso_xstats_get(const struct rte_eventdev *event_dev,
 
 	switch (mode) {
 	case RTE_EVENT_DEV_XSTATS_DEVICE:
-		break;
+		return 0;
 	case RTE_EVENT_DEV_XSTATS_PORT:
 		if (queue_port_id >= (signed int)dev->nb_event_ports)
 			goto invalid_value;
Signature · 1 line
2.25.4
#19 lore raw
In reply to Ferruh Yigit

11/05/2020 18:07, Ferruh Yigit:

Quoted 2 lines

Can be reproduced with "make EXTRA_CFLAGS='-O1'" command using gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Series applied, thanks