DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Fix warnings when using gcc 15
       [not found] <20250110170603.538756-1-stephen@networkplumber.or>
@ 2025-01-20 23:23 ` Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 1/3] crypto/cnxk: fix gcc 15 warning Stephen Hemminger
                     ` (3 more replies)
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
  1 sibling, 4 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-20 23:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Three fixes need to make current main branch build cleanly with
current pre-release of Gcc 15.

Stephen Hemminger (3):
  crypto/cnxk: fix gcc 15 warning
  net/thunderx/base: fix build with Gcc 15
  examples/flow_filtering: fix gcc 15 overflow warning

 drivers/crypto/cnxk/cnxk_se.h                 |  2 +-
 drivers/net/thunderx/base/nicvf_mbox.c        | 42 +++++++++----------
 .../snippets/snippet_match_mpls.c             |  2 +-
 3 files changed, 23 insertions(+), 23 deletions(-)

-- 
2.45.2


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

* [PATCH v2 1/3] crypto/cnxk: fix gcc 15 warning
  2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
@ 2025-01-20 23:23   ` Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 2/3] net/thunderx/base: fix build with Gcc 15 Stephen Hemminger
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-20 23:23 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, stable, anoobj, Ankur Dwivedi,
	Tejasree Kondoj, Akhil Goyal

GCC 15 produces warnings about uninitaialized variables.

In file included from ../lib/mbuf/rte_mbuf.h:36,
                 from ../lib/cryptodev/rte_crypto.h:15,
                 from ../lib/cryptodev/rte_cryptodev.h:19,
                 from ../drivers/crypto/cnxk/cn9k_cryptodev_ops.c:5:
In function ‘pdcp_chain_sg1_prep’,
    inlined from ‘cpt_pdcp_chain_alg_prep’ at ../drivers/crypto/cnxk/cnxk_se.h:1621:11,
    inlined from ‘fill_pdcp_chain_params’ at ../drivers/crypto/cnxk/cnxk_se.h:3114:8,
    inlined from ‘cpt_sym_inst_fill’ at ../drivers/crypto/cnxk/cnxk_se.h:3364:9,
    inlined from ‘cn9k_cpt_inst_prep’ at ../drivers/crypto/cnxk/cn9k_cryptodev_ops.c:93:10:
../lib/eal/include/rte_common.h:469:38: warning: ‘fc_params.meta_buf.vaddr’ may be used uninitialized [-Wmaybe-uninitialized]
  469 | #define RTE_PTR_ADD(ptr, x) ((void*)((uintptr_t)(ptr) + (x)))
      |                                      ^~~~~~~~~~~~~~~~
../drivers/common/cnxk/roc_platform.h:47:34: note: in expansion of macro ‘RTE_PTR_ADD’
   47 | #define PLT_PTR_ADD              RTE_PTR_ADD
      |                                  ^~~~~~~~~~~
../drivers/crypto/cnxk/cnxk_se.h:900:19: note: in expansion of macro ‘PLT_PTR_ADD’
  900 |         m_vaddr = PLT_PTR_ADD(m_vaddr, ROC_SE_OFF_CTRL_LEN + PLT_ALIGN_CEIL(hdr_len, 8));
      |                   ^~~~~~~~~~~
In file included from ../drivers/crypto/cnxk/cn9k_cryptodev_ops.c:20:
../drivers/crypto/cnxk/cnxk_se.h: In function ‘cn9k_cpt_inst_prep’:
../drivers/crypto/cnxk/cnxk_se.h:3008:33: note: ‘fc_params.meta_buf.vaddr’ was declared here
 3008 |         struct roc_se_fc_params fc_params;
      |                                 ^~~~~~~~~
In function ‘pdcp_chain_sg1_prep’,
    inlined from ‘cpt_pdcp_chain_alg_prep’ at ../drivers/crypto/cnxk/cnxk_se.h:1621:11,
    inlined from ‘fill_pdcp_chain_params’ at ../drivers/crypto/cnxk/cnxk_se.h:3114:8,
    inlined from ‘cpt_sym_inst_fill’ at ../drivers/crypto/cnxk/cnxk_se.h:3364:9,
    inlined from ‘cn9k_cpt_inst_prep’ at ../drivers/crypto/cnxk/cn9k_cryptodev_ops.c:82:10:
../lib/eal/include/rte_common.h:469:38: warning: ‘fc_params.meta_buf.vaddr’ may be used uninitialized [-Wmaybe-uninitialized]
  469 | #define RTE_PTR_ADD(ptr, x) ((void*)((uintptr_t)(ptr) + (x)))
      |                                      ^~~~~~~~~~~~~~~~
../drivers/common/cnxk/roc_platform.h:47:34: note: in expansion of macro ‘RTE_PTR_ADD’
   47 | #define PLT_PTR_ADD              RTE_PTR_ADD
      |                                  ^~~~~~~~~~~
../drivers/crypto/cnxk/cnxk_se.h:900:19: note: in expansion of macro ‘PLT_PTR_ADD’
  900 |         m_vaddr = PLT_PTR_ADD(m_vaddr, ROC_SE_OFF_CTRL_LEN + PLT_ALIGN_CEIL(hdr_len, 8));
      |                   ^~~~~~~~~~~
../drivers/crypto/cnxk/cnxk_se.h: In function ‘cn9k_cpt_inst_prep’:
../drivers/crypto/cnxk/cnxk_se.h:3008:33: note: ‘fc_params.meta_buf.vaddr’ was declared here
 3008 |         struct roc_se_fc_params fc_params;
      |                                 ^~~~~~~~~

Fixes: d3bff77cc371 ("crypto/cnxk: separate out PDCP chain datapath")
Cc: stable@dpdk.org
Cc: anoobj@marvell.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/cnxk/cnxk_se.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 7262a49945..649e38c495 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -3005,7 +3005,7 @@ fill_pdcp_chain_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,
 {
 	uint32_t ci_data_length, ci_data_offset, a_data_length, a_data_offset;
 	struct rte_crypto_sym_op *sym_op = cop->sym;
-	struct roc_se_fc_params fc_params;
+	struct roc_se_fc_params fc_params = { };
 	struct rte_mbuf *m_src, *m_dst;
 	uint8_t cpt_op = sess->cpt_op;
 	uint64_t d_offs, d_lens;
-- 
2.45.2


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

* [PATCH v2 2/3] net/thunderx/base: fix build with Gcc 15
  2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 1/3] crypto/cnxk: fix gcc 15 warning Stephen Hemminger
@ 2025-01-20 23:23   ` Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 3/3] examples/flow_filtering: fix gcc 15 overflow warning Stephen Hemminger
  2025-01-22 10:50   ` [PATCH v2 0/3] Fix warnings when using gcc 15 David Marchand
  3 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-20 23:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, David Marchand, Jerin Jacob, Maciej Czekaj

Gcc 15 now produces warning with the base code of Thunderx driver.
The issue is that Gcc now defaults to C23 mode, and the standards
gods have decided that the result of partial initialization of a union
is not defined for other fields.

The fix is to use an empty initializer which forces full initialization.

[2377/3224] Compiling C object drivers/net/thunderx/base/libnicvf_base.a.p/nicvf_mbox.c.o
In function ‘nicvf_mbox_send_msg_to_pf_raw’,
    inlined from ‘nicvf_mbox_send_async_msg_to_pf’ at ../drivers/net/thunderx/base/nicvf_mbox.c:70:2,
    inlined from ‘nicvf_mbox_cfg_done’ at ../drivers/net/thunderx/base/nicvf_mbox.c:468:2:
../drivers/net/thunderx/base/nicvf_mbox.c:59:17: warning: ‘mbx’ is used uninitialized [-Wuninitialized]
   59 |                 nicvf_reg_write(nic, mbx_addr, *mbx_data);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/thunderx/base/nicvf_mbox.c: In function ‘nicvf_mbox_cfg_done’:
../drivers/net/thunderx/base/nicvf_mbox.c:465:24: note: ‘mbx’ declared here
  465 |         struct nic_mbx mbx = { .msg = { 0 } };
      |                        ^~~
In function ‘nicvf_mbox_send_msg_to_pf_raw’,
    inlined from ‘nicvf_mbox_send_async_msg_to_pf’ at ../drivers/net/thunderx/base/nicvf_mbox.c:70:2,
    inlined from ‘nicvf_mbox_link_change’ at ../drivers/net/thunderx/base/nicvf_mbox.c:477:2:
../drivers/net/thunderx/base/nicvf_mbox.c:59:17: warning: ‘mbx’ is used uninitialized [-Wuninitialized]
   59 |                 nicvf_reg_write(nic, mbx_addr, *mbx_data);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/thunderx/base/nicvf_mbox.c: In function ‘nicvf_mbox_link_change’:
../drivers/net/thunderx/base/nicvf_mbox.c:474:24: note: ‘mbx’ declared here
  474 |         struct nic_mbx mbx = { .msg = { 0 } };

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/thunderx/base/nicvf_mbox.c | 42 +++++++++++++-------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/thunderx/base/nicvf_mbox.c b/drivers/net/thunderx/base/nicvf_mbox.c
index 0e0176974d..29407f75fa 100644
--- a/drivers/net/thunderx/base/nicvf_mbox.c
+++ b/drivers/net/thunderx/base/nicvf_mbox.c
@@ -212,7 +212,7 @@ int
 nicvf_mbox_set_mac_addr(struct nicvf *nic,
 			const uint8_t mac[NICVF_MAC_ADDR_SIZE])
 {
-	struct nic_mbx mbx = { .msg = {0} };
+	struct nic_mbx mbx = { };
 	int i;
 
 	mbx.msg.msg = NIC_MBOX_MSG_SET_MAC;
@@ -226,7 +226,7 @@ nicvf_mbox_set_mac_addr(struct nicvf *nic,
 int
 nicvf_mbox_config_cpi(struct nicvf *nic, uint32_t qcnt)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_CPI_CFG;
 	mbx.cpi_cfg.vf_id = nic->vf_id;
@@ -239,7 +239,7 @@ nicvf_mbox_config_cpi(struct nicvf *nic, uint32_t qcnt)
 int
 nicvf_mbox_get_rss_size(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_RSS_SIZE;
 	mbx.rss_size.vf_id = nic->vf_id;
@@ -251,7 +251,7 @@ nicvf_mbox_get_rss_size(struct nicvf *nic)
 int
 nicvf_mbox_config_rss(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 	struct nicvf_rss_reta_info *rss = &nic->rss_info;
 	size_t tot_len = rss->rss_size;
 	size_t cur_len;
@@ -284,7 +284,7 @@ int
 nicvf_mbox_rq_config(struct nicvf *nic, uint16_t qidx,
 		     struct pf_rq_cfg *pf_rq_cfg)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_RQ_CFG;
 	mbx.rq.qs_num = nic->vf_id;
@@ -296,7 +296,7 @@ nicvf_mbox_rq_config(struct nicvf *nic, uint16_t qidx,
 int
 nicvf_mbox_sq_config(struct nicvf *nic, uint16_t qidx)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_SQ_CFG;
 	mbx.sq.qs_num = nic->vf_id;
@@ -309,7 +309,7 @@ nicvf_mbox_sq_config(struct nicvf *nic, uint16_t qidx)
 int
 nicvf_mbox_qset_config(struct nicvf *nic, struct pf_qs_cfg *qs_cfg)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 #if NICVF_BYTE_ORDER == NICVF_BIG_ENDIAN
 	qs_cfg->be = 1;
@@ -325,7 +325,7 @@ nicvf_mbox_qset_config(struct nicvf *nic, struct pf_qs_cfg *qs_cfg)
 int
 nicvf_mbox_request_sqs(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 	size_t i;
 
 	assert_primary(nic);
@@ -346,7 +346,7 @@ nicvf_mbox_request_sqs(struct nicvf *nic)
 int
 nicvf_mbox_rq_drop_config(struct nicvf *nic, uint16_t qidx, bool enable)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 	struct pf_rq_drop_cfg *drop_cfg;
 
 	/* Enable CQ drop to reserve sufficient CQEs for all tx packets */
@@ -365,7 +365,7 @@ nicvf_mbox_rq_drop_config(struct nicvf *nic, uint16_t qidx, bool enable)
 int
 nicvf_mbox_update_hw_max_frs(struct nicvf *nic, uint16_t mtu)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_SET_MAX_FRS;
 	mbx.frs.max_frs = mtu;
@@ -376,7 +376,7 @@ nicvf_mbox_update_hw_max_frs(struct nicvf *nic, uint16_t mtu)
 int
 nicvf_mbox_rq_sync(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	/* Make sure all packets in the pipeline are written back into mem */
 	mbx.msg.msg = NIC_MBOX_MSG_RQ_SW_SYNC;
@@ -387,7 +387,7 @@ nicvf_mbox_rq_sync(struct nicvf *nic)
 int
 nicvf_mbox_rq_bp_config(struct nicvf *nic, uint16_t qidx, bool enable)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_RQ_BP_CFG;
 	mbx.rq.qs_num = nic->vf_id;
@@ -401,7 +401,7 @@ nicvf_mbox_rq_bp_config(struct nicvf *nic, uint16_t qidx, bool enable)
 int
 nicvf_mbox_loopback_config(struct nicvf *nic, bool enable)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.lbk.msg = NIC_MBOX_MSG_LOOPBACK;
 	mbx.lbk.vf_id = nic->vf_id;
@@ -414,7 +414,7 @@ nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask,
 			       uint8_t tx_stat_mask, uint16_t rq_stat_mask,
 			       uint16_t sq_stat_mask)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.reset_stat.msg = NIC_MBOX_MSG_RESET_STAT_COUNTER;
 	mbx.reset_stat.rx_stat_mask = rx_stat_mask;
@@ -427,7 +427,7 @@ nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask,
 int
 nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.lbk.msg = NIC_MBOX_MSG_SET_LINK;
 	mbx.lbk.vf_id = nic->vf_id;
@@ -439,7 +439,7 @@ nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable)
 int
 nicvf_mbox_change_mode(struct nicvf *nic, struct change_link_mode *cfg)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.mode.msg = NIC_MBOX_MSG_CHANGE_MODE;
 	mbx.mode.vf_id = nic->vf_id;
@@ -453,7 +453,7 @@ nicvf_mbox_change_mode(struct nicvf *nic, struct change_link_mode *cfg)
 void
 nicvf_mbox_shutdown(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_SHUTDOWN;
 	nicvf_mbox_send_msg_to_pf(nic, &mbx);
@@ -462,7 +462,7 @@ nicvf_mbox_shutdown(struct nicvf *nic)
 void
 nicvf_mbox_cfg_done(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE;
 	nicvf_mbox_send_async_msg_to_pf(nic, &mbx);
@@ -471,7 +471,7 @@ nicvf_mbox_cfg_done(struct nicvf *nic)
 void
 nicvf_mbox_link_change(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
 	nicvf_mbox_send_async_msg_to_pf(nic, &mbx);
@@ -480,7 +480,7 @@ nicvf_mbox_link_change(struct nicvf *nic)
 void
 nicvf_mbox_reset_xcast(struct nicvf *nic)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.msg.msg = NIC_MBOX_MSG_RESET_XCAST;
 	nicvf_mbox_send_msg_to_pf(nic, &mbx);
@@ -489,7 +489,7 @@ nicvf_mbox_reset_xcast(struct nicvf *nic)
 int
 nicvf_mbox_set_xcast(struct nicvf *nic, uint8_t  mode, uint64_t mac)
 {
-	struct nic_mbx mbx = { .msg = { 0 } };
+	struct nic_mbx mbx = { };
 
 	mbx.xcast.msg = NIC_MBOX_MSG_SET_XCAST;
 	mbx.xcast.mode = mode;
-- 
2.45.2


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

* [PATCH v2 3/3] examples/flow_filtering: fix gcc 15 overflow warning
  2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 1/3] crypto/cnxk: fix gcc 15 warning Stephen Hemminger
  2025-01-20 23:23   ` [PATCH v2 2/3] net/thunderx/base: fix build with Gcc 15 Stephen Hemminger
