From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B478B43B0C; Tue, 13 Feb 2024 17:58:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E18040A4B; Tue, 13 Feb 2024 17:58:27 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 9835E402D8 for ; Tue, 13 Feb 2024 17:58:26 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 96EF22088F; Tue, 13 Feb 2024 17:58:25 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Tue, 13 Feb 2024 17:58:21 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F20F@smartserver.smartshare.dk> In-Reply-To: <1707806741-29694-2-git-send-email-roretzla@linux.microsoft.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions Thread-Index: AdpeSEjFALu9DeKDSxWItmA1VXch4wAT9pAQ References: <1706657173-26166-2-git-send-email-roretzla@linux.microsoft.com> <1707806741-29694-1-git-send-email-roretzla@linux.microsoft.com> <1707806741-29694-2-git-send-email-roretzla@linux.microsoft.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Tyler Retzlaff" , Cc: "Andrew Boyer" , "Andrew Rybchenko" , "Bruce Richardson" , "Chenbo Xia" , "Konstantin Ananyev" , "Maxime Coquelin" 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 > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > Sent: Tuesday, 13 February 2024 07.46 >=20 > Replace the use of RTE_MARKER with C11 anonymous unions to improve > code portability between toolchains. How about combining the cacheline 0 marker and padding, like this: struct rte_mbuf { - RTE_MARKER cacheline0; + union { + char cacheline0[RTE_CACHE_LINE_MIN_SIZE]; =20 + struct { - void *buf_addr; /**< Virtual address of segment buffer. */ + void *buf_addr; /**< Virtual address of segment buffer. */ #if RTE_IOVA_IN_MBUF You could do the same with the cacheline1 marker: /* second cache line - fields only used in slow path or on TX */ - RTE_MARKER cacheline1 __rte_cache_min_aligned; + union { + char cacheline1[RTE_CACHE_LINE_MIN_SIZE]; =20 + struct { #if RTE_IOVA_IN_MBUF - /** - * Next segment of scattered packet. Must be NULL in the last - * segment or in case of non-segmented packet. - */ - struct rte_mbuf *next; + /** + * Next segment of scattered packet. Must be NULL in the last + * segment or in case of non-segmented packet. + */ + struct rte_mbuf *next; #else It also avoids the weird union between cacheline0 and buf_addr at the = beginning of the structure, and between cacheline1 and next/dynfield2 at = the beginning of the second cache line. And then you can omit the pad_cacheline0 array at the end of the first = part of the structure. BTW: char is a weaker type than uint8_t - i.e. it is easier to cast to = another type. It might be a personal preference, but I would use char instead of = uint8_t for the padding array.