From patchwork Thu Apr 4 17:15:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139104 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6E2A843DFB; Thu, 4 Apr 2024 19:15:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 701D940A67; Thu, 4 Apr 2024 19:15:19 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EF0D2402BC for ; Thu, 4 Apr 2024 19:15:14 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4822220E94A4; Thu, 4 Apr 2024 10:15:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4822220E94A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712250914; bh=H9j1fCv2LwSunEdLuRN66u3MaK9xk9Z6hwEsohm2ZI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=psohcYos9LHnXTvrhygvbkViw+ZINStGToUllTgQh9NmBz8vMW6O3BGBWemWw0oIS T8xJcir7bLXjMlokCztZb8R9tmzItSk5BTpSMVPygxJtBrI0aYI1nQ9ReKBmtEAFEH Fipy1nngfeTOtfg4Y/kp2nb/F8JOBvktSLMmVZ6k= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Thomas Monjalon , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH 1/4] latencystats: use alloca instead of vla trivial Date: Thu, 4 Apr 2024 10:15:10 -0700 Message-Id: <1712250913-1977-2-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 simple conversion of VLA to alloca(). Signed-off-by: Tyler Retzlaff --- lib/latencystats/rte_latencystats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index 4ea9b0d..f59a9eb 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -159,7 +159,7 @@ struct latency_stats_nameoff { { unsigned int i, cnt = 0; uint64_t now; - float latency[nb_pkts]; + float *latency = alloca(sizeof(float) * nb_pkts); static float prev_latency; /* * Alpha represents degree of weighting decrease in EWMA, From patchwork Thu Apr 4 17:15:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139103 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4D1D043DFB; Thu, 4 Apr 2024 19:15:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39D234067B; Thu, 4 Apr 2024 19:15:18 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id F1FE1402CC for ; Thu, 4 Apr 2024 19:15:14 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 55D8D20E97BD; Thu, 4 Apr 2024 10:15:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 55D8D20E97BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712250914; bh=aAA7sFcoLU0TA8wNQPECKqZN3neiLmIQ/dd15t0zKNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S72f5Dw/ksO1qcsNMRnIPLVsa/9MFCdr70ha2t4U4dzjFNd9MGWfmeUZfH/51Gk2A SGYMXYEjdoJf1NCOY0ODooKMADYlq3tZ00GguZofzwlTnj++0YbvD7CY+TyoUS6NoS IE1YB5kkcfaYfWoJvc8b6nJU4ZvxCqqfn1d5ICXw= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Thomas Monjalon , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH 2/4] hash: use alloca instead of vla trivial Date: Thu, 4 Apr 2024 10:15:11 -0700 Message-Id: <1712250913-1977-3-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 simple conversion of VLA to alloca() where dimension multiplier removed. Signed-off-by: Tyler Retzlaff --- lib/hash/rte_thash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 68f653f..633e211 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -771,7 +771,7 @@ struct rte_thash_subtuple_helper * uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t *tmp_tuple = alloca(tuple_len); unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; From patchwork Thu Apr 4 17:15:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139105 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A202B43DFB; Thu, 4 Apr 2024 19:15:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B40CF40A6E; Thu, 4 Apr 2024 19:15:20 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 105FB4064A for ; Thu, 4 Apr 2024 19:15:15 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 63C3A20E97C1; Thu, 4 Apr 2024 10:15:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 63C3A20E97C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1712250914; bh=rD+L0VBEA4ijIJdqdd449HN9OEIpZijzzM7uh0U3AQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qrnREoKVqff0DtjBVN7ryRKKIj3Yj3IKzzmZmLHi1J/fhN9E50nqWjQHZXeexfm3C 1XVUskKQaMPawK8I688aQVpFBysb1rp5mv9tjftuVcJxnhyKMtWSP8U4fjF3hWtOJY Tw9KaNbCNxhTIH3rCvsILpUKmCXHeotaQCvaU6ME= From: Tyler Retzlaff To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Thomas Monjalon , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH 3/4] vhost: use alloca instead of vla sizeof Date: Thu, 4 Apr 2024 10:15:12 -0700 Message-Id: <1712250913-1977-4-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 VLA to alloca() where sizeof(array) was in use. Signed-off-by: Tyler Retzlaff --- lib/vhost/socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c index 96b3ab5..cedcfb2 100644 --- a/lib/vhost/socket.c +++ b/lib/vhost/socket.c @@ -110,7 +110,8 @@ struct vhost_user { { struct iovec iov; struct msghdr msgh; - char control[CMSG_SPACE(max_fds * sizeof(int))]; + const size_t control_sz = sizeof(char) * CMSG_SPACE(max_fds * sizeof(int)); + char *control = alloca(control_sz); struct cmsghdr *cmsg; int got_fds = 0; int ret; @@ -124,7 +125,7 @@ struct vhost_user { msgh.msg_iov = &iov; msgh.msg_iovlen = 1; msgh.msg_control = control; - msgh.msg_controllen = sizeof(control); + msgh.msg_controllen = control_sz; ret = recvmsg(sockfd, &msgh, 0); if (ret <= 0) { From patchwork Thu Apr 4 17:15:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139106 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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_Br=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;