From: Chengwen Feng <[email protected]>

Add a coccinelle script that codifies the socket to NUMA node
rename rules of the migration announced in the deprecation
notice.

The script is not applied now. Once the deprecation notice has
completed a release cycle, it will be used to generate a single
tree-wide conversion patch.

Coccinelle cannot express every needed change: designated
initializers, union field declarations, documentation and string
literals require manual adjustments. It also silently skips
functions whose signature carries unknown attribute macros
(e.g. __rte_unused).

Signed-off-by: Chengwen Feng <[email protected]>
---
 devtools/cocci/socket_to_numa_node.cocci | 152 +++++++++++++++++++++++
 1 file changed, 152 insertions(+)
 create mode 100644 devtools/cocci/socket_to_numa_node.cocci

diff --git a/devtools/cocci/socket_to_numa_node.cocci 
b/devtools/cocci/socket_to_numa_node.cocci
new file mode 100644
index 0000000000..76d91df053
--- /dev/null
+++ b/devtools/cocci/socket_to_numa_node.cocci
@@ -0,0 +1,152 @@
+// Convert the socket terminology to NUMA node terminology.
+//
+// This script codifies the rename rules of the socket to NUMA node
+// terminology migration announced in
+// doc/guides/rel_notes/deprecation.rst. The tree is not converted
+// yet: once the deprecation notice has completed a release cycle,
+// this script is used to generate a single tree-wide conversion
+// patch.
+//
+// Coccinelle cannot express every needed change: designated
+// initializers, union field declarations, documentation and string
+// literals require manual adjustments.
+//
+// Coccinelle also silently skips functions whose signature carries
+// unknown attribute macros (e.g. __rte_unused); call sites inside
+// such functions need manual conversion as well.
+//
+// The socket_id names are kept as deprecated aliases, applications
+// get one release to switch (see deprecation.rst).
+
+// Union member of the public structures.
+@@
+expression E;
+@@
+-E.socket_id
++E.numa_node
+
+@@
+expression E;
+@@
+-E->socket_id
++E->numa_node
+
+// EAL APIs.
+@@
+@@
+-SOCKET_ID_ANY
++RTE_NUMA_NODE_ANY
+
+@@
+@@
+-rte_socket_id()
++rte_numa_node()
+
+@@
+@@
+-rte_socket_count()
++rte_numa_node_count()
+
+@@
+expression E;
+@@
+-rte_socket_id_by_idx(E)
++rte_numa_node_by_idx(E)
+
+@@
+expression E;
+@@
+-rte_cpu_socket_id(E)
++rte_cpu_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_lcore_to_socket_id(E)
++rte_lcore_to_numa_node(E)
+
+// Legacy malloc APIs.
+@@
+expression E1, E2, E3, E4;
+@@
+-rte_malloc_socket(E1, E2, E3, E4)
++rte_malloc_onnode(E1, E2, E3, E4)
+
+@@
+expression E1, E2, E3, E4;
+@@
+-rte_zmalloc_socket(E1, E2, E3, E4)
++rte_zmalloc_onnode(E1, E2, E3, E4)
+
+@@
+expression E1, E2, E3, E4, E5;
+@@
+-rte_calloc_socket(E1, E2, E3, E4, E5)
++rte_calloc_onnode(E1, E2, E3, E4, E5)
+
+@@
+expression E1, E2, E3, E4;
+@@
+-rte_realloc_socket(E1, E2, E3, E4)
++rte_realloc_onnode(E1, E2, E3, E4)
+
+@@
+expression E;
+@@
+-rte_malloc_heap_get_socket(E)
++rte_malloc_heap_get_numa_node(E)
+
+@@
+expression E1, E2;
+@@
+-rte_malloc_get_socket_stats(E1, E2)
++rte_malloc_get_numa_stats(E1, E2)
+
+@@
+expression E;
+@@
+-rte_malloc_heap_socket_is_external(E)
++rte_malloc_heap_numa_is_external(E)
+
+@@
+@@
+-struct rte_malloc_socket_stats
++struct rte_malloc_numa_stats
+
+// Device APIs (the same pattern applies to every library that
+// exposed a device socket API).
+@@
+expression E;
+@@
+-rte_eth_dev_socket_id(E)
++rte_eth_dev_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_cryptodev_socket_id(E)
++rte_cryptodev_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_event_dev_socket_id(E)
++rte_event_dev_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_compressdev_socket_id(E)
++rte_compressdev_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_rawdev_socket_id(E)
++rte_rawdev_numa_node(E)
+
+@@
+expression E;
+@@
+-rte_ml_dev_socket_id(E)
++rte_ml_dev_numa_node(E)
-- 
2.55.0

Reply via email to