From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23084606A320 for ; Tue, 1 Dec 2026 19:37:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=WwUlfWEF Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93993402BD; Tue, 1 Dec 2026 20:36:59 +0100 (CET) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by mails.dpdk.org (Postfix) with ESMTPS id AF562402B8 for ; Tue, 1 Dec 2026 20:36:58 +0100 (CET) Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-8a07078200fso6441780b3a.2 for ; Tue, 01 Dec 2026 11:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1796153817; x=1796758617; darn=dpdk.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Uy4o9xS0qEP1qY2MNjalxtZL1AeFqEV1liaFwbQ2S5M=; b=WwUlfWEFmo9bVFwY9J/S2hvCU1P0A+XDZVE5ryg3QGeLR+TaGnAKgLJwCxLGRyoy+0 r9+dXk71bpzkzV/GqmlXQI733yq+vtIQmIrUYfaSp/vgqCh3Ylo27Xj77fkYDxbKLgtI 5wD+qE2xnD+LuqrKv7/nKGzlVTYnH5ZooJqd+je7rX6M939pMlrZRu5Tvk99l36zy8EC a+EJ8Wi2V3BQ1d5L6Ag84xjGQiBWRCm/OH4F8ZpQdNQmL2sp5cJ2punLTIsBSB7/lAWf asfEeGajx6STi+MEEsT5D0wZixy8CrLvVLv5ScDheEvvvsBY3ryyhU6+FO5ZBwaSw+fn n3sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796153817; x=1796758617; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Uy4o9xS0qEP1qY2MNjalxtZL1AeFqEV1liaFwbQ2S5M=; b=dOtSxaJj0/ukQka/VZHbFMy7trVnUZRmdb9YzN22x/521hsZdisk9sCKu8NnAijwc3 yt+LEf32EO4VXHOaxiTkMuI21tbCF8mTPkeDdip8jffiV62RqYG/o/4LJnHBMvWxWRNp JgfP9Ub//i9bq1ZAHM6ojcaj4PkvDiKc32CYm+61zQ1rwTRbsxDHWhoc3Qw+wBAvrV4Y snuGWAox/0236lRw4n+Xf+Yj9DXzl4n6pQKGa4dVVpAxS0B/kZbJUCBq1gEDdXbeJ60u S+NWAbiGFOUXxaIu5C3b/SuuCuUi8gBG52KCM35Nlg/ZIJ/p4UKS0fxm+h5fiW9pzWCh NW/A== X-Forwarded-Encrypted: i=1; AL+hErHznlvtIbxvRu/MAKNUqJuNwsWn7qUDwVYHOPkLy1Ef6x+GfE1VgXjw7CBkWt835Y+8IuI=@dpdk.org X-Gm-Message-State: APuU4Z8Tq9RIMdgSfGaHkxyQA+w4niuxT/ZM7whLxZlDBrNodlxRUwdj lSiF/IV988QEkPVTJeqLSrhgyeTnOG9jyKHKfd6N9D5ki4ZnBBnKrNNaqW7TVUo6aAE= X-Gm-Gg: AZFdTZeqcl8MWm4J7A/2GjAis86HgONG1R0xp+EkfFfYT6ck7pypsEbVixUcUyv6T+y prBL0L/aVeHVbmx9Wd/IUW/5LQTjiUDlCiNcDmDdrnCPUsu/BmHdQQsubjD/OdTeKUk6aznjaAJ csP5bF3uoqRziBpYTf5u4GDsexVMgASjAeej1cbWm2PbKFAye0lpOd/kPynGsvnokemtKeGuxPS D4E3VBOnLyIifET+gtT+x6v2MNXOwaiY8dXpjezxSgrKV35k0xp+TUDb/PXf4ug9TPvou34BP3j 1QuGsKlOWJ5qn+UxGTkAg4Za8sIi9NdPjKtuuJ44Fr1C2S1YDJMr0jWLUZOrncMpCTpcyXstJwh CnEZg9SPaWGTU+8wvR65wMmCmpSJD7E/xCb5b8aPlV68ibQMEl2y24flYDbArvF+PRzI3m5uTb9 7wDUCez2R4lLoQ/tB2AeDl6s+ZODCw8RaE+wDXFZmld66UVBwL0C9KyvgcDTSzwf/l7uGSXcLEZ MDpuOZ/mHdIw1zl9AjKczIYfi4tVdYNbWwiTpQaWwEqdT1OnQYZhc63gAQ+iDC7qydQ57TXj8CM gRPrunvwH2SuoViCJbt74virzruaGxYF7UCVbgCpAuKqI8sE9dMPLAOzdm2sZxSebCi4a7l99lm L+ExqmKVIDs3tPAY= X-Received: by 2002:a05:6a00:893:b0:898:9b2:605b with SMTP id d2e1a72fcca58-8c87d806d03mr35997225b3a.56.1796153816991; Tue, 01 Dec 2026 11:36:56 -0800 (PST) Received: from phoenix.local (204-195-112-43.wavecable.com. [204.195.112.43]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c873c1cfa0sm20155568b3a.48.2026.12.01.11.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 11:36:56 -0800 (PST) Date: Tue, 1 Dec 2026 11:36:54 -0800 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: "Bruce Richardson" , Subject: Re: [PATCH v2 1/6] eal: add macros for local variable-length structure buffers Message-ID: <20261201113654.7013a15c@phoenix.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35F65B4A@smartserver.smartshare.dk> References: <20261116160932.1006354-1-bruce.richardson@intel.com> <20261201182249.2520829-1-bruce.richardson@intel.com> <20261201182249.2520829-2-bruce.richardson@intel.com> <98CBD80474FA8B44BF855DF32C47DC35F65B4A@smartserver.smartshare.dk> X-Archived-By: MIME-Version: 1.0 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-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, 1 Dec 2026 20:29:46 +0100 Morten Br=C3=B8rup wrote: > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Tuesday, 1 December 2026 19.23 > >=20 > > Many drivers allocate small control-path messages, which consist of a > > header structure followed by a variable-length array, using malloc and > > free, which adds error handling and the risk of leaks on error paths. > >=20 > > Add RTE_DEFINE_FLEX and RTE_DEFINE_FLEX_BYTES macros to define such > > buffers on the stack instead, (similar to equivalent macros in Linux > > kernel). The buffer is a union of a byte array and the structure type, > > giving correct alignment and type-safe access via a pointer, with the > > byte array first so that zero-initialization covers the whole buffer. > >=20 > > Signed-off-by: Bruce Richardson > > --- =20 >=20 > I thought we wanted to get rid of variable length arrays... > Could this be implemented using alloca() instead? >=20 >=20 There is difference between Variable Length Array (VLA) which is on stack buffer like: void foo(size_t n) { int results[n]; ... And Flexible Array which is structure with variable amount of data at the end: struct foo { int nflow; struct flow flows[]; } The Linux kernel also uses Gcc/clang counted by, can these macros do that?