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 9D4E543DFB; Thu, 4 Apr 2024 19:15:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0558640A72; Thu, 4 Apr 2024 19:15:22 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1B0EC4067B for ; Thu, 4 Apr 2024 19:15:15 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 710A020E97C5; Thu, 4 Apr 2024 10:15:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 710A020E97C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712250914; bh=kOhp+ERR46H7sVuxwGoUUntAFlG8XLhNqoQ4gU+CwUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZEcO3RJJG5XAYXP0cSRsVDkjnO6wAJpzoYWl2rxKkXVODggHw/2O+5GHo5wWonQ58 oBVnE41zSfcHQlaInb5R5/1kQ/+3Fq1Ved9BRyMrCMjEw7e1qH/7tGAIRkgggNa6cP 83iwen4DcmokIqYHyqsxQTDy3MrRYldp2WZDe/UQ= 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 4/4] dispatcher: use alloca instead of vla multi dimensional Date: Thu, 4 Apr 2024 10:15:13 -0700 Message-Id: <1712250913-1977-5-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1712250913-1977-1-git-send-email-roretzla@linux.microsoft.com> References: <20231107193220.GA15232@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <1712250913-1977-1-git-send-email-roretzla@linux.microsoft.com> 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 RFC sample illustrating conversion of multi-dimensional VLA to use alloca(). Signed-off-by: Tyler Retzlaff --- lib/dispatcher/rte_dispatcher.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dispatcher/rte_dispatcher.c b/lib/dispatcher/rte_dispatcher.c index 7934917..f154c26 100644 --- a/lib/dispatcher/rte_dispatcher.c +++ b/lib/dispatcher/rte_dispatcher.c @@ -119,7 +119,7 @@ struct rte_dispatcher { struct rte_event *events, uint16_t num_events) { int i; - struct rte_event bursts[EVD_MAX_HANDLERS][num_events]; + struct rte_event *bursts = alloca(sizeof(struct rte_event) * EVD_MAX_HANDLERS * num_events); uint16_t burst_lens[EVD_MAX_HANDLERS] = { 0 }; uint16_t drop_count = 0; uint16_t dispatch_count; @@ -136,7 +136,7 @@ struct rte_dispatcher { continue; } - bursts[handler_idx][burst_lens[handler_idx]] = *event; + bursts[handler_idx * num_events + burst_lens[handler_idx]] = *event; burst_lens[handler_idx]++; } @@ -152,7 +152,7 @@ struct rte_dispatcher { continue; handler->process_fun(dispatcher->event_dev_id, port->port_id, - bursts[i], len, handler->process_data); + &bursts[i * num_events], len, handler->process_data); dispatched += len; -- 1.8.3.1