@ 2025-01-20 23:23   ` Stephen Hemminger
  2025-01-22 10:50   ` [PATCH v2 0/3] Fix warnings when using gcc 15 David Marchand
  3 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-20 23:23 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, shperetz, Ori Kam

Gcc 15 no longer allows initialization of arrays with strings
because the null character is dropped. Resolve by using an
array initializer.

../examples/flow_filtering/snippets/snippet_match_mpls.c: In function ‘snippet_mpls_create_pattern_template’:
../examples/flow_filtering/snippets/snippet_match_mpls.c:62:31: warning: initializer-string for array of ‘unsigned char’ is too long [-Wunterminated-string-initialization]
   62 |                 .label_tc_s = "\xff\xff\xf1",
      |                               ^~~~~~~~~~~~~~

Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases snippets")
Cc: shperetz@nvidia.com

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/flow_filtering/snippets/snippet_match_mpls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/flow_filtering/snippets/snippet_match_mpls.c b/examples/flow_filtering/snippets/snippet_match_mpls.c
index a2e429f686..8382ec7041 100644
--- a/examples/flow_filtering/snippets/snippet_match_mpls.c
+++ b/examples/flow_filtering/snippets/snippet_match_mpls.c
@@ -59,7 +59,7 @@ snippet_mpls_create_pattern_template(uint16_t port_id, struct rte_flow_error *er
 		 * the Traffic Class set to 0,
 		 * and the Bottom of Stack bit set to 1.
 		 */
-		.label_tc_s = "\xff\xff\xf1",
+		.label_tc_s = { 0xff, 0xff, 0xf1 },
 	};
 
 	/* Define the flow pattern template. */
