[PATCH v7 27/27] net/ice: avoid rte malloc in flow pattern match
Anatoly Burakov
anatoly.burakov at intel.com
Fri Feb 20 11:14:34 CET 2026
Currently, when allocating buffers for pattern match items and flow item
storage, we are using rte_zmalloc followed by immediate rte_free. This
memory does not need to be stored in hugepage memory, so replace it with
regular malloc/free.
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
drivers/net/intel/ice/ice_acl_filter.c | 3 ++-
drivers/net/intel/ice/ice_fdir_filter.c | 5 +++--
drivers/net/intel/ice/ice_generic_flow.c | 15 +++++++--------
drivers/net/intel/ice/ice_hash.c | 3 ++-
drivers/net/intel/ice/ice_switch_filter.c | 5 +++--
5 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/net/intel/ice/ice_acl_filter.c b/drivers/net/intel/ice/ice_acl_filter.c
index 38e30a4f62..6754a40044 100644
--- a/drivers/net/intel/ice/ice_acl_filter.c
+++ b/drivers/net/intel/ice/ice_acl_filter.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -1009,7 +1010,7 @@ ice_acl_parse(struct ice_adapter *ad,
*meta = filter;
error:
- rte_free(item);
+ free(item);
return ret;
}
diff --git a/drivers/net/intel/ice/ice_fdir_filter.c b/drivers/net/intel/ice/ice_fdir_filter.c
index 0b92b9ab38..93ab803b44 100644
--- a/drivers/net/intel/ice/ice_fdir_filter.c
+++ b/drivers/net/intel/ice/ice_fdir_filter.c
@@ -3,6 +3,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <rte_flow.h>
#include <rte_hash.h>
#include <rte_hash_crc.h>
@@ -2845,11 +2846,11 @@ ice_fdir_parse(struct ice_adapter *ad,
rte_free(filter->pkt_buf);
}
- rte_free(item);
+ free(item);
return ret;
error:
rte_free(filter->pkt_buf);
- rte_free(item);
+ free(item);
return ret;
}
diff --git a/drivers/net/intel/ice/ice_generic_flow.c b/drivers/net/intel/ice/ice_generic_flow.c
index 644958cccf..62f0c334a1 100644
--- a/drivers/net/intel/ice/ice_generic_flow.c
+++ b/drivers/net/intel/ice/ice_generic_flow.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -2313,19 +2314,17 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
}
item_num++;
- items = rte_zmalloc("ice_pattern",
- item_num * sizeof(struct rte_flow_item), 0);
+ items = calloc(item_num, sizeof(struct rte_flow_item));
if (!items) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
NULL, "No memory for PMD internal items.");
return NULL;
}
- pattern_match_item = rte_zmalloc("ice_pattern_match_item",
- sizeof(struct ice_pattern_match_item), 0);
+ pattern_match_item = calloc(1, sizeof(struct ice_pattern_match_item));
if (!pattern_match_item) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "Failed to allocate memory.");
- rte_free(items);
+ free(items);
return NULL;
}
@@ -2344,7 +2343,7 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
pattern_match_item->pattern_list =
array[i].pattern_list;
pattern_match_item->meta = array[i].meta;
- rte_free(items);
+ free(items);
return pattern_match_item;
}
}
@@ -2352,8 +2351,8 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
unsupported:
rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
pattern, "Unsupported pattern");
- rte_free(items);
- rte_free(pattern_match_item);
+ free(items);
+ free(pattern_match_item);
return NULL;
}
diff --git a/drivers/net/intel/ice/ice_hash.c b/drivers/net/intel/ice/ice_hash.c
index f9db530504..77829e607b 100644
--- a/drivers/net/intel/ice/ice_hash.c
+++ b/drivers/net/intel/ice/ice_hash.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_debug.h>
#include <rte_ether.h>
@@ -1236,7 +1237,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
*meta = rss_meta_ptr;
else
rte_free(rss_meta_ptr);
- rte_free(pattern_match_item);
+ free(pattern_match_item);
return ret;
}
diff --git a/drivers/net/intel/ice/ice_switch_filter.c b/drivers/net/intel/ice/ice_switch_filter.c
index 28bc775a2c..b25e5eaad3 100644
--- a/drivers/net/intel/ice/ice_switch_filter.c
+++ b/drivers/net/intel/ice/ice_switch_filter.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -1877,14 +1878,14 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
rte_free(sw_meta_ptr);
}
- rte_free(pattern_match_item);
+ free(pattern_match_item);
return 0;
error:
rte_free(list);
rte_free(sw_meta_ptr);
- rte_free(pattern_match_item);
+ free(pattern_match_item);
return -rte_errno;
}
--
2.47.3
More information about the dev
mailing list