DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Mattias Rönnblom" <hofors@lysator.liu.se>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Subject: Re: [PATCH v5 00/32] replace use of rte_memcpy() with fixed size
Date: Sun, 26 May 2024 16:51:52 +0200	[thread overview]
Message-ID: <b5abc3a8-6dff-46ac-bd18-01fea2076ca1@lysator.liu.se> (raw)
In-Reply-To: <20240522033009.143100-1-stephen@networkplumber.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
> 

  parent reply	other threads:[~2024-05-26 14:51 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 16:32 [PATCH 0/2] uuid: enhancements and tests Stephen Hemminger
2024-04-03 16:32 ` [PATCH 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:11   ` Tyler Retzlaff
2024-04-03 16:32 ` [PATCH 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-03 22:11 ` [PATCH v2 0/2] uuid: add generate functions and tests Stephen Hemminger
2024-04-03 22:11   ` [PATCH v2 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:16     ` Tyler Retzlaff
2024-04-03 22:11   ` [PATCH v2 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-04 16:18     ` Tyler Retzlaff
2024-04-04 16:22 ` [PATCH v3 0/2] uuid: add generate functions and tests Stephen Hemminger
2024-04-04 16:22   ` [PATCH v3 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:22   ` [PATCH v3 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 00/30] replace use of rte_memcpy with fixed sizes Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 01/30] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Stephen Hemminger
2024-04-06  9:01     ` Morten Brørup
2024-04-05 16:53   ` [PATCH v4 02/30] eal: replace use of " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 03/30] ethdev: replace uses of rte_memcpy Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 04/30] eventdev: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 05/30] cryptodev: " Stephen Hemminger
2024-04-10 15:40     ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53   ` [PATCH v4 06/30] ip_frag: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 07/30] net: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 08/30] lpm: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 09/30] node: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 10/30] pdcp: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 11/30] pipeline: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 12/30] rib: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 13/30] security: " Stephen Hemminger
2024-04-10 15:40     ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53   ` [PATCH v4 14/30] bus: remove unneeded rte_memcpy.h include Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 15/30] net: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 16/30] raw: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 17/30] baseband: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 18/30] common: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 19/30] crypto: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 20/30] " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 21/30] event: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 22/30] mempool: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 23/30] ml/cnxk: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 24/30] app/test-pmd: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 25/30] app/graph: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 26/30] app/test-eventdev: " Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 27/30] app/test: " Stephen Hemminger
2024-04-10 18:28     ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53   ` [PATCH v4 28/30] app/test-pipeline: remove unused rte_memcpy.h include Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 29/30] app/test-bbdev: remove unnecessary include of rte_memcpy.h Stephen Hemminger
2024-04-05 16:53   ` [PATCH v4 30/30] examples: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-09 17:05 ` [PATCH v4 0/2] uuid: generator functions and unit test Stephen Hemminger
2024-04-09 17:05   ` [PATCH v4 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-09 17:05   ` [PATCH v4 2/2] test: add functional test for uuid Stephen Hemminger
2024-05-22  3:27 ` [PATCH v5 00/32] replace use of rte_memcpy() with fixed size Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 01/32] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 02/32] eal: replace use of " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 03/32] ethdev: replace uses of rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 04/32] eventdev: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 05/32] cryptodev: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 06/32] ip_frag: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 07/32] net: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 08/32] lpm: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 09/32] node: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 10/32] pdcp: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 11/32] pipeline: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 12/32] rib: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 13/32] security: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 14/32] bus: remove unneeded rte_memcpy.h include Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 15/32] raw: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 16/32] baseband: " Stephen Hemminger
2024-05-23 18:28     ` Chautru, Nicolas
2024-05-22  3:27   ` [PATCH v5 17/32] common: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 18/32] crypto: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 19/32] event: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 20/32] mempool: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 21/32] ml/cnxk: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 22/32] app/test-pmd: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 23/32] app/graph: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 24/32] app/test-eventdev: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 25/32] app/test: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 26/32] app/test-pipeline: remove unused rte_memcpy.h include Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 27/32] app/test-bbdev: remove unnecessary include of rte_memcpy.h Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 28/32] examples: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 29/32] net/null: replace use of fixed size memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 30/32] net/tap: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 31/32] net/pcap: " Stephen Hemminger
2024-05-22  3:27   ` [PATCH v5 32/32] net/af_xdp:: " Stephen Hemminger
2024-05-26 14:51   ` Mattias Rönnblom [this message]
2024-05-26 23:32     ` [PATCH v5 00/32] replace use of rte_memcpy() with fixed size Stephen Hemminger
2024-05-27  6:06       ` Mattias Rönnblom
2024-05-27  6:38       ` Morten Brørup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b5abc3a8-6dff-46ac-bd18-01fea2076ca1@lysator.liu.se \
    --to=hofors@lysator.liu.se \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).