-- 
2.45.2


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

* Re: [PATCH v2 0/3] Fix warnings when using gcc 15
  2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
                     ` (2 preceding siblings ...)
  2025-01-20 23:23   ` [PATCH v2 3/3] examples/flow_filtering: fix gcc 15 overflow warning Stephen Hemminger
@ 2025-01-22 10:50   ` David Marchand
  3 siblings, 0 replies; 21+ messages in thread
From: David Marchand @ 2025-01-22 10:50 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Tue, Jan 21, 2025 at 12:25 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> Three fixes need to make current main branch build cleanly with
> current pre-release of Gcc 15.
>
> Stephen Hemminger (3):
>   crypto/cnxk: fix gcc 15 warning
>   net/thunderx/base: fix build with Gcc 15
>   examples/flow_filtering: fix gcc 15 overflow warning
>
>  drivers/crypto/cnxk/cnxk_se.h                 |  2 +-
>  drivers/net/thunderx/base/nicvf_mbox.c        | 42 +++++++++----------
>  .../snippets/snippet_match_mpls.c             |  2 +-
>  3 files changed, 23 insertions(+), 23 deletions(-)

Tested with OBS builds on Fedora rawhide.
Series applied, thanks Stephen.


-- 
David Marchand


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

* [PATCH v3 00/15] Add attributes to allocation functions
       [not found] <20250110170603.538756-1-stephen@networkplumber.or>
  2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
@ 2025-01-23 16:28 ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 01/15] fib: add allocation function attributes Stephen Hemminger
                     ` (14 more replies)
  1 sibling, 15 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger


This patch series builds on the allocation function attributes
added in 24.11 release. These annotations will allow for compiler
to flag cases where a pointer is allocated with one function
but incorrectly passed to a different free function.

The current code base does this correctly now, but adding
attributes will catch future bugs, or errors in user programs.

For each of these patches, the free function prototype
needs to be reordered to be before the function attribute
of the allocator.

Checkpatch perl script falsely complains in a couple patches
because it doesn't really understand C syntax for attributes.

v3 - fix another spot where free function prototype needs to be moved.

Stephen Hemminger (15):
  fib: add allocation function attributes
  rib: annotate rib allocation functions
  hash: add allocation function attributes
  lpm: add allocation function attributes
  pipeline: add allocation function attributes
  acl: add allocation function attributes
  bitratestats: add allocation function attributes
  member: add allocation function attributes
  mempool: add allocation function attributes
  eventdev: add allocation function attributes
  ring: add allocation function attributes
  reorder: add allocation function attributes
  compressdev: add allocation function attributes
  telemetry: add allocation function attributes
  sched: add allocation function attributes

 lib/acl/rte_acl.h                 | 26 ++++++++-------
 lib/bitratestats/rte_bitrate.h    | 20 +++++------
 lib/compressdev/rte_comp.h        | 28 ++++++++--------
 lib/eventdev/rte_event_ring.h     | 27 +++++++--------
 lib/fib/rte_fib.h                 | 26 ++++++++-------
 lib/fib/rte_fib6.h                | 24 +++++++-------
 lib/fib/trie.h                    |  7 ++--
 lib/hash/rte_fbk_hash.h           | 24 +++++++-------
 lib/hash/rte_hash.h               | 21 ++++++------
 lib/lpm/rte_lpm.h                 | 23 ++++++-------
 lib/lpm/rte_lpm6.h                | 23 ++++++-------
 lib/member/rte_member.h           | 24 +++++++-------
 lib/mempool/rte_mempool.h         | 37 +++++++++++----------
 lib/pipeline/rte_port_in_action.h | 55 ++++++++++++++++---------------
 lib/pipeline/rte_table_action.h   | 53 +++++++++++++++--------------
 lib/reorder/rte_reorder.h         | 23 ++++++-------
 lib/rib/rte_rib.h                 | 24 +++++++-------
 lib/rib/rte_rib6.h                | 24 +++++++-------
 lib/ring/rte_ring.h               | 22 +++++++------
 lib/sched/rte_sched.h             | 23 +++++++------
 lib/telemetry/rte_telemetry.h     | 21 ++++++------
 21 files changed, 296 insertions(+), 259 deletions(-)

-- 
2.45.2


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

* [PATCH v3 01/15] fib: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 02/15] rib: annotate rib allocation functions Stephen Hemminger
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

Use function attributes to catch cases where fib table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/fib/rte_fib.h  | 26 +++++++++++++++-----------
 lib/fib/rte_fib6.h | 24 +++++++++++++-----------
 lib/fib/trie.h     |  7 ++++---
 3 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h
index 496d137d48..65c24d5459 100644
--- a/lib/fib/rte_fib.h
+++ b/lib/fib/rte_fib.h
@@ -17,8 +17,10 @@
 
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_rcu_qsbr.h>
 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -128,6 +130,17 @@ struct rte_fib_rcu_config {
 	uint32_t reclaim_max;
 };
 
