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 EE233439C9; Fri, 26 Jan 2024 00:31:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B4E8402A7; Fri, 26 Jan 2024 00:31:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id D124A40289 for ; Fri, 26 Jan 2024 00:31:43 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 1581620E56B9; Thu, 25 Jan 2024 15:31:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1581620E56B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1706225503; bh=OIGnTMyDi6RkymF3C2BKHovyWwDkrNlRkECXRiL20e4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KM55WUHgYNvOc659CLP/ecg8ULOu5Fts6RPLIaUq0A2cG6+lGsPM4ZochoOsSgZ58 iiHp3PVPloiPyTseVDRXGg2h/ZUAnCya7Wvua6eKgM7xy3ZEws608lHf6tHnAf1sKB BSyQ1pFvwP38qaGxfTmVV04R86y9T4f4PNxIS04c= Date: Thu, 25 Jan 2024 15:31:43 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, Mattias =?iso-8859-1?Q?R=F6nnblom?= , Anatoly Burakov , Bruce Richardson , David Christensen , Harry van Haaren , Konstantin Ananyev , Min Zhou , Ruifeng Wang , Stanislaw Kardach , thomas@monjalon.net Subject: Re: [PATCH] RFC: use C11 alignas instead of GCC attribute aligned Message-ID: <20240125233143.GA1920@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1700069997-4399-1-git-send-email-roretzla@linux.microsoft.com> <20240125183713.GA27715@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <98CBD80474FA8B44BF855DF32C47DC35E9F1A3@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: <98CBD80474FA8B44BF855DF32C47DC35E9F1A3@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 Thu, Jan 25, 2024 at 11:53:04PM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Thursday, 25 January 2024 19.37 > > > > ping. > > > > Please review this thread if you have time, the main point of > > discussion > > I would like to receive consensus on the following questions. > > > > 1. Should we continue to expand common alignments behind an __rte_macro > > > > i.e. what do we prefer to appear in code > > > > alignas(RTE_CACHE_LINE_MIN_SIZE) > > > > -- or -- > > > > __rte_cache_aligned > > > > One of the benefits of dropping the macro is it provides a clear visual > > indicator that it is not placed in the same location or get applied > > to types as is done with __attribute__((__aligned__(n))). > > We don't want our own proprietary variant of something that already exists in the C standard. Now that we have moved to C11, the __rte alignment macros should be considered obsolete. > > Note: I don't mind convenience macros for common use cases, so we could also introduce the macro suggested by Mattias [1]: ack > > #define RTE_CACHE_ALIGNAS alignas(RTE_CACHE_LINE_SIZE) > > [1]: https://inbox.dpdk.org/dev/dc3f3131-38e6-4219-861e-b31ec10c08bb@lysator.liu.se/ i'm good with this, it satisfies that it is a different name than the original and therefore achieves the same intent. i'll spin the patch series with this macro. > > > > > 2. where should we place alignas(n) or __rte_macro (if we use a macro) > > > > Should it be on the same line as the variable or field or on the > > preceeding line? > > > > /* same line example struct */ > > struct T { > > /* alignas(64) applies to field0 *not* struct T type declaration > > */ > > alignas(64) void *field0; > > void *field1; > > > > ... other fields ... > > > > alignas(64) uint64_t field5; > > uint32_t field6; > > > > ... more fields ... > > > > }; > > > > /* same line example array */ > > alignas(64) static const uint32_t array[4] = { ... }; > > > > -- or -- > > > > /* preceeding line example struct */ > > struct T { > > /* alignas(64) applies to field0 *not* struct T type declaration > > */ > > alignas(64) > > void *field0; > > void *field1; > > > > ... other fields ... > > > > alignas(64) > > uint64_t field5; > > uint32_t field6; > > > > ... more fields ... > > > > }; > > > > /* preceeding line example array */ > > alignas(64) > > static const uint32_t array[4] = { ... }; > > > > Searching the net for what other projects do, I came across this required placement [2]: > > uint64_t alignas(64) field5; > > [2]: https://lore.kernel.org/buildroot/20230730000851.6faa3391@windsurf/T/ > > So let's follow the standard's intention and put them on the same line. > On an case-by-case basis, we can wrap lines if it improves readability, like we do with function headers that have a lot of attributes. just fyi. the linked code is c++ and standard c++ has both semantic and syntactic differences from standard c. notably standard c is moving away from the notion that you can alignas types and instead you align variables/fields/members. further restricting placement is the need to choose an intersecting placement that works when consumed in either a c or c++ translation unit. so the options i present above are that intersection. ty > > > > > > I'll submit patches for lib/* once the discussion is concluded. > > > > thanks folks