From patchwork Wed Feb 14 16:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 136792 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5543843B38; Wed, 14 Feb 2024 17:40:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 573B94338E; Wed, 14 Feb 2024 17:36:54 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 26EC742E95 for ; Wed, 14 Feb 2024 17:36:09 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1C2F320B2027; Wed, 14 Feb 2024 08:36:06 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1C2F320B2027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707928568; bh=5c9/vuZQZ+h9YQQEwX5Iv0l18LCKqwfr1HKPBBUBccA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owFdvvxBDPXs9Y8LYvtMeMRhyV6LckFUa3uTy/QKQkvpvhWbIT5xv3/iu9HPwUmG1 GFVAQ/wwu9SElQG42065Efecrf5paHcrDxY+a8vr2HhNO62GBI/UJjwuWwjVB/JQqf 1b0HUACT0HLdCigu7FNsSG7b/YFjbV3dTNQmtZZI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Cristian Dumitrescu , David Christensen , David Hunt , Ferruh Yigit , Honnappa Nagarahalli , Jasvinder Singh , Jerin Jacob , Kevin Laatz , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Sameh Gobriel , Stanislaw Kardach , Thomas Monjalon , Vladimir Medvedkin , Yipeng Wang , Tyler Retzlaff Subject: [PATCH v4 38/39] graph: use C11 alignas Date: Wed, 14 Feb 2024 08:36:03 -0800 Message-Id: <1707928564-28796-39-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707928564-28796-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. * Replace use of __rte_aligned(a) on variables/fields with alignas(a). Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup --- lib/graph/graph_private.h | 4 ++-- lib/graph/graph_stats.c | 4 ++-- lib/graph/rte_graph.h | 4 ++-- lib/graph/rte_graph_worker_common.h | 17 ++++++++++------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h index fb88d4b..7e4d9f8 100644 --- a/lib/graph/graph_private.h +++ b/lib/graph/graph_private.h @@ -71,11 +71,11 @@ struct node { * Structure that holds the graph scheduling workqueue node stream. * Used for mcore dispatch model. */ -struct graph_mcore_dispatch_wq_node { +struct __rte_cache_aligned graph_mcore_dispatch_wq_node { rte_graph_off_t node_off; uint16_t nb_objs; void *objs[RTE_GRAPH_BURST_SIZE]; -} __rte_cache_aligned; +}; /** * @internal diff --git a/lib/graph/graph_stats.c b/lib/graph/graph_stats.c index cc32245..2fb808b 100644 --- a/lib/graph/graph_stats.c +++ b/lib/graph/graph_stats.c @@ -28,7 +28,7 @@ struct cluster_node { struct rte_node *nodes[]; }; -struct rte_graph_cluster_stats { +struct __rte_cache_aligned rte_graph_cluster_stats { /* Header */ rte_graph_cluster_stats_cb_t fn; uint32_t cluster_node_size; /* Size of struct cluster_node */ @@ -38,7 +38,7 @@ struct rte_graph_cluster_stats { size_t sz; struct cluster_node clusters[]; -} __rte_cache_aligned; +}; #define boarder_model_dispatch() \ fprintf(f, "+-------------------------------+---------------+--------" \ diff --git a/lib/graph/rte_graph.h b/lib/graph/rte_graph.h index 2d37d5e..ecfec20 100644 --- a/lib/graph/rte_graph.h +++ b/lib/graph/rte_graph.h @@ -200,7 +200,7 @@ struct rte_graph_cluster_stats_param { * * @see struct rte_graph_cluster_stats_param::fn */ -struct rte_graph_cluster_node_stats { +struct __rte_cache_aligned rte_graph_cluster_node_stats { uint64_t ts; /**< Current timestamp. */ uint64_t calls; /**< Current number of calls made. */ uint64_t objs; /**< Current number of objs processed. */ @@ -225,7 +225,7 @@ struct rte_graph_cluster_node_stats { rte_node_t id; /**< Node identifier of stats. */ uint64_t hz; /**< Cycles per seconds. */ char name[RTE_NODE_NAMESIZE]; /**< Name of the node. */ -} __rte_cache_aligned; +}; /** * Create Graph. diff --git a/lib/graph/rte_graph_worker_common.h b/lib/graph/rte_graph_worker_common.h index 4045a7a..36d864e 100644 --- a/lib/graph/rte_graph_worker_common.h +++ b/lib/graph/rte_graph_worker_common.h @@ -12,6 +12,8 @@ * process, enqueue and move streams of objects to the next nodes. */ +#include + #include #include #include @@ -43,7 +45,7 @@ * * Data structure to hold graph data. */ -struct rte_graph { +struct __rte_cache_aligned rte_graph { /* Fast path area. */ uint32_t tail; /**< Tail of circular buffer. */ uint32_t head; /**< Head of circular buffer. */ @@ -57,7 +59,8 @@ struct rte_graph { union { /* Fast schedule area for mcore dispatch model */ struct { - struct rte_graph_rq_head *rq __rte_cache_aligned; /* The run-queue */ + alignas(RTE_CACHE_LINE_SIZE) struct rte_graph_rq_head *rq; + /* The run-queue */ struct rte_graph_rq_head rq_head; /* The head for run-queue list */ unsigned int lcore_id; /**< The graph running Lcore. */ @@ -77,14 +80,14 @@ struct rte_graph { uint64_t nb_pkt_to_capture; char pcap_filename[RTE_GRAPH_PCAP_FILE_SZ]; /**< Pcap filename. */ uint64_t fence; /**< Fence. */ -} __rte_cache_aligned; +}; /** * @internal * * Data structure to hold node data. */ -struct rte_node { +struct __rte_cache_aligned rte_node { /* Slow path area */ uint64_t fence; /**< Fence. */ rte_graph_off_t next; /**< Index to next node. */ @@ -109,7 +112,7 @@ struct rte_node { }; /* Fast path area */ #define RTE_NODE_CTX_SZ 16 - uint8_t ctx[RTE_NODE_CTX_SZ] __rte_cache_aligned; /**< Node Context. */ + alignas(RTE_CACHE_LINE_SIZE) uint8_t ctx[RTE_NODE_CTX_SZ]; /**< Node Context. */ uint16_t size; /**< Total number of objects available. */ uint16_t idx; /**< Number of objects used. */ rte_graph_off_t off; /**< Offset of node in the graph reel. */ @@ -124,8 +127,8 @@ struct rte_node { rte_node_process_t process; /**< Process function. */ uint64_t process_u64; }; - struct rte_node *nodes[] __rte_cache_min_aligned; /**< Next nodes. */ -} __rte_cache_aligned; + alignas(RTE_CACHE_LINE_MIN_SIZE) struct rte_node *nodes[]; /**< Next nodes. */ +}; /** * @internal