+
+/**
+ * Free an FIB object.
+ *
+ * @param fib
+ *   FIB object handle created by rte_fib_create().
+ *   If fib is NULL, no operation is performed.
+ */
+void
+rte_fib_free(struct rte_fib *fib);
+
 /**
  * Create FIB
  *
@@ -142,7 +155,8 @@ struct rte_fib_rcu_config {
  *  NULL otherwise with rte_errno set to an appropriate values.
  */
 struct rte_fib *
-rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf);
+rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf)
+	__rte_malloc __rte_dealloc(rte_fib_free, 1);
 
 /**
  * Find an existing FIB object and return a pointer to it.
@@ -157,16 +171,6 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf);
 struct rte_fib *
 rte_fib_find_existing(const char *name);
 
-/**
- * Free an FIB object.
- *
- * @param fib
- *   FIB object handle created by rte_fib_create().
- *   If fib is NULL, no operation is performed.
- */
-void
-rte_fib_free(struct rte_fib *fib);
-
 /**
  * Add a route to the FIB.
  *
diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h
index 21f0492374..b03b24421c 100644
--- a/lib/fib/rte_fib6.h
+++ b/lib/fib/rte_fib6.h
@@ -82,6 +82,17 @@ struct rte_fib6_conf {
 	};
 };
 
+
+/**
+ * Free an FIB object.
+ *
+ * @param fib
+ *   FIB object handle created by rte_fib6_create().
+ *   If fib is NULL, no operation is performed.
+ */
+void
+rte_fib6_free(struct rte_fib6 *fib);
+
 /**
  * Create FIB
  *
@@ -96,7 +107,8 @@ struct rte_fib6_conf {
  *  NULL otherwise with rte_errno set to an appropriate values.
  */
 struct rte_fib6 *
-rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
+rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
+	__rte_malloc __rte_dealloc(rte_fib6_free, 1);
 
 /**
  * Find an existing FIB object and return a pointer to it.
@@ -111,16 +123,6 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
 struct rte_fib6 *
 rte_fib6_find_existing(const char *name);
 
-/**
- * Free an FIB object.
- *
- * @param fib
- *   FIB object handle created by rte_fib6_create().
- *   If fib is NULL, no operation is performed.
- */
-void
-rte_fib6_free(struct rte_fib6 *fib);
-
 /**
  * Add a route to the FIB.
  *
diff --git a/lib/fib/trie.h b/lib/fib/trie.h
index f87fc0f6d2..bcb161702b 100644
--- a/lib/fib/trie.h
+++ b/lib/fib/trie.h
@@ -129,12 +129,13 @@ LOOKUP_FUNC(2b, uint16_t, 1)
 LOOKUP_FUNC(4b, uint32_t, 2)
 LOOKUP_FUNC(8b, uint64_t, 3)
 
-void *
-trie_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
-
 void
 trie_free(void *p);
 
+void *
+trie_create(const char *name, int socket_id, struct rte_fib6_conf *conf)
+	__rte_malloc __rte_dealloc(trie_free, 1);
+
 rte_fib6_lookup_fn_t
 trie_get_lookup_fn(void *p, enum rte_fib6_lookup_type type);
 
-- 
2.45.2


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

* [PATCH v3 02/15] rib: annotate rib allocation functions
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 01/15] fib: add allocation function attributes Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 03/15] hash: add allocation function attributes Stephen Hemminger
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin

Add function attributes to catch cases where rib is allocated
and not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/rib/rte_rib.h  | 24 +++++++++++++-----------
 lib/rib/rte_rib6.h | 24 +++++++++++++-----------
 2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h
index 2054d3cebd..f30b85d79a 100644
--- a/lib/rib/rte_rib.h
+++ b/lib/rib/rte_rib.h
@@ -230,6 +230,17 @@ rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh);
 int
 rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh);
 
+
+/**
+ * Free an RIB object.
+ *
+ * @param rib
+ *   RIB object handle created with rte_rib_create().
+ *   If rib is NULL, no operation is performed.
+ */
+void
+rte_rib_free(struct rte_rib *rib);
+
 /**
  * Create RIB
  *
@@ -245,7 +256,8 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh);
  */
 struct rte_rib *
 rte_rib_create(const char *name, int socket_id,
-	       const struct rte_rib_conf *conf);
+	       const struct rte_rib_conf *conf)
+	__rte_malloc __rte_dealloc(rte_rib_free, 1);
 
 /**
  * Find an existing RIB object and return a pointer to it.
@@ -259,16 +271,6 @@ rte_rib_create(const char *name, int socket_id,
 struct rte_rib *
 rte_rib_find_existing(const char *name);
 
-/**
- * Free an RIB object.
- *
- * @param rib
- *   RIB object handle created with rte_rib_create().
- *   If rib is NULL, no operation is performed.
- */
-void
-rte_rib_free(struct rte_rib *rib);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h
index a60756f798..d9514acf82 100644
--- a/lib/rib/rte_rib6.h
+++ b/lib/rib/rte_rib6.h
@@ -294,6 +294,17 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh);
 int
 rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh);
 
+
+/**
+ * Free an RIB object.
+ *
+ * @param rib
+ *   RIB object handle created with rte_rib6_create().
+ *   If rib is NULL, no operation is performed.
+ */
+void
+rte_rib6_free(struct rte_rib6 *rib);
+
 /**
  * Create RIB
  *
@@ -309,7 +320,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh);
  */
 struct rte_rib6 *
 rte_rib6_create(const char *name, int socket_id,
-		const struct rte_rib6_conf *conf);
+		const struct rte_rib6_conf *conf)
+	__rte_malloc __rte_dealloc(rte_rib6_free, 1);
 
 /**
  * Find an existing RIB object and return a pointer to it.
@@ -323,16 +335,6 @@ rte_rib6_create(const char *name, int socket_id,
 struct rte_rib6 *
 rte_rib6_find_existing(const char *name);
 
-/**
- * Free an RIB object.
- *
- * @param rib
- *   RIB object handle created with rte_rib6_create().
- *   If rib is NULL, no operation is performed.
- */
-void
-rte_rib6_free(struct rte_rib6 *rib);
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.45.2


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

* [PATCH v3 03/15] hash: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 01/15] fib: add allocation function attributes Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 02/15] rib: annotate rib allocation functions Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 04/15] lpm: " Stephen Hemminger
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin

Use function attributes to catch cases where hash table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/hash/rte_fbk_hash.h | 24 +++++++++++++-----------
 lib/hash/rte_hash.h     | 21 +++++++++++----------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/lib/hash/rte_fbk_hash.h b/lib/hash/rte_fbk_hash.h
index 1f0c1d1b6c..b1a43f37b4 100644
--- a/lib/hash/rte_fbk_hash.h
+++ b/lib/hash/rte_fbk_hash.h
@@ -322,6 +322,16 @@ rte_fbk_hash_get_load_factor(struct rte_fbk_hash_table *ht)
  */
 struct rte_fbk_hash_table *rte_fbk_hash_find_existing(const char *name);
 
+
+/**
+ * Free all memory used by a hash table.
+ * Has no effect on hash tables allocated in memory zones
+ *
+ * @param ht
+ *   Hash table to deallocate.
+ */
+void rte_fbk_hash_free(struct rte_fbk_hash_table *ht);
+
 /**
  * Create a new hash table for use with four byte keys.
  *
@@ -339,17 +349,9 @@ struct rte_fbk_hash_table *rte_fbk_hash_find_existing(const char *name);
  *    - EEXIST - a memzone with the same name already exists
  *    - ENOMEM - no appropriate memory area found in which to create memzone
  */
