DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Huichao Cai" <chcchc88@163.com>
Cc: "David Marchand" <david.marchand@redhat.com>,
	"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
	dev <dev@dpdk.org>, "Thomas Monjalon" <thomas@monjalon.net>
Subject: Re: [PATCH v7] ip_frag: add IPv4 options fragment and test data
Date: Fri, 17 Jun 2022 09:31:12 -0700	[thread overview]
Message-ID: <20220617093112.6c7f4945@hermes.local> (raw)
In-Reply-To: <7d176bd8.1b9e.1816fca693b.Coremail.chcchc88@163.com>

On Fri, 17 Jun 2022 11:52:25 +0800 (CST)
"Huichao Cai" <chcchc88@163.com> wrote:

> Hi,Stephen
> 
> 
> There are some things I don't quite understand.Hope you can answer that.
> This will help me avoid similar errors in subsequent patch submissions.Thanks!
> 
> 
> There are places where rte_memcpy functions are used:
> ============================================
> In test_ipfrag.c:
> from func test_get_ipv4_opt: 
> rte_memcpy(expected_opt->data,expected_first_frag_ipv4_opts_copied,sizeof(expected_first_frag_ipv4_opts_copied));
> rte_memcpy(expected_opt>data,expected_first_frag_ipv4_opts_nocopied,sizeof(expected_first_frag_ipv4_opts_nocopied));  
> rte_memcpy(expected_opt->data,expected_sub_frag_ipv4_opts_copied,sizeof(expected_sub_frag_ipv4_opts_copied));
> rte_memcpy(expected_opt->data,expected_sub_frag_ipv4_opts_nocopied,sizeof(expected_sub_frag_ipv4_opts_nocopied));
> from func v4_allocate_packet_of:
> rte_memcpy(hdr + 1, opt.data, opt.len);
> from func test_get_frag_opt:
> rte_memcpy(opt->data, iph_opt, opt_len);
> 
> 
> In rte_ipv4_fragmentation.c:
> from func v4_allocate_packet_of:
> rte_memcpy(dst, src, header_len);
> from func __create_ipopt_frag_hdr:
> 
> rte_memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr));
> rte_memcpy(ipopt_frag_hdr + ipopt_len, p_opt, p_opt[1]);
> ============================================
> 
> 
> These are the compilation errors:
> ============================================
> test_ipfrag.c:230
> In test_ipfrag.c:
> from func v4_allocate_packet_of:
> rte_memcpy(hdr + 1, opt.data, opt.len);
> rte_ipv4_fragmentation.c:68
> In rte_ipv4_fragmentation.c:
> from func __create_ipopt_frag_hdr:
> rte_memcpy(ipopt_frag_hdr + ipopt_len, p_opt, p_opt[1]);
> ============================================
> 
> 
> 1.Do I need to replace all rte_memcpy with memcpy or only the two rte_memcpy that compile the error are replaced by memcpy?

I would just replace all of the rte_memcpy with memcpy

> 2.
> >Since the copies will all be short why bother using rte_memcpy() all over
> >the place.  Especially in the test code, just use memcpy().  
> For example,in app/test-pmd/cmdline.c:from func cmd_set_vxlan_parsed:rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);Why this place can be used rte_memcpy?
> 3.For example, how such a compilation error occurs:
> ../app/test/test_ipfrag.c:57:17: note: at offset [5, 40] into object‘data’ of size 40
> 4.Under what circumstances can we use rte_memcpy?


It depends. The recommendation here was that fixing warnings is higher priority that saving a few cycles
in an underutilized part of DPDK.

Rte_memcpy() was added in early versions of DPDK because the standard toolchain gcc/glibc
was not using the optimum set of instructions on x86.  Rather than fix glibc, Intel wrote
their own rte_memcpy(). Then DPDK developers, started to assume that rte_memcpy() is always best.

I expect that rte_memcpy() is able to do better than memcpy() for larger copies because it is
likely to use bigger vector instructions and check for alignment.
For small copies just doing the mov's directly is going to be as fast or faster.
In fact, lots of places in DPDK should
replace rte_memcpy() with simple structure assignment to preserve type safety.

This is somewhat historical data, it might be wrong. It would be worthwhile to have benchmarks
across different sizes (variable and fixed), different compilers, and different CPU's.
There might be surprising results.


  reply	other threads:[~2022-06-17 16:31 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24  8:47 [PATCH] ip_frag: add IPv4 options fragment and unit " Huichao Cai
2021-12-01 11:49 ` Dariusz Sosnowski
2021-12-02  2:24   ` Huichao Cai
2022-02-15  8:50 ` [PATCH v2] ip_frag: add IPv4 options fragment and " Huichao Cai
2022-02-18 19:04   ` Ananyev, Konstantin
2022-02-21  2:34     ` Huichao Cai
2022-02-21  3:17   ` [PATCH v3] " Huichao Cai
2022-02-25 14:33     ` Ananyev, Konstantin
2022-02-28 12:39       ` Huichao Cai
2022-03-15  7:22     ` [PATCH v4] " Huichao Cai
2022-03-21 14:24       ` Ananyev, Konstantin
2022-03-22  1:25         ` Huichao Cai
2022-03-22  3:09       ` [PATCH v5] " Huichao Cai
2022-03-23 12:52         ` Ananyev, Konstantin
2022-04-06  1:22           ` Huichao Cai
2022-04-06 16:47             ` Ananyev, Konstantin
2022-04-07 14:08               ` Aaron Conole
2022-04-13  2:49                 ` Huichao Cai
2022-04-11  3:55         ` [PATCH v6] " Huichao Cai
2022-04-14 13:14           ` Thomas Monjalon
2022-04-14 13:26             ` Thomas Monjalon
2022-04-15  1:52               ` Huichao Cai
2022-04-15  3:26           ` [PATCH v7] " Huichao Cai
2022-04-15  8:29             ` Ananyev, Konstantin
2022-05-29  8:50               ` Huichao Cai
2022-05-29  8:57               ` Huichao Cai
2022-05-29 10:38                 ` Konstantin Ananyev
2022-05-31 21:23               ` Thomas Monjalon
2022-06-16 15:10             ` David Marchand
2022-06-16 16:31               ` Stephen Hemminger
2022-06-17  3:52                 ` Huichao Cai
2022-06-17 16:31                   ` Stephen Hemminger [this message]
2022-06-18 11:01                     ` Huichao Cai

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=20220617093112.6c7f4945@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=chcchc88@163.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=thomas@monjalon.net \
    /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).