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 0167043B37; Wed, 14 Feb 2024 14:12:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C93BA4026A; Wed, 14 Feb 2024 14:12:34 +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 303EE40263 for ; Wed, 14 Feb 2024 14:12:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707916352; 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=oTZGmtRfIdxfv0w5Crtw0AQXIBf+CukJpfe43rriYCE=; b=A/rGaPVu9o3gjrdIQNG7n2x06vEvTzS+Y0NgCJSI/xNcXRH4z8z3NaXxAEn16oRyQvYRqP vguOxPflXh/DzBC9KETXVu/AjRp9QJBX3xrPu+gmzOrzx6KZ4hTQt03N4OQF4TONeM9h5/ om6XqDdCVVQ7mcO9sxtzPLqusgBzosE= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-47CdX9cDMv-bZlK_pANoCQ-1; Wed, 14 Feb 2024 08:12:31 -0500 X-MC-Unique: 47CdX9cDMv-bZlK_pANoCQ-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2d0a0bd3ebaso56800751fa.2 for ; Wed, 14 Feb 2024 05:12:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707916350; x=1708521150; 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=oTZGmtRfIdxfv0w5Crtw0AQXIBf+CukJpfe43rriYCE=; b=ZocrRJ2opKbujM+tQMbYWpKayy6PCMuG/FuvZvnIzZkehnofY0lQs/GtdZrRgg3+me u4GeusZmJ8kZ81K5VS4kWjg3ju28rcN9bJMxR4l6tUzFvh3Kh9r6df7TCVP26CgJNW/c spEXVdNEgVFCHZbwOlFthQO835mibiK6a6z5Rd8nCcQoI/d9wk0WLfYIy5uLyHOocV5E jVPzPgp7BRsRj2cSyP0iD8qa536BHQzU4q5BO5UdPWITMDjq6+j+k+s69h/1E21jbVfT KHyL2eb0l2RLgGWDEY1XY+S+btsLo1SlAegNi3vvNBUrGAdEEo68MFiaaK54Jd4dK1X9 Q3XA== X-Gm-Message-State: AOJu0YwKgOuR+GJBNxbDMsN2eUSiKvW4HhUIf3awztKUMynCR4tMqVwf f99UzOg0Q8WshY7RnEpVkZrmu3zbVibSAB9v9CzX8argRudewrypXwDeKIhMHAn2lvc67s0mXPa mjI48EkgVllWtdjRO+YXEjgBzvmLsrwEzhIUAqiLnTbJfNIDCpVNudTYMaxUOeaLufKea/Hg9JD e756/4cj0u+LaaUGg= X-Received: by 2002:ac2:5497:0:b0:511:7734:c369 with SMTP id t23-20020ac25497000000b005117734c369mr1980716lfk.60.1707916349903; Wed, 14 Feb 2024 05:12:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuh8kUiIv8aAVFjDP3qcohp5OW8KeiH/TjYs/Xp9ujU2mGk4mcWlElQw8CD3oMyOjCnI26a1R7lskgJHDzoJ8= X-Received: by 2002:ac2:5497:0:b0:511:7734:c369 with SMTP id t23-20020ac25497000000b005117734c369mr1980695lfk.60.1707916349577; Wed, 14 Feb 2024 05:12:29 -0800 (PST) MIME-Version: 1.0 References: <1707873986-29352-1-git-send-email-roretzla@linux.microsoft.com> <1707894382-307-1-git-send-email-roretzla@linux.microsoft.com> <1707894382-307-9-git-send-email-roretzla@linux.microsoft.com> In-Reply-To: <1707894382-307-9-git-send-email-roretzla@linux.microsoft.com> From: David Marchand Date: Wed, 14 Feb 2024 14:12:17 +0100 Message-ID: Subject: Re: [PATCH v3 08/39] mbuf: remove unnecessary explicit alignment 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 Wed, Feb 14, 2024 at 8:07=E2=80=AFAM Tyler Retzlaff wrote: > > Remove explicit alignment with __rte_aligned(sizeof(T)) on buf_iova > field in the absence of packing the field should be correctly aligned. > > Signed-off-by: Tyler Retzlaff > --- > 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..7369e3e 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)); > + rte_iova_t buf_iova; > #else Before the change, for 32bits build: struct rte_mbuf { RTE_MARKER cacheline0; /* 0 0 */ void * buf_addr; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ rte_iova_t buf_iova __attribute__((__aligned__(8))); /* 8 8 */ RTE_MARKER64 rearm_data; /* 16 0 */ ... After the change: struct rte_mbuf { RTE_MARKER cacheline0; /* 0 0 */ void * buf_addr; /* 0 4 */ rte_iova_t buf_iova; /* 4 8 */ RTE_MARKER64 rearm_data; /* 12 0 */ ... So it looks like uint64_t is not naturally aligned on 8 bytes for x86 32 bits, which explains the current explicit constraint (and comment in the header). See also 586ec205bcbb ("mbuf: fix 64-bit address alignment in 32-bit builds= "). This results in a cascading offset changes triggering multiple build errors in vectorised code: In file included from ../../../git/pub/dpdk.org/main/lib/eal/x86/include/rte_vect.h:16, from ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c:5: ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c: In function =E2=80=98idpf_singleq_rearm_common=E2=80=99: ../../../git/pub/dpdk.org/main/lib/eal/include/rte_common.h:509:55: error: size of unnamed array is negative 509 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ^ ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c:68:17: note: in expansion of macro =E2=80=98RTE_BUILD_BUG_ON=E2=80=99 68 | RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, buf_iova= ) !=3D | ^~~~~~~~~~~~~~~~ ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c: In function =E2=80=98_idpf_singleq_recv_raw_pkts_avx512=E2=80=99: ../../../git/pub/dpdk.org/main/lib/eal/include/rte_common.h:509:55: error: size of unnamed array is negative 509 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ^ ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c:461:17: note: in expansion of macro =E2=80=98RTE_BUILD_BUG_ON=E2=80=99 461 | RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=3D | ^~~~~~~~~~~~~~~~ ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c: In function =E2=80=98_idpf_splitq_recv_raw_pkts_avx512=E2=80=99: ../../../git/pub/dpdk.org/main/lib/eal/include/rte_common.h:509:55: error: size of unnamed array is negative 509 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ^ ../../../git/pub/dpdk.org/main/drivers/common/idpf/idpf_common_rxtx_avx512.= c:921:17: note: in expansion of macro =E2=80=98RTE_BUILD_BUG_ON=E2=80=99 921 | RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, rearm_data) !=3D | ^~~~~~~~~~~~~~~~ --=20 David Marchand