-struct rte_fbk_hash_table * \
-rte_fbk_hash_create(const struct rte_fbk_hash_params *params);
-
-/**
- * Free all memory used by a hash table.
- * Has no effect on hash tables allocated in memory zones
- *
- * @param ht
- *   Hash table to deallocate.
- */
-void rte_fbk_hash_free(struct rte_fbk_hash_table *ht);
+struct rte_fbk_hash_table *
+rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
+	__rte_malloc __rte_dealloc(rte_fbk_hash_free, 1);
 
 #ifdef __cplusplus
 }
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 05ab447e4a..736fb15885 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -125,6 +125,15 @@ struct rte_hash_rcu_config {
 /** @internal A hash table structure. */
 struct rte_hash;
 
+/**
+ * De-allocate all memory used by hash table.
+ *
+ * @param h
+ *   Hash table to free, if NULL, the function does nothing.
+ */
+void
+rte_hash_free(struct rte_hash *h);
+
 /**
  * Create a new hash table.
  *
@@ -143,7 +152,8 @@ struct rte_hash;
  *    - ENOMEM - no appropriate memory area found in which to create memzone
  */
 struct rte_hash *
-rte_hash_create(const struct rte_hash_parameters *params);
+rte_hash_create(const struct rte_hash_parameters *params)
+	__rte_malloc __rte_dealloc(rte_hash_free, 1);
 
 /**
  * Set a new hash compare function other than the default one.
@@ -171,15 +181,6 @@ void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func);
 struct rte_hash *
 rte_hash_find_existing(const char *name);
 
-/**
- * De-allocate all memory used by hash table.
- *
- * @param h
- *   Hash table to free, if NULL, the function does nothing.
- */
-void
-rte_hash_free(struct rte_hash *h);
-
 /**
  * Reset all hash structure, by zeroing all entries.
  * When RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF is enabled,
-- 
2.45.2


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

* [PATCH v3 04/15] lpm: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (2 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 03/15] hash: add allocation function attributes Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 05/15] pipeline: " Stephen Hemminger
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson, Vladimir Medvedkin

Use function attributes to catch cases where lpm table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/lpm/rte_lpm.h  | 23 ++++++++++++-----------
 lib/lpm/rte_lpm6.h | 23 ++++++++++++-----------
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h
index 329dc1aad4..7df64f06b1 100644
--- a/lib/lpm/rte_lpm.h
+++ b/lib/lpm/rte_lpm.h
@@ -140,6 +140,16 @@ struct rte_lpm_rcu_config {
 				 */
 };
 
+/**
+ * Free an LPM object.
+ *
+ * @param lpm
+ *   LPM object handle
+ *   If lpm is NULL, no operation is performed.
+ */
+void
+rte_lpm_free(struct rte_lpm *lpm);
+
 /**
  * Create an LPM object.
  *
@@ -161,7 +171,8 @@ struct rte_lpm_rcu_config {
  */
 struct rte_lpm *
 rte_lpm_create(const char *name, int socket_id,
-		const struct rte_lpm_config *config);
+	       const struct rte_lpm_config *config)
+	__rte_malloc __rte_dealloc(rte_lpm_free, 1);
 
 /**
  * Find an existing LPM object and return a pointer to it.
@@ -176,16 +187,6 @@ rte_lpm_create(const char *name, int socket_id,
 struct rte_lpm *
 rte_lpm_find_existing(const char *name);
 
-/**
- * Free an LPM object.
- *
- * @param lpm
- *   LPM object handle
- *   If lpm is NULL, no operation is performed.
- */
-void
-rte_lpm_free(struct rte_lpm *lpm);
-
 /**
  * Associate RCU QSBR variable with an LPM object.
  *
diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h
index 079187ca56..08b5618613 100644
--- a/lib/lpm/rte_lpm6.h
+++ b/lib/lpm/rte_lpm6.h
@@ -34,6 +34,16 @@ struct rte_lpm6_config {
 	int flags;               /**< This field is currently unused. */
 };
 
+/**
+ * Free an LPM object.
+ *
+ * @param lpm
+ *   LPM object handle
+ *   If lpm is NULL, no operation is performed.
+ */
+void
+rte_lpm6_free(struct rte_lpm6 *lpm);
+
 /**
  * Create an LPM object.
  *
@@ -55,7 +65,8 @@ struct rte_lpm6_config {
  */
 struct rte_lpm6 *
 rte_lpm6_create(const char *name, int socket_id,
-		const struct rte_lpm6_config *config);
+		const struct rte_lpm6_config *config)
+	__rte_malloc __rte_dealloc(rte_lpm6_free, 1);
 
 /**
  * Find an existing LPM object and return a pointer to it.
@@ -70,16 +81,6 @@ rte_lpm6_create(const char *name, int socket_id,
 struct rte_lpm6 *
 rte_lpm6_find_existing(const char *name);
 
-/**
- * Free an LPM object.
- *
- * @param lpm
- *   LPM object handle
- *   If lpm is NULL, no operation is performed.
- */
-void
-rte_lpm6_free(struct rte_lpm6 *lpm);
-
 /**
  * Add a rule to the LPM table.
  *
-- 
2.45.2


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

* [PATCH v3 05/15] pipeline: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (3 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 04/15] lpm: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 06/15] acl: " Stephen Hemminger
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use function attributes to catch cases where pipeline is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pipeline/rte_port_in_action.h | 55 ++++++++++++++++---------------
 lib/pipeline/rte_table_action.h   | 53 +++++++++++++++--------------
 2 files changed, 56 insertions(+), 52 deletions(-)

diff --git a/lib/pipeline/rte_port_in_action.h b/lib/pipeline/rte_port_in_action.h
index 9d17bae988..ee6cc59fae 100644
--- a/lib/pipeline/rte_port_in_action.h
+++ b/lib/pipeline/rte_port_in_action.h
@@ -164,18 +164,6 @@ struct rte_port_in_action_lb_params {
  */
 struct rte_port_in_action_profile;
 
-/**
- * Input port action profile create.
- *
- * @param[in] socket_id
- *   CPU socket ID for the internal data structures memory allocation.
- * @return
- *   Input port action profile handle on success, NULL otherwise.
- */
-__rte_experimental
-struct rte_port_in_action_profile *
-rte_port_in_action_profile_create(uint32_t socket_id);
-
 /**
  * Input port action profile free.
  *
@@ -189,6 +177,19 @@ __rte_experimental
 int
 rte_port_in_action_profile_free(struct rte_port_in_action_profile *profile);
 
+/**
+ * Input port action profile create.
+ *
+ * @param[in] socket_id
+ *   CPU socket ID for the internal data structures memory allocation.
+ * @return
+ *   Input port action profile handle on success, NULL otherwise.
+ */
+__rte_experimental
+struct rte_port_in_action_profile *
+rte_port_in_action_profile_create(uint32_t socket_id)
+	__rte_malloc __rte_dealloc(rte_port_in_action_profile_free, 1);
+
 /**
  * Input port action profile action register.
  *
@@ -236,6 +237,19 @@ rte_port_in_action_profile_freeze(struct rte_port_in_action_profile *profile);
  */
 struct rte_port_in_action;
 
+/**
+ * Input port action free.
+ *
+ * @param[in] action
+ *   Handle to input port action object (needs to be valid).
+ *   If action is NULL, no operation is performed.
+ * @return
+ *   Always zero.
+ */
+__rte_experimental
+int
+rte_port_in_action_free(struct rte_port_in_action *action);
+
 /**
  * Input port action create.
  *
@@ -252,21 +266,8 @@ struct rte_port_in_action;
  */
 __rte_experimental
 struct rte_port_in_action *
