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 9E5E543DFB; Thu, 4 Apr 2024 19:15:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A90B402E8; Thu, 4 Apr 2024 19:15:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 03D5A402E8 for ; Thu, 4 Apr 2024 19:15:15 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3AC8320E94A3; Thu, 4 Apr 2024 10:15:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3AC8320E94A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712250914; bh=APOPtIYhw2AUB6f6nOwZ/x3WKAr4J1YZm8yELcFMKgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dc/7oxQNU7BEgWpFZaAumJ8LvpuvB4a5QndNsatf41B/Gwidqs0QE7/Wmc92eOwnR lz22ezp67VvnjASGTL6Bwpf1lSh1Rb4Qm54nHn40oGhmnXit1nJ5duN55vFhWqWvmK Jwogv8eY1B++Ad1J53CMAWkBZDdIuhuggpUkjJr4= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Thomas Monjalon , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH 0/4] RFC samples converting VLA to alloca Date: Thu, 4 Apr 2024 10:15:09 -0700 Message-Id: <1712250913-1977-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20231107193220.GA15232@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20231107193220.GA15232@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> 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 This series is not intended for merge. It insteat provides examples of converting use of VLAs to alloca() would look like. what's the advantages of VLA over alloca()? * sizeof(array) works as expected. * multi-dimensional arrays are still arrays instead of pointers to dynamically allocated space. this means multiple subscript syntax works (unlike on a pointer) and calculation of addresses into allocated space in ascending order is performed by the compiler instead of manually. what's the disadvantage of VLA over alloca()? * VLA generation is subtl/implicit, there do appear to be places where a VLA is being used where it perhaps was not intended but it is hard to spot. e.g. hotpath rte_mbuf *array[burst_size]; where burst_size is not a constant expression, e.g. unintended in other syntax positions that are not intuitive, see patchwork link. https://patchwork.dpdk.org/project/dpdk/patch/1699896038-28106-1-git-send-email-roretzla@linux.microsoft.com/ for the above reasons i'd recommend only converting to alloca() where necessary (msvc has to compile it) and for the other instances leave them as they are. Tyler Retzlaff (4): latencystats: use alloca instead of vla trivial hash: use alloca instead of vla trivial vhost: use alloca instead of vla sizeof dispatcher: use alloca instead of vla multi dimensional lib/dispatcher/rte_dispatcher.c | 6 +++--- lib/hash/rte_thash.c | 2 +- lib/latencystats/rte_latencystats.c | 2 +- lib/vhost/socket.c | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) -- 1.8.3.1