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 B018F432D8; Wed, 8 Nov 2023 17:51:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9607B402BB; Wed, 8 Nov 2023 17:51:59 +0100 (CET) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by mails.dpdk.org (Postfix) with ESMTP id 963B8402A7 for ; Wed, 8 Nov 2023 17:51:57 +0100 (CET) Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3b2ea7cca04so4393785b6e.2 for ; Wed, 08 Nov 2023 08:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699462317; x=1700067117; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=aMsLn+QJBN896DG0SffNwfO51lQ6AlLcFmUpllDEoBk=; b=tAaGSwLVTCb8b7PM7sSHe+oAeCawcjmGEMH8y6BVLaL25ZRWI7/DoL6mH4pfN/HRF2 4TSNMKivkhbvD8Rfl74L0+7uTfkMRrXr8jUUGvPWzNBxilT+ZWnGqOys0NqsxOV2143J 9z8wNdz9K48d5vj4ESka0h0ec5nkutLFBPeYj2GL0n8AXa35aNgEuy532DzRhAonKkvR XprMkF+F2XPS9w2Hxj8nH6SXEQRjI7ZqH8PTTuh3QX2a6BxM4W3cX3z0l195g3rkoxGm OJ1hK3T0mKFy/mJ61fp5vOyle7nggKmXphFFIKT06SMWcrw+bSTxQqPVo+c12NExhTPM XSsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699462317; x=1700067117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aMsLn+QJBN896DG0SffNwfO51lQ6AlLcFmUpllDEoBk=; b=wG76eCWxdGy2dW44Fdh3A1lYrAN3+nIbXs9jMYLlpSMu3leKGQAoyXy4cd2dhDq7Yj NngjKcpL5A7ex/Q+yz3CR1VO7vlTpLLkaBOe0zMUdlHGYkKeVe08IqF/IiW1O05rF9Ij SReVssC++o+UVhw6CXulqLbdiMwWyltvN7cW/B1ey9FpWqCgYKqhD2XquhTj5wYaJJN2 dhuYDi5wetQvX+71TlSbZ6A1MXcfmyFqFYxoQMogAtomfu143L5q4cYMsSzJ8DrNXhCb rgNzMYY2625ua70C/zDnrsulGNNcCQ+jRajTNPCrtRuvlRqbh9izsSOKOtflTJL9Bc5/ jjFw== X-Gm-Message-State: AOJu0Yy9K47hKcOvjhuV2eNJNuz55d5FI6r+lKgOUmkO0v9khBU/10Ux 11bkbVTLSsrugMU6kbC84ZEzef5bgHdhyVKyHIc= X-Google-Smtp-Source: AGHT+IFzJdSTKtjxzP/XQ9OZiWfAeFFggnIba8HIEXfuqfmZ/c+YMnemLcSH6OVOkvyE+r+jM7zGRA== X-Received: by 2002:a05:6808:4441:b0:3ae:554b:6c57 with SMTP id ep1-20020a056808444100b003ae554b6c57mr2690697oib.11.1699462316621; Wed, 08 Nov 2023 08:51:56 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id f10-20020a056a00228a00b006c1221bc58bsm9213639pfe.115.2023.11.08.08.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 08:51:56 -0800 (PST) Date: Wed, 8 Nov 2023 08:51:54 -0800 From: Stephen Hemminger To: Tyler Retzlaff Cc: dev@dpdk.org Subject: Re: RFC acceptable handling of VLAs across toolchains Message-ID: <20231108085154.757719e4@hermes.local> In-Reply-To: <20231107193220.GA15232@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20231107193220.GA15232@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> 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-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, 7 Nov 2023 11:32:20 -0800 Tyler Retzlaff wrote: > hi folks, >=20 > i'm seeking advice. we have use of VLAs which are now optional in > standard C. some toolchains provide a conformant implementation and msvc > does not (and never will). >=20 > we seem to have a few options, just curious about what people would > prefer. >=20 > * use alloca >=20 > * use dynamically allocated storage >=20 > * conditional compiled code where the msvc leg uses one of the previous > two options >=20 > i'll leave it simple for now, i'd like to hear input rather than provide > a recommendation for now. >=20 > thanks! As an experiment did a build of current DPDK with -Wvla option. Lots of errors, some have obvious solutions like: ../drivers/net/failsafe/failsafe_intr.c: In function =E2=80=98fs_rx_event_p= roxy_service_install=E2=80=99: ../drivers/net/failsafe/failsafe_intr.c:142:17: warning: ISO C90 forbids va= riable length array =E2=80=98service_core_list=E2=80=99 [-Wvla] 142 | uint32_t service_core_list[num_service_cores]; | ^~~~~~~~ This could just be RTE_MAX_LCORES. others like rte_metrics should just use malloc() as is used already in that function. ../lib/metrics/rte_metrics_telemetry.c: In function =E2=80=98rte_metrics_te= l_update_metrics_ethdev=E2=80=99: ../lib/metrics/rte_metrics_telemetry.c:140:9: warning: ISO C90 forbids vari= able length array =E2=80=98xstats_values=E2=80=99 [-Wvla] 140 | uint64_t xstats_values[num_xstats]; | ^~~~~~~~ ../lib/metrics/rte_metrics_telemetry.c: In function =E2=80=98rte_metrics_te= l_extract_data=E2=80=99: ../lib/metrics/rte_metrics_telemetry.c:384:9: warning: ISO C90 forbids vari= able length array =E2=80=98stat_names=E2=80=99 [-Wvla] 384 | const char *stat_names[num_stat_names]; | ^~~~~ Others already have an implicit upper bound. Example is in rte_cuckoo_hash where some fields us RTE_HASH_LOOKUP_BULK_MAX and some use VLA. [170/2868] Compiling C object lib/librte_hash.a.p/hash_rte_cuckoo_hash.c.o ../lib/hash/rte_cuckoo_hash.c: In function =E2=80=98rte_hash_lookup_bulk_da= ta=E2=80=99: ../lib/hash/rte_cuckoo_hash.c:2355:9: warning: ISO C90 forbids variable len= gth array =E2=80=98positions=E2=80=99 [-Wvla] 2355 | int32_t positions[num_keys]; | ^~~~~~~ ../lib/hash/rte_cuckoo_hash.c: In function =E2=80=98rte_hash_lookup_with_ha= sh_bulk_data=E2=80=99: ../lib/hash/rte_cuckoo_hash.c:2471:9: warning: ISO C90 forbids variable len= gth array =E2=80=98positions=E2=80=99 [-Wvla] 2471 | int32_t positions[num_keys]; | ^~~~~~~ Would it make sense to have an rte_config.h value for maximum burst size? Lots of code is using nb_pkts. There is also some confusing ones like: ../lib/mempool/rte_mempool.c: In function =E2=80=98mempool_cache_init=E2=80= =99: ../lib/mempool/rte_mempool.c:751:50: warning: ISO C90 forbids array whose s= ize cannot be evaluated [-Wvla] 751 | RTE_SIZEOF_FIELD(struct rte_mempool_cache,= objs[0])); | ^~~~~~~~~~~~~~~~~ ../lib/eal/include/rte_common.h:498:65: note: in definition of macro =E2=80= =98RTE_BUILD_BUG_ON=E2=80=99 498 | #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(con= dition)])) | ^~~= ~~~~~~ ../lib/mempool/rte_mempool.c:751:26: note: in expansion of macro =E2=80=98R= TE_SIZEOF_FIELD=E2=80=99 751 | RTE_SIZEOF_FIELD(struct rte_mempool_cache,= objs[0]));