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 0C45D440D7; Sun, 26 May 2024 16:51:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA0214064A; Sun, 26 May 2024 16:51:56 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id 3452A4064A for ; Sun, 26 May 2024 16:51:55 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id D57921ACFF for ; Sun, 26 May 2024 16:51:54 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id C82EC1ACFD; Sun, 26 May 2024 16:51:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=ALL_TRUSTED,AWL, T_SCC_BODY_TEXT_LINE autolearn=disabled version=4.0.0 X-Spam-Score: -1.3 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 1FDF41AD4F; Sun, 26 May 2024 16:51:53 +0200 (CEST) Message-ID: Date: Sun, 26 May 2024 16:51:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 00/32] replace use of rte_memcpy() with fixed size To: Stephen Hemminger , dev@dpdk.org References: <20240403163432.437275-1-stephen@networkplumber.org> <20240522033009.143100-1-stephen@networkplumber.org> Content-Language: en-US From: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= In-Reply-To: <20240522033009.143100-1-stephen@networkplumber.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP 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 2024-05-22 05:27, Stephen Hemminger wrote: > The DPDK has a lot of unnecessary usage of rte_memcpy. > This patch set replaces cases where rte_memcpy is used with a fixed > size constant size. > > Typical example is: > rte_memcpy(mac_addrs, mac.addr_bytes, RTE_ETHER_ADDR_LEN); > which can be replaced with: > memcpy(mac_addrs, mac.addr_bytes, RTE_ETHER_ADDR_LEN); > > This does not change the resulting binary on almost all architectures > because x86 version of intrisics and glibc are the same, and > other architectures were using __builtin_constant_p(). > > The main benefit is that analysis tools like fortify, Coverity, and ASAN > analyzers can check these memcpy's. A recent example is that > on Ubuntu 22.04 detected undefined use of memcpy such as: > memcpy(dst, NULL, 0) > Would it be possible to instead have a build mode where rte_memcpy() is *always* delegating to memcpy(), and run these tools on that configuration? It seems easier to just always using rte_memcpy() in DPDK code, then let the platform (not the programmer) choose whatever is most appropriate. > The first patch is a simple coccinelle script to do the replacement > and the rest are the results broken out by module. The script can be used > again to make sure more bad usage doesn't creep in with new drivers. > > v5 - rebase and fix a couple of the SW drivers. > rewording of commit messages > > v4 - replace other unnecessary rte_memcpy in ethdev. > replace memcpy with structure assignment where possible. > fixup formatting in a couple places. > > v3 - rebase and rerun coccinelle script on 24.03 > - consolidate patches by subtree > - remove inclusion of rte_memcpy.h when no longer used. > > Stephen Hemminger (32): > cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy > eal: replace use of fixed size rte_memcpy > ethdev: replace uses of rte_memcpy > eventdev: replace use of fixed size rte_memcpy > cryptodev: replace use of fixed size rte_memcpy > ip_frag: replace use of fixed size rte_memcpy > net: replace use of fixed size rte_memcpy > lpm: replace use of fixed size rte_memcpy > node: replace use of fixed size rte_memcpy > pdcp: replace use of fixed size rte_memcpy > pipeline: replace use of fixed size rte_memcpy > rib: replace use of fixed size rte_memcpy > security: replace use of fixed size rte_memcpy > bus: remove unneeded rte_memcpy.h include > raw: replace use of fixed size rte_memcpy > baseband: replace use of fixed size rte_memcpy > common: replace use of fixed size rte_memcpy > crypto: replace use of fixed size rte_memcpy > event: replace use of fixed size rte_memcpy > mempool: replace use of fixed size rte_memcpy > ml/cnxk: replace use of fixed size rte_memcpy > app/test-pmd: replace use of fixed size rte_memcpy > app/graph: replace use of fixed size rte_memcpy > app/test-eventdev: replace use of fixed size rte_memcpy > app/test: replace use of fixed size rte_memcpy > app/test-pipeline: remove unused rte_memcpy.h include > app/test-bbdev: remove unnecessary include of rte_memcpy.h > examples: replace use of fixed size rte_memcpy > net/null: replace use of fixed size memcpy > net/tap: replace use of fixed size rte_memcpy > net/pcap: replace use of fixed size rte_memcpy > net/af_xdp:: replace use of fixed size rte_memcpy > > app/graph/neigh.c | 8 +- > app/test-bbdev/test_bbdev.c | 1 - > app/test-eventdev/test_pipeline_common.c | 19 ++-- > app/test-pipeline/config.c | 1 - > app/test-pipeline/init.c | 1 - > app/test-pipeline/main.c | 1 - > app/test-pipeline/runtime.c | 1 - > app/test-pmd/cmdline.c | 48 ++++----- > app/test-pmd/cmdline_flow.c | 24 ++--- > app/test-pmd/config.c | 8 +- > app/test-pmd/csumonly.c | 1 - > app/test-pmd/flowgen.c | 1 - > app/test-pmd/iofwd.c | 1 - > app/test-pmd/macfwd.c | 1 - > app/test-pmd/macswap.c | 1 - > app/test-pmd/noisy_vnf.c | 1 - > app/test-pmd/rxonly.c | 1 - > app/test-pmd/testpmd.c | 1 - > app/test/commands.c | 1 - > app/test/packet_burst_generator.c | 4 +- > app/test/test_crc.c | 5 +- > app/test/test_cryptodev.c | 18 ++-- > app/test/test_cryptodev_asym.c | 1 - > app/test/test_cryptodev_security_pdcp.c | 1 - > app/test/test_efd.c | 1 - > app/test/test_efd_perf.c | 1 - > app/test/test_event_crypto_adapter.c | 12 +-- > app/test/test_event_dma_adapter.c | 4 +- > app/test/test_eventdev.c | 1 - > app/test/test_ipsec.c | 6 +- > app/test/test_link_bonding_mode4.c | 8 +- > app/test/test_mbuf.c | 1 - > app/test/test_member.c | 1 - > app/test/test_member_perf.c | 1 - > app/test/test_rawdev.c | 1 - > app/test/test_security_inline_proto.c | 36 +++---- > app/test/test_service_cores.c | 1 - > app/test/virtual_pmd.c | 3 +- > devtools/cocci/rte_memcpy.cocci | 11 ++ > drivers/baseband/acc/rte_acc100_pmd.c | 16 ++- > drivers/baseband/acc/rte_vrb_pmd.c | 21 ++-- > drivers/baseband/la12xx/bbdev_la12xx.c | 4 +- > drivers/bus/auxiliary/linux/auxiliary.c | 1 - > drivers/bus/fslmc/fslmc_bus.c | 1 - > drivers/bus/fslmc/fslmc_vfio.c | 1 - > drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c | 1 - > drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 1 - > drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 1 - > drivers/bus/pci/linux/pci.c | 1 - > drivers/common/idpf/idpf_common_device.c | 4 +- > drivers/common/idpf/idpf_common_virtchnl.c | 10 +- > drivers/common/qat/qat_qp.c | 10 +- > drivers/compress/qat/qat_comp.c | 8 +- > drivers/crypto/ccp/ccp_crypto.c | 14 +-- > drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +- > drivers/crypto/cnxk/cnxk_se.h | 2 +- > drivers/crypto/dpaa_sec/dpaa_sec.c | 2 +- > drivers/crypto/ipsec_mb/pmd_snow3g.c | 4 +- > drivers/crypto/qat/qat_sym_session.c | 52 +++++---- > .../scheduler/rte_cryptodev_scheduler.c | 6 +- > drivers/crypto/scheduler/scheduler_failover.c | 12 +-- > drivers/event/cnxk/cnxk_eventdev_selftest.c | 1 - > drivers/event/cnxk/cnxk_tim_evdev.c | 4 +- > drivers/event/dlb2/dlb2.c | 4 +- > drivers/event/dpaa/dpaa_eventdev.c | 1 - > drivers/event/dpaa2/dpaa2_eventdev.c | 7 +- > drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 1 - > drivers/event/dpaa2/dpaa2_hw_dpcon.c | 1 - > drivers/event/octeontx/ssovf_evdev_selftest.c | 1 - > drivers/event/octeontx/timvf_evdev.c | 4 +- > drivers/mempool/dpaa/dpaa_mempool.c | 4 +- > drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 5 +- > drivers/ml/cnxk/cn10k_ml_model.c | 8 +- > drivers/ml/cnxk/cn10k_ml_ops.c | 11 +- > drivers/ml/cnxk/cnxk_ml_ops.c | 2 +- > drivers/ml/cnxk/mvtvm_ml_model.c | 8 +- > drivers/ml/cnxk/mvtvm_ml_ops.c | 8 +- > drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- > drivers/net/null/rte_eth_null.c | 6 +- > drivers/net/pcap/pcap_ethdev.c | 2 +- > drivers/net/pcap/pcap_osdep_freebsd.c | 2 +- > drivers/net/pcap/pcap_osdep_linux.c | 2 +- > drivers/net/tap/rte_eth_tap.c | 14 +-- > drivers/raw/ifpga/afu_pmd_he_hssi.c | 3 +- > drivers/raw/ifpga/afu_pmd_he_lpbk.c | 3 +- > drivers/raw/ifpga/afu_pmd_he_mem.c | 3 +- > drivers/raw/ifpga/afu_pmd_n3000.c | 8 +- > drivers/raw/ifpga/ifpga_rawdev.c | 11 +- > drivers/raw/skeleton/skeleton_rawdev.c | 8 +- > drivers/raw/skeleton/skeleton_rawdev_test.c | 1 - > examples/bbdev_app/main.c | 2 +- > examples/bond/main.c | 1 - > examples/ip_fragmentation/main.c | 1 - > examples/ip_reassembly/main.c | 1 - > examples/ipv4_multicast/main.c | 1 - > examples/l2fwd-cat/cat.c | 4 +- > examples/l2fwd-jobstats/main.c | 1 - > examples/l2fwd-keepalive/main.c | 1 - > examples/l2fwd-macsec/main.c | 1 - > examples/l2fwd/main.c | 1 - > examples/l3fwd-power/main.c | 1 - > examples/l3fwd/main.c | 1 - > examples/link_status_interrupt/main.c | 1 - > .../client_server_mp/mp_server/init.c | 1 - > .../client_server_mp/mp_server/main.c | 1 - > examples/multi_process/symmetric_mp/main.c | 1 - > examples/ptpclient/ptpclient.c | 11 +- > examples/qos_sched/app_thread.c | 1 - > examples/qos_sched/main.c | 1 - > examples/server_node_efd/efd_server/init.c | 1 - > examples/server_node_efd/efd_server/main.c | 1 - > examples/vhost/main.c | 6 +- > examples/vmdq/main.c | 7 +- > examples/vmdq_dcb/main.c | 15 +-- > lib/cryptodev/rte_cryptodev.c | 2 +- > lib/eal/common/eal_common_options.c | 7 +- > lib/ethdev/rte_ethdev.c | 12 +-- > lib/ethdev/rte_flow.c | 101 +++++++++--------- > lib/eventdev/rte_event_crypto_adapter.c | 2 +- > lib/eventdev/rte_event_dma_adapter.c | 4 +- > lib/eventdev/rte_event_timer_adapter.c | 2 +- > lib/fib/trie.c | 2 +- > lib/ip_frag/rte_ipv6_fragmentation.c | 4 +- > lib/ip_frag/rte_ipv6_reassembly.c | 6 +- > lib/lpm/rte_lpm6.c | 3 +- > lib/net/rte_ether.c | 2 +- > lib/node/ip6_lookup.c | 8 +- > lib/pdcp/pdcp_process.c | 36 +++---- > lib/pipeline/rte_table_action.c | 8 +- > lib/rib/rte_rib6.h | 5 +- > lib/security/rte_security.c | 4 +- > 131 files changed, 368 insertions(+), 450 deletions(-) > create mode 100644 devtools/cocci/rte_memcpy.cocci >