-rte_port_in_action_create(struct rte_port_in_action_profile *profile,
-	uint32_t socket_id);
-
-/**
- * Input port action free.
- *
- * @param[in] action
- *   Handle to input port action object (needs to be valid).
- *   If action is NULL, no operation is performed.
- * @return
- *   Always zero.
- */
-__rte_experimental
-int
-rte_port_in_action_free(struct rte_port_in_action *action);
+rte_port_in_action_create(struct rte_port_in_action_profile *profile, uint32_t socket_id)
+	__rte_malloc __rte_dealloc(rte_port_in_action_free, 1);
 
 /**
  * Input port params get.
diff --git a/lib/pipeline/rte_table_action.h b/lib/pipeline/rte_table_action.h
index 47a7bdfc01..e8b4d8b33d 100644
--- a/lib/pipeline/rte_table_action.h
+++ b/lib/pipeline/rte_table_action.h
@@ -54,6 +54,7 @@
 
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_compat.h>
 #include <rte_ether.h>
 #include <rte_ip6.h>
@@ -812,17 +813,6 @@ struct rte_table_action_decap_params {
  */
 struct rte_table_action_profile;
 
-/**
- * Table action profile create.
- *
- * @param[in] common
- *   Common action configuration.
- * @return
- *   Table action profile handle on success, NULL otherwise.
- */
-__rte_experimental
-struct rte_table_action_profile *
-rte_table_action_profile_create(struct rte_table_action_common_config *common);
 
 /**
  * Table action profile free.
@@ -836,6 +826,19 @@ __rte_experimental
 int
 rte_table_action_profile_free(struct rte_table_action_profile *profile);
 
+/**
+ * Table action profile create.
+ *
+ * @param[in] common
+ *   Common action configuration.
+ * @return
+ *   Table action profile handle on success, NULL otherwise.
+ */
+__rte_experimental
+struct rte_table_action_profile *
+rte_table_action_profile_create(struct rte_table_action_common_config *common)
+	__rte_malloc __rte_dealloc(rte_table_action_profile_free, 1);
+
 /**
  * Table action profile action register.
  *
@@ -881,6 +884,18 @@ rte_table_action_profile_freeze(struct rte_table_action_profile *profile);
  */
 struct rte_table_action;
 
+/**
+ * Table action free.
+ *
+ * @param[in] action
+ *   Handle to table action object (needs to be valid).
+ * @return
+ *   Zero on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_table_action_free(struct rte_table_action *action);
+
 /**
  * Table action create.
  *
@@ -898,20 +913,8 @@ struct rte_table_action;
  */
 __rte_experimental
 struct rte_table_action *
-rte_table_action_create(struct rte_table_action_profile *profile,
-	uint32_t socket_id);
-
-/**
- * Table action free.
- *
- * @param[in] action
- *   Handle to table action object (needs to be valid).
- * @return
- *   Zero on success, non-zero error code otherwise.
- */
-__rte_experimental
-int
-rte_table_action_free(struct rte_table_action *action);
+rte_table_action_create(struct rte_table_action_profile *profile, uint32_t socket_id)
+	__rte_malloc __rte_dealloc(rte_table_action_free, 1);
 
 /**
  * Table action table params get.
-- 
2.45.2


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

* [PATCH v3 06/15] acl: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (4 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 05/15] pipeline: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 07/15] bitratestats: " Stephen Hemminger
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Konstantin Ananyev

Use function attributes to catch cases where acl table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/acl/rte_acl.h | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib/acl/rte_acl.h b/lib/acl/rte_acl.h
index ca75a6f220..b95f8778c3 100644
--- a/lib/acl/rte_acl.h
+++ b/lib/acl/rte_acl.h
@@ -133,6 +133,19 @@ struct rte_acl_param {
 };
 
 
+/** @internal opaque ACL handle */
+struct rte_acl_ctx;
+
+/**
+ * De-allocate all memory used by ACL context.
+ *
+ * @param ctx
+ *   ACL context to free
+ *   If ctx is NULL, no operation is performed.
+ */
+void
+rte_acl_free(struct rte_acl_ctx *ctx);
+
 /**
  * Create a new ACL context.
  *
@@ -145,7 +158,8 @@ struct rte_acl_param {
  *   - EINVAL - invalid parameter passed to function
  */
 struct rte_acl_ctx *
-rte_acl_create(const struct rte_acl_param *param);
+rte_acl_create(const struct rte_acl_param *param)
+	__rte_malloc __rte_dealloc(rte_acl_free, 1);
 
 /**
  * Find an existing ACL context object and return a pointer to it.
@@ -160,16 +174,6 @@ rte_acl_create(const struct rte_acl_param *param);
 struct rte_acl_ctx *
 rte_acl_find_existing(const char *name);
 
-/**
- * De-allocate all memory used by ACL context.
- *
- * @param ctx
- *   ACL context to free
- *   If ctx is NULL, no operation is performed.
- */
-void
-rte_acl_free(struct rte_acl_ctx *ctx);
-
 /**
  * Add rules to an existing ACL context.
  * This function is not multi-thread safe.
-- 
2.45.2


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

* [PATCH v3 07/15] bitratestats: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (5 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 06/15] acl: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 08/15] member: " Stephen Hemminger
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Use function attributes to catch cases where bitratestats is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/bitratestats/rte_bitrate.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h
index 979a712837..27951f3e28 100644
--- a/lib/bitratestats/rte_bitrate.h
+++ b/lib/bitratestats/rte_bitrate.h
@@ -17,16 +17,6 @@ extern "C" {
  */
 struct rte_stats_bitrates;
 
-
-/**
- * Allocate a bitrate statistics structure
- *
- * @return
- *   - Pointer to structure on success
- *   - NULL on error (zmalloc failure)
- */
-struct rte_stats_bitrates *rte_stats_bitrate_create(void);
-
 /**
  * Free bitrate statistics structure
  *
@@ -36,6 +26,16 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void);
  */
 void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data);
 
+/**
+ * Allocate a bitrate statistics structure
+ *
+ * @return
+ *   - Pointer to structure on success
+ *   - NULL on error (zmalloc failure)
+ */
+struct rte_stats_bitrates *rte_stats_bitrate_create(void)
+	__rte_malloc __rte_dealloc(rte_stats_bitrate_free, 1);
+
 /**
  * Register bitrate statistics with the metric library.
  *
-- 
2.45.2


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

* [PATCH v3 08/15] member: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (6 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 07/15] bitratestats: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 09/15] mempool: " Stephen Hemminger
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Yipeng Wang, Sameh Gobriel

Use function attributes to catch cases where member table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/member/rte_member.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/member/rte_member.h b/lib/member/rte_member.h
index 109bdd000b..0235bb0a81 100644
--- a/lib/member/rte_member.h
+++ b/lib/member/rte_member.h
@@ -341,6 +341,16 @@ struct __rte_cache_aligned rte_member_parameters {
 struct rte_member_setsum *
 rte_member_find_existing(const char *name);
 
+/**
+ * De-allocate memory used by set-summary.
+ *
+ * @param setsum
+ *   Pointer to the set summary.
+ *   If setsum is NULL, no operation is performed.
+ */
+void
+rte_member_free(struct rte_member_setsum *setsum);
+
 /**
  * Create set-summary (SS).
  *
@@ -351,7 +361,8 @@ rte_member_find_existing(const char *name);
  *   Return value is NULL if the creation failed.
  */
 struct rte_member_setsum *
