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 B6C5A43B0D; Tue, 13 Feb 2024 19:48:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 533FC42E1B; Tue, 13 Feb 2024 19:48:20 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E38B442E10 for ; Tue, 13 Feb 2024 19:48:18 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2C84A20B2000; Tue, 13 Feb 2024 10:48:18 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2C84A20B2000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707850098; bh=uiMjfiY4nAxd5azDWzmHOG9RRwxAchNYv47sa0w2qsQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AtZ56ge0++XHzzbCx9qqfU+WoVvJhMrTjBss1IrEnfFBtCbgB3O63G9h8KTHZCyvb 21Vg4U6KZDYmCHmOQ3zAu4KZ9JF8InjPb99g839yKmArBPRqYFcjGEEDZW2iumeCAI sUIz/k53B43x+Asltv/VuhSyn9fBLEhvuYvKqUXI= Date: Tue, 13 Feb 2024 10:48:18 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, Andrew Boyer , Andrew Rybchenko , Bruce Richardson , Chenbo Xia , Konstantin Ananyev , Maxime Coquelin Subject: Re: [PATCH v2] mbuf: replace GCC marker extension with C11 anonymous unions Message-ID: <20240213184818.GA20546@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> 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> <98CBD80474FA8B44BF855DF32C47DC35E9F20F@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F20F@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Tue, Feb 13, 2024 at 05:58:21PM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Tuesday, 13 February 2024 07.46 > > > > 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: this seems like a good suggestion i will evaluate it. at least it gets rid of all the extra nesting if there are no unforseen problems. > > struct rte_mbuf { > - RTE_MARKER cacheline0; > + union { > + char cacheline0[RTE_CACHE_LINE_MIN_SIZE]; > > + 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: yeah, i wondered if i should. i'll do it since it does seem more consistent to just pad out both cachelines explicitly instead of just doing all but the last. we probably don't need to align struct rte_mbuf type if we do since it will cause it to be naturally aligned to RTE_CACHE_LINE_MIN_SIZE. > > /* 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]; > > + 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. noted, i'll make the change. thanks!