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 D62D243D17; Thu, 21 Mar 2024 16:46:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54E50427E1; Thu, 21 Mar 2024 16:46:45 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id C60154029E for ; Thu, 21 Mar 2024 16:46:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id F148920B74C0; Thu, 21 Mar 2024 08:46:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com F148920B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1711036003; bh=INCXlJPGORpvDaJUjLHZmlCFBW/Iw4V4nGYl54vXKpQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WYI+SchCGyV68/+fsTj4fLtkc0heNgtTAHDaJcqvZ4hsqSUkeytgfSmO6Cg5ain15 hXO2Ucrla1AQlGacc1MO61n2QNopGGe14lrg59idj4k3UcX6KkP5aYWTECvNvbEGq+ ZQ1qltMZCskzKs9c/FaIHgL61uKNOO9//5e6xsd0= Date: Thu, 21 Mar 2024 08:46:42 -0700 From: Tyler Retzlaff To: Stephen Hemminger Cc: dev@dpdk.org, Akhil Goyal , Aman Singh , Anatoly Burakov , Bruce Richardson , Byron Marohn , Conor Walsh , Cristian Dumitrescu , Dariusz Sosnowski , David Hunt , Jerin Jacob , Jingjing Wu , Kirill Rybalchenko , Konstantin Ananyev , Matan Azrad , Ori Kam , Radu Nicolau , Ruifeng Wang , Sameh Gobriel , Sivaprasad Tummala , Suanming Mou , Sunil Kumar Kori , Vamsi Attunuru , Viacheslav Ovsiienko , Vladimir Medvedkin , Yipeng Wang , Yuying Zhang Subject: Re: [PATCH 00/15] fix packing of structs when building with MSVC Message-ID: <20240321154642.GA11257@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1710968771-16435-1-git-send-email-roretzla@linux.microsoft.com> <20240321083219.5504c54f@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240321083219.5504c54f@hermes.local> 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 Thu, Mar 21, 2024 at 08:32:19AM -0700, Stephen Hemminger wrote: > On Wed, 20 Mar 2024 14:05:56 -0700 > Tyler Retzlaff wrote: > > > MSVC struct packing is not compatible with GCC provide a macro that can > > be used to push existing pack value and sets packing to 1-byte. The > > existing __rte_packed macro is then used to restore the pack value > > prior to the push. > > > > Instead of providing macros exclusively for MSVC and for GCC the > > existing macro is deliberately utilized to trigger a warning if no > > existing packing has been pushed allowing easy identification of > > locations where the __rte_msvc_pack is missing. > > > > I've decided to only add the macro to packed structs that are built > > for Windows. It seems there is little value in adding the macro tree > > wide and if new code arrives that is built on Windows the __rte_packed > > will flag where the preamble macro is required. > > > > Why is packed used so many places in DPDK? > Packed should be reserved for things like network protocols > with unaligned fields. I made the same observation. Even network frame formats can be handled without packing so long as you do some extra work to copy small units of data out which is often worth doing manually and once only instead of obfuscated behind codegen and direct field access. > Many of these structure have no holes and are naturally packed. > Adding packed attribute unnecessarily can generate poor code on > architectures that do not support unaligned access. For the specific case where their fields and alignments are naturally packed I'm not entirely certain you get different codegen but I agree it might and we'd like to avoid it if it does. In a lot of the cases it seems to be drivers and often appears like it is either structs that are used to hardware registers or firmware protocol data units. Both of which may be need packing. I will commit to removing packing in structs in this series iff individual maintainers identify the specific structs in reply to the series. If there is no request I'll leave it to them to figure out. Maintainers should review and request removal as appropriate. Thanks!