-rte_member_create(const struct rte_member_parameters *params);
+rte_member_create(const struct rte_member_parameters *params)
+	__rte_malloc __rte_dealloc(rte_member_free, 1);
 
 /**
  * Lookup key in set-summary (SS).
@@ -528,17 +539,6 @@ int
 rte_member_report_heavyhitter(const struct rte_member_setsum *setsum,
 			      void **keys, uint64_t *counts);
 
-
-/**
- * De-allocate memory used by set-summary.
- *
- * @param setsum
- *   Pointer to the set summary.
- *   If setsum is NULL, no operation is performed.
- */
-void
-rte_member_free(struct rte_member_setsum *setsum);
-
 /**
  * Reset the set-summary tables. E.g. reset bits to be 0 in BF,
  * reset set_id in each entry to be RTE_MEMBER_NO_MATCH in HT based SS.
-- 
2.45.2


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

* [PATCH v3 09/15] mempool: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (7 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 08/15] member: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 10/15] eventdev: " Stephen Hemminger
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Morten Brørup, Andrew Rybchenko

Use function attributes to catch cases where mempool is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
---
 lib/mempool/rte_mempool.h | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 7bdc92b812..c495cc012f 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1012,6 +1012,20 @@ typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
  */
 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
 
+/**
+ * Free a mempool
+ *
+ * Unlink the mempool from global list, free the memory chunks, and all
+ * memory referenced by the mempool. The objects must not be used by
+ * other cores as they will be freed.
+ *
+ * @param mp
+ *   A pointer to the mempool structure.
+ *   If NULL then, the function does nothing.
+ */
+void
+rte_mempool_free(struct rte_mempool *mp);
+
 /**
  * Create a new mempool named *name* in memory.
  *
@@ -1095,7 +1109,8 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
 		   unsigned cache_size, unsigned private_data_size,
 		   rte_mempool_ctor_t *mp_init, void *mp_init_arg,
 		   rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
-		   int socket_id, unsigned flags);
+		   int socket_id, unsigned int flags)
+	__rte_malloc __rte_dealloc(rte_mempool_free, 1);
 
 /**
  * Create an empty mempool
@@ -1132,22 +1147,10 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
  *   with rte_errno set appropriately. See rte_mempool_create() for details.
  */
 struct rte_mempool *
-rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
-	unsigned cache_size, unsigned private_data_size,
-	int socket_id, unsigned flags);
-/**
- * Free a mempool
- *
- * Unlink the mempool from global list, free the memory chunks, and all
- * memory referenced by the mempool. The objects must not be used by
- * other cores as they will be freed.
- *
- * @param mp
- *   A pointer to the mempool structure.
- *   If NULL then, the function does nothing.
- */
-void
-rte_mempool_free(struct rte_mempool *mp);
+rte_mempool_create_empty(const char *name, unsigned int n, unsigned int elt_size,
+			 unsigned int cache_size, unsigned int private_data_size,
+			 int socket_id, unsigned int flags)
+		__rte_malloc __rte_dealloc(rte_mempool_free, 1);
 
 /**
  * Add physically contiguous memory for objects in the pool at init
-- 
2.45.2


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

* [PATCH v3 10/15] eventdev: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (8 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 09/15] mempool: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 11/15] ring: " Stephen Hemminger
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jerin Jacob

Use function attributes to catch cases where eventdev is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eventdev/rte_event_ring.h | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/lib/eventdev/rte_event_ring.h b/lib/eventdev/rte_event_ring.h
index 5769da269e..a8f308e4d6 100644
--- a/lib/eventdev/rte_event_ring.h
+++ b/lib/eventdev/rte_event_ring.h
@@ -247,7 +247,18 @@ int
 rte_event_ring_init(struct rte_event_ring *r, const char *name,
 	unsigned int count, unsigned int flags);
 
-/*
+
+/**
+ * De-allocate all memory used by the ring.
+ *
+ * @param r
+ *   Pointer to ring to created with rte_event_ring_create().
+ *   If r is NULL, no operation is performed.
+ */
+void
+rte_event_ring_free(struct rte_event_ring *r);
+
+/**
  * Create an event ring structure
  *
  * This function allocates memory and initializes an event ring inside that
@@ -288,8 +299,8 @@ rte_event_ring_init(struct rte_event_ring *r, const char *name,
  *    - ENOMEM - no appropriate memory area found in which to create memzone
  */
 struct rte_event_ring *
-rte_event_ring_create(const char *name, unsigned int count, int socket_id,
-		unsigned int flags);
+rte_event_ring_create(const char *name, unsigned int count, int socket_id, unsigned int flags)
+	__rte_malloc __rte_dealloc(rte_event_ring_free, 1);
 
 /**
  * Search for an event ring based on its name
@@ -304,16 +315,6 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id,
 struct rte_event_ring *
 rte_event_ring_lookup(const char *name);
 
-/**
- * De-allocate all memory used by the ring.
- *
- * @param r
- *   Pointer to ring to created with rte_event_ring_create().
- *   If r is NULL, no operation is performed.
- */
-void
-rte_event_ring_free(struct rte_event_ring *r);
-
 /**
  * Return the size of the event ring.
  *
-- 
2.45.2


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

* [PATCH v3 11/15] ring: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (9 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 10/15] eventdev: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 12/15] reorder: " Stephen Hemminger
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Honnappa Nagarahalli, Konstantin Ananyev

Use function attributes to catch cases where ring is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ring/rte_ring.h | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lib/ring/rte_ring.h b/lib/ring/rte_ring.h
index 63a71d5871..15340a1981 100644
--- a/lib/ring/rte_ring.h
+++ b/lib/ring/rte_ring.h
@@ -119,6 +119,16 @@ ssize_t rte_ring_get_memsize(unsigned int count);
 int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
 	unsigned int flags);
 
+
+/**
+ * De-allocate all memory used by the ring.
+ *
+ * @param r
+ *   Ring to free.
+ *   If NULL then, the function does nothing.
+ */
+void rte_ring_free(struct rte_ring *r);
+
 /**
  * Create a new ring named *name* in memory.
  *
@@ -183,16 +193,8 @@ int rte_ring_init(struct rte_ring *r, const char *name, unsigned int count,
  *    - ENOMEM - no appropriate memory area found in which to create memzone
  */
 struct rte_ring *rte_ring_create(const char *name, unsigned int count,
-				 int socket_id, unsigned int flags);
-
-/**
- * De-allocate all memory used by the ring.
- *
- * @param r
- *   Ring to free.
- *   If NULL then, the function does nothing.
- */
-void rte_ring_free(struct rte_ring *r);
+				 int socket_id, unsigned int flags)
+	__rte_malloc __rte_dealloc(rte_ring_free, 1);
 
 /**
  * Dump the status of the ring to a file.
-- 
2.45.2


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

* [PATCH v3 12/15] reorder: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (10 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 11/15] ring: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 13/15] compressdev: " Stephen Hemminger
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Volodymyr Fialko

Use function attributes to catch cases where reorder table is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Volodymyr Fialko <vfialko@marvell.com>
---
 lib/reorder/rte_reorder.h | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/reorder/rte_reorder.h b/lib/reorder/rte_reorder.h
index 56a6507f9f..2f26ed7df3 100644
--- a/lib/reorder/rte_reorder.h
+++ b/lib/reorder/rte_reorder.h
@@ -44,6 +44,16 @@ rte_reorder_seqn(struct rte_mbuf *mbuf)
 		rte_reorder_seqn_t *);
 }
 
+/**
+ * Free reorder buffer instance.
+ *
+ * @param b
+ *   Pointer to reorder buffer instance.
+ *   If b is NULL, no operation is performed.
+ */
+void
+rte_reorder_free(struct rte_reorder_buffer *b);
+
 /**
  * Create a new reorder buffer instance
  *
@@ -64,7 +74,8 @@ rte_reorder_seqn(struct rte_mbuf *mbuf)
  *    - EINVAL - invalid parameters
  */
 struct rte_reorder_buffer *
