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 9AFEA43C38; Tue, 5 Mar 2024 15:31:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1FA2A40270; Tue, 5 Mar 2024 15:31:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 1A1564026B for ; Tue, 5 Mar 2024 15:31:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709649064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QBzPNO36Y5nEErUhEXOOer/HndAu24QLid7I/KcVOUM=; b=iELX5x1QSnaDB3OECuTbFar1yJ7sdtIESgR+tRGpa1V+8oDDms63rH+A4C5UKwS9y1JYs3 fFquDPLkcRgq9/HABKSpeDhTepAMK3XOXSrKVXIS540Rf8wQxw6vTnbLl1NWj7wZFyp/NQ NUi9TN8upPraT8yxU2BEYX6ubrzJYvM= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-491-KwpeEFQ2OkWIX1f-1IcUIg-1; Tue, 05 Mar 2024 09:31:02 -0500 X-MC-Unique: KwpeEFQ2OkWIX1f-1IcUIg-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5132c85310aso4878517e87.2 for ; Tue, 05 Mar 2024 06:31:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709649061; x=1710253861; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QBzPNO36Y5nEErUhEXOOer/HndAu24QLid7I/KcVOUM=; b=kxX2KMstPmczGqfPSrJwCl0fTChmrHk8afCLqtIezsyWhDV+NXrFri7cuB5k9kAWOV t12j6LeS15WcyxDiTFtg1lsiuv3rxaFD2OfqAMGnEcM35t6n8vygl5VyDsL+47j6yVFU 94w6IfJCgkI9KQDEUmWDgFefC2yNzBaXNG4gcI0kAipoWTwe4cuuLMwg1eaDJ+m+3QRn n6wUIiOGqTkIdDQNEf39FhwN2V1RvkvnsawzV8DEcQa/IMTXqQbc96p+E/Mhd0aZ/BWS s2o7RZKwT6O1YN1vmPTRzqT0DDGjV62QnMZoeVD6Nl1OtYDGqRDDaS5bg/I1BkNGXr6b d6Tg== X-Gm-Message-State: AOJu0YybXBlRauPVY1Ptihfik9SQ5oS5ZE3Hwunzz7F1voR3UwFlTCIK M5cki29ihiFJeWLj7erIVumBEo2yJm1uDrDmVwXPiFtfJljmSxFrU1K3IvN1vlrGPRS74qGvoDw o6nuUFZNIuB+31MIQV2Obb+/snkUz8jwIf/bUMpnDduYovFIq+gbhlVtFrSQu4cd6DDgL18QITs GNZ0/2n1xZwReYAW4= X-Received: by 2002:a05:6512:b81:b0:512:fc00:7c6 with SMTP id b1-20020a0565120b8100b00512fc0007c6mr1668496lfv.51.1709649061327; Tue, 05 Mar 2024 06:31:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxhsOg6J/p7wnxk0C0lZQ/ei80IzQUcqi1BlHr2FTa8VSYUIF+A0bxeV4zT58VADKD0mbA8HC5HrW9wDUYznw= X-Received: by 2002:a05:6512:b81:b0:512:fc00:7c6 with SMTP id b1-20020a0565120b8100b00512fc0007c6mr1668474lfv.51.1709649060987; Tue, 05 Mar 2024 06:31:00 -0800 (PST) MIME-Version: 1.0 References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1709574764-9041-1-git-send-email-roretzla@linux.microsoft.com> <1709574764-9041-9-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1709574764-9041-9-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Tue, 5 Mar 2024 15:30:49 +0100 Message-ID: Subject: Re: [PATCH v7 08/39] mbuf: use C11 alignas To: Tyler Retzlaff Cc: dev@dpdk.org, 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Mon, Mar 4, 2024 at 6:54=E2=80=AFPM Tyler Retzlaff wrote: > > The current location used for __rte_aligned(a) for alignment of types > and variables is not compatible with MSVC. There is only a single > location accepted by both toolchains. > > For variables standard C11 offers alignas(a) supported by conformant > compilers i.e. both MSVC and GCC. > > For types the standard offers no alignment facility that compatibly > interoperates with C and C++ but may be achieved by relocating the > placement of __rte_aligned(a) to the aforementioned location accepted > by all currently supported toolchains. > > To allow alignment for both compilers do the following: > > * 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=C3=B8rup > Acked-by: Konstantin Ananyev > --- > lib/mbuf/rte_mbuf_core.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h > index 5688683..917a811 100644 > --- a/lib/mbuf/rte_mbuf_core.h > +++ b/lib/mbuf/rte_mbuf_core.h > @@ -463,7 +463,7 @@ enum { > /** > * The generic rte_mbuf, containing a packet mbuf. > */ > -struct rte_mbuf { > +struct __rte_cache_aligned rte_mbuf { > RTE_MARKER cacheline0; > > void *buf_addr; /**< Virtual address of segment buffer.= */ > @@ -476,7 +476,7 @@ struct rte_mbuf { > * same mbuf cacheline0 layout for 32-bit and 64-bit. This makes > * working on vector drivers easier. > */ > - rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t)); > + alignas(sizeof(rte_iova_t)) rte_iova_t buf_iova; > #else > /** > * Next segment of scattered packet. > @@ -662,7 +662,7 @@ struct rte_mbuf { > uint16_t timesync; > > uint32_t dynfield1[9]; /**< Reserved for dynamic fields. */ > -} __rte_cache_aligned; > +}; I probably missed the discussion, but why is cacheline1 not handled in this patch? I was expecting a: - RTE_MARKER cacheline1 __rte_cache_min_aligned; + alignas(RTE_CACHE_LINE_MIN_SIZE) RTE_MARKER cacheline1; --=20 David Marchand