From patchwork Thu Apr 18 10:33:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Ananyev X-Patchwork-Id: 139493 X-Patchwork-Delegate: thomas@monjalon.net 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 6191343E9F; Thu, 18 Apr 2024 12:34:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 14E9E40A89; Thu, 18 Apr 2024 12:33:55 +0200 (CEST) Received: from forward501b.mail.yandex.net (forward501b.mail.yandex.net [178.154.239.145]) by mails.dpdk.org (Postfix) with ESMTP id 5C91940A71 for ; Thu, 18 Apr 2024 12:33:53 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7907:0:640:8f19:0]) by forward501b.mail.yandex.net (Yandex) with ESMTPS id C536161961; Thu, 18 Apr 2024 13:33:52 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id GXCBSvCo7Ko0-fUgP80VP; Thu, 18 Apr 2024 13:33:52 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713436432; bh=s1b4ZClLEB86JFCDAHCtaw0NUgVudcAr+Pp5Q3Ol/P4=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=oS7/jVedndFzVDQqlGqz1T/KvCJvxV1grQJel0QMY5Eusge03i2JATHHncfgLm1dd EQyyWhAcDEl1v8m3O4f9ZjzTZbiTCUhIKu3752yk3Uzs9sCnYxxgaXIvSdnYgqiXGk xnO76GfChbxn/x7mUKk2/tkdz2hdRO7EXsLC/Luk= Authentication-Results: mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Konstantin Ananyev To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, vladimir.medvedkin@intel.com, honnappa.nagarahalli@arm.com, roretzla@linux.microsoft.com, Konstantin Ananyev Subject: [RFC 6/6] rcu: remove VLA warnings Date: Thu, 18 Apr 2024 11:33:14 +0100 Message-Id: <20240418103314.40705-7-konstantin.v.ananyev@yandex.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418103314.40705-1-konstantin.v.ananyev@yandex.ru> References: <20240418103314.40705-1-konstantin.v.ananyev@yandex.ru> MIME-Version: 1.0 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 From: Konstantin Ananyev 1) ./lib/rcu/rte_rcu_qsbr.c:359:9: warning: ISO C90 forbids variable length array ‘data’ [-Wvla] 2) ./lib/rcu/rte_rcu_qsbr.c:422:9: warning: ISO C90 forbids variable length array ‘data’ [-Wvla] In both cases we allocate VLA for one element from RCU deferred queue. Right now, size of element in RCU queue is not limited by API. The approach is to introduce some reasonable limitation on RCU DQ element size. Choose 128B for now. With that in place we can replace both VLA occurencies with fixed size array. Note that such change need to be treated as API change. So can be applied only at 24.11. Signed-off-by: Konstantin Ananyev Acked-By: Morten Brørup --- lib/rcu/rte_rcu_qsbr.c | 7 ++++--- lib/rcu/rte_rcu_qsbr.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index f08d974d07..6800ef03a5 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -278,7 +278,8 @@ rte_rcu_qsbr_dq_create(const struct rte_rcu_qsbr_dq_parameters *params) if (params == NULL || params->free_fn == NULL || params->v == NULL || params->name == NULL || params->size == 0 || params->esize == 0 || - (params->esize % 4 != 0)) { + (params->esize % 4 != 0) || + params->esize > RTE_QSBR_ESIZE_MAX) { RCU_LOG(ERR, "Invalid input parameter"); rte_errno = EINVAL; @@ -356,7 +357,7 @@ int rte_rcu_qsbr_dq_enqueue(struct rte_rcu_qsbr_dq *dq, void *e) return 1; } - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; dq_elem = (__rte_rcu_qsbr_dq_elem_t *)data; /* Start the grace period */ dq_elem->token = rte_rcu_qsbr_start(dq->v); @@ -419,7 +420,7 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n, cnt = 0; - char data[dq->esize]; + char data[RTE_QSBR_ESIZE_MAX + __RTE_QSBR_TOKEN_SIZE]; /* Check reader threads quiescent state and reclaim resources */ while (cnt < n && rte_ring_dequeue_bulk_elem_start(dq->r, &data, diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 0506191b80..892e5a31a4 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -86,6 +86,11 @@ struct __rte_cache_aligned rte_rcu_qsbr_cnt { #define __RTE_QSBR_CNT_MAX ((uint64_t)~0) #define __RTE_QSBR_TOKEN_SIZE sizeof(uint64_t) +/** + * Max allowable size (in bytes) of each element in the defer queue + */ +#define RTE_QSBR_ESIZE_MAX (2 * RTE_CACHE_LINE_MIN_SIZE) + /* RTE Quiescent State variable structure. * This structure has two elements that vary in size based on the * 'max_threads' parameter.