-rte_reorder_create(const char *name, unsigned socket_id, unsigned int size);
+rte_reorder_create(const char *name, unsigned int socket_id, unsigned int size)
+	__rte_malloc __rte_dealloc(rte_reorder_free, 1);
 
 /**
  * Initializes given reorder buffer instance
@@ -111,16 +122,6 @@ rte_reorder_find_existing(const char *name);
 void
 rte_reorder_reset(struct rte_reorder_buffer *b);
 
-/**
- * Free reorder buffer instance.
- *
- * @param b
- *   Pointer to reorder buffer instance.
- *   If b is NULL, no operation is performed.
- */
-void
-rte_reorder_free(struct rte_reorder_buffer *b);
-
 /**
  * Insert given mbuf in reorder buffer in its correct position
  *
-- 
2.45.2


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

* [PATCH v3 13/15] compressdev: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (11 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 12/15] reorder: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 14/15] telemetry: " Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 15/15] sched: " Stephen Hemminger
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Fan Zhang, Ashish Gupta

Use function attributes to catch cases where compressdev is allocated
but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/compressdev/rte_comp.h | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/lib/compressdev/rte_comp.h b/lib/compressdev/rte_comp.h
index d66a4b1cb9..f86e773b28 100644
--- a/lib/compressdev/rte_comp.h
+++ b/lib/compressdev/rte_comp.h
@@ -480,6 +480,19 @@ struct __rte_cache_aligned rte_comp_op {
 	 */
 };
 
+
+/**
+ * Free operation structure
+ * If operation has been allocate from a rte_mempool, then the operation will
+ * be returned to the mempool.
+ *
+ * @param op
+ *   Compress operation pointer allocated from rte_comp_op_alloc()
+ *   If op is NULL, no operation is performed.
+ */
+void
+rte_comp_op_free(struct rte_comp_op *op);
+
 /**
  * Creates an operation pool
  *
@@ -501,7 +514,8 @@ struct __rte_cache_aligned rte_comp_op {
 struct rte_mempool *
 rte_comp_op_pool_create(const char *name,
 		unsigned int nb_elts, unsigned int cache_size,
-		uint16_t user_size, int socket_id);
+		uint16_t user_size, int socket_id)
+	__rte_malloc __rte_dealloc(rte_comp_op_free, 1);
 
 /**
  * Allocate an operation from a mempool with default parameters set
@@ -533,18 +547,6 @@ int
 rte_comp_op_bulk_alloc(struct rte_mempool *mempool,
 		struct rte_comp_op **ops, uint16_t nb_ops);
 
-/**
- * Free operation structure
- * If operation has been allocate from a rte_mempool, then the operation will
- * be returned to the mempool.
- *
- * @param op
- *   Compress operation pointer allocated from rte_comp_op_alloc()
- *   If op is NULL, no operation is performed.
- */
-void
-rte_comp_op_free(struct rte_comp_op *op);
-
 /**
  * Bulk free operation structures
  * If operations have been allocated from an rte_mempool, then the operations
-- 
2.45.2


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

* [PATCH v3 14/15] telemetry: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (12 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 13/15] compressdev: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  2025-01-23 16:28   ` [PATCH v3 15/15] sched: " Stephen Hemminger
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson

Use function attributes to catch cases where telemetry data
is allocated but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/telemetry/rte_telemetry.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/telemetry/rte_telemetry.h b/lib/telemetry/rte_telemetry.h
index 2ccfc73a5f..c4554e4028 100644
--- a/lib/telemetry/rte_telemetry.h
+++ b/lib/telemetry/rte_telemetry.h
@@ -414,16 +414,6 @@ __rte_experimental
 int
 rte_telemetry_register_cmd_arg(const char *cmd, telemetry_arg_cb fn, void *arg, const char *help);
 
-/**
- * Get a pointer to a container with memory allocated. The container is to be
- * used embedded within an existing telemetry dict/array.
- *
- * @return
- *  Pointer to a container.
- */
-struct rte_tel_data *
-rte_tel_data_alloc(void);
-
 /**
  * @internal
  * Free a container that has memory allocated.
@@ -435,6 +425,17 @@ rte_tel_data_alloc(void);
 void
 rte_tel_data_free(struct rte_tel_data *data);
 
+/**
+ * Get a pointer to a container with memory allocated. The container is to be
+ * used embedded within an existing telemetry dict/array.
+ *
+ * @return
+ *  Pointer to a container.
+ */
+struct rte_tel_data *
+rte_tel_data_alloc(void)
+	__rte_malloc __rte_dealloc(rte_tel_data_free, 1);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.45.2


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

* [PATCH v3 15/15] sched: add allocation function attributes
  2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
                     ` (13 preceding siblings ...)
  2025-01-23 16:28   ` [PATCH v3 14/15] telemetry: " Stephen Hemminger
@ 2025-01-23 16:28   ` Stephen Hemminger
  14 siblings, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2025-01-23 16:28 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Use function attributes to catch cases where sched port config
is allocated but not freed correctly.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/sched/rte_sched.h | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/lib/sched/rte_sched.h b/lib/sched/rte_sched.h
index 222e6b3583..7ae570aa1b 100644
--- a/lib/sched/rte_sched.h
+++ b/lib/sched/rte_sched.h
@@ -310,16 +310,7 @@ struct rte_sched_port_params {
  * Configuration
  */
 
-/**
- * Hierarchical scheduler port configuration
- *
- * @param params
- *   Port scheduler configuration parameter structure
- * @return
- *   Handle to port scheduler instance upon success or NULL otherwise.
- */
-struct rte_sched_port *
-rte_sched_port_config(struct rte_sched_port_params *params);
+struct rte_sched_port;
 
 /**
  * Hierarchical scheduler port free
@@ -331,6 +322,18 @@ rte_sched_port_config(struct rte_sched_port_params *params);
 void
 rte_sched_port_free(struct rte_sched_port *port);
 
+/**
+ * Hierarchical scheduler port configuration
+ *
+ * @param params
+ *   Port scheduler configuration parameter structure
+ * @return
+ *   Handle to port scheduler instance upon success or NULL otherwise.
+ */
+struct rte_sched_port *
+rte_sched_port_config(struct rte_sched_port_params *params)
+	__rte_malloc __rte_dealloc(rte_sched_port_free, 1);
+
 /**
  * Hierarchical scheduler pipe profile add
  *
-- 
2.45.2


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

end of thread, other threads:[~2025-01-23 16:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250110170603.538756-1-stephen@networkplumber.or>
2025-01-20 23:23 ` [PATCH v2 0/3] Fix warnings when using gcc 15 Stephen Hemminger
2025-01-20 23:23   ` [PATCH v2 1/3] crypto/cnxk: fix gcc 15 warning Stephen Hemminger
2025-01-20 23:23   ` [PATCH v2 2/3] net/thunderx/base: fix build with Gcc 15 Stephen Hemminger
2025-01-20 23:23   ` [PATCH v2 3/3] examples/flow_filtering: fix gcc 15 overflow warning Stephen Hemminger
2025-01-22 10:50   ` [PATCH v2 0/3] Fix warnings when using gcc 15 David Marchand
2025-01-23 16:28 ` [PATCH v3 00/15] Add attributes to allocation functions Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 01/15] fib: add allocation function attributes Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 02/15] rib: annotate rib allocation functions Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 03/15] hash: add allocation function attributes Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 04/15] lpm: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 05/15] pipeline: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 06/15] acl: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 07/15] bitratestats: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 08/15] member: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 09/15] mempool: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 10/15] eventdev: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 11/15] ring: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 12/15] reorder: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 13/15] compressdev: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 14/15] telemetry: " Stephen Hemminger
2025-01-23 16:28   ` [PATCH v3 15/15] sched: " Stephen Hemminger

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