DPDK patches and discussions
 help / color / mirror / Atom feed
From: fengchengwen <fengchengwen@huawei.com>
To: Jie Hai <haijie1@huawei.com>, <dev@dpdk.org>,
	<thomas@monjalon.net>, <ferruh.yigit@amd.com>
Cc: <lihuisong@huawei.com>
Subject: Re: [PATCH v3 2/2] examples/l3fwd: add option to set mbuf cache size
Date: Thu, 17 Oct 2024 19:10:00 +0800	[thread overview]
Message-ID: <def58e5f-d8c7-4b96-ab2a-b1104adfebdb@huawei.com> (raw)
In-Reply-To: <20241017095858.27865-3-haijie1@huawei.com>

There's a little tip that can be modified, with that modified:
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

On 2024/10/17 17:58, Jie Hai wrote:
> The mempool cache size of mbuf is set to
> RTE_MEMPOOL_CACHE_MAX_SIZE as default. This patch allows
> users to configure the cache size by "--mbcache", and limits
> the parameter to a maximum of RTE_MEMPOOL_CACHE_MAX_SIZE.
> 
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> Acked-by: Huisong Li <lihuisong@huawei.com>
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
> ---
>  examples/l3fwd/l3fwd.h |  1 +
>  examples/l3fwd/main.c  | 33 ++++++++++++++++++++++++++++++---
>  2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
> index 618e0eaa3af1..0cce3406ee7d 100644
> --- a/examples/l3fwd/l3fwd.h
> +++ b/examples/l3fwd/l3fwd.h
> @@ -117,6 +117,7 @@ extern struct acl_algorithms acl_alg[];
>  extern uint32_t max_pkt_len;
>  
>  extern uint32_t nb_pkt_per_burst;
> +extern uint32_t mb_mempool_cache_size;
>  
>  /* Send burst of packets on an output interface */
>  static inline int
> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index 8b7a07cc7d67..d08525faa1a6 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -58,6 +58,7 @@ static_assert(MEMPOOL_CACHE_SIZE >= MAX_PKT_BURST, "MAX_PKT_BURST should be at m
>  uint16_t nb_rxd = RX_DESC_DEFAULT;
>  uint16_t nb_txd = TX_DESC_DEFAULT;
>  uint32_t nb_pkt_per_burst = DEFAULT_PKT_BURST;
> +uint32_t mb_mempool_cache_size = MEMPOOL_CACHE_SIZE;
>  
>  /**< Ports set in promiscuous mode off by default. */
>  static int promiscuous_on;
> @@ -399,6 +400,7 @@ print_usage(const char *prgname)
>  		" [--rx-queue-size NPKTS]"
>  		" [--tx-queue-size NPKTS]"
>  		" [--burst NPKTS]"
> +		" [--mbcache CACHESZ]"
>  		" [--eth-dest=X,MM:MM:MM:MM:MM:MM]"
>  		" [--max-pkt-len PKTLEN]"
>  		" [--no-numa]"
> @@ -426,6 +428,8 @@ print_usage(const char *prgname)
>  		"            Default: %d\n"
>  		"  --burst NPKTS: Burst size in decimal\n"
>  		"            Default: %d\n"
> +		"  --mbcache CACHESZ: Cache size in decimal\n"

Suggest "  --mbcache CACHESZ: Mbuf cache size in decimal\n"

> +		"            Default: %d\n"
>  		"  --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for port X\n"
>  		"  --max-pkt-len PKTLEN: maximum packet length in decimal (64-9600)\n"
>  		"  --no-numa: Disable numa awareness\n"
> @@ -455,7 +459,7 @@ print_usage(const char *prgname)
>  		"                    another is route entry at while line leads with character '%c'.\n"
>  		"  --rule_ipv6=FILE: Specify the ipv6 rules entries file.\n"
>  		"  --alg: ACL classify method to use, one of: %s.\n\n",
> -		prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST,
> +		prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST, MEMPOOL_CACHE_SIZE,
>  		ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg);
>  }
>  
> @@ -673,6 +677,22 @@ parse_lookup(const char *optarg)
>  	return 0;
>  }
>  
> +static void
> +parse_mbcache_size(const char *optarg)
> +{
> +	unsigned long mb_cache_size;
> +	char *end = NULL;
> +
> +	mb_cache_size = strtoul(optarg, &end, 10);
> +	if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0'))
> +		return;
> +	if (mb_cache_size <= RTE_MEMPOOL_CACHE_MAX_SIZE)
> +		mb_mempool_cache_size = (uint32_t)mb_cache_size;
> +	else
> +		rte_exit(EXIT_FAILURE, "mbcache must be >= 0 and <= %d\n",
> +			 RTE_MEMPOOL_CACHE_MAX_SIZE);
> +}
> +
>  static void
>  parse_pkt_burst(const char *optarg)
>  {
> @@ -748,6 +768,7 @@ static const char short_options[] =
>  #define CMD_LINE_OPT_RULE_IPV6 "rule_ipv6"
>  #define CMD_LINE_OPT_ALG "alg"
>  #define CMD_LINE_OPT_PKT_BURST "burst"
> +#define CMD_LINE_OPT_MB_CACHE_SIZE "mbcache"
>  
>  enum {
>  	/* long options mapped to a short option */
> @@ -777,7 +798,8 @@ enum {
>  	CMD_LINE_OPT_ENABLE_VECTOR_NUM,
>  	CMD_LINE_OPT_VECTOR_SIZE_NUM,
>  	CMD_LINE_OPT_VECTOR_TMO_NS_NUM,
> -	CMD_LINE_OPT_PKT_BURST_NUM
> +	CMD_LINE_OPT_PKT_BURST_NUM,
> +	CMD_LINE_OPT_MB_CACHE_SIZE_NUM
>  };
>  
>  static const struct option lgopts[] = {
> @@ -805,6 +827,7 @@ static const struct option lgopts[] = {
>  	{CMD_LINE_OPT_RULE_IPV6,   1, 0, CMD_LINE_OPT_RULE_IPV6_NUM},
>  	{CMD_LINE_OPT_ALG,   1, 0, CMD_LINE_OPT_ALG_NUM},
>  	{CMD_LINE_OPT_PKT_BURST,   1, 0, CMD_LINE_OPT_PKT_BURST_NUM},
> +	{CMD_LINE_OPT_MB_CACHE_SIZE,   1, 0, CMD_LINE_OPT_MB_CACHE_SIZE_NUM},
>  	{NULL, 0, 0, 0}
>  };
>  
> @@ -897,6 +920,10 @@ parse_args(int argc, char **argv)
>  			parse_pkt_burst(optarg);
>  			break;
>  
> +		case CMD_LINE_OPT_MB_CACHE_SIZE_NUM:
> +			parse_mbcache_size(optarg);
> +			break;
> +
>  		case CMD_LINE_OPT_ETH_DEST_NUM:
>  			parse_eth_dest(optarg);
>  			break;
> @@ -1089,7 +1116,7 @@ init_mem(uint16_t portid, unsigned int nb_mbuf)
>  				 portid, socketid);
>  			pktmbuf_pool[portid][socketid] =
>  				rte_pktmbuf_pool_create(s, nb_mbuf,
> -					MEMPOOL_CACHE_SIZE, 0,
> +					mb_mempool_cache_size, 0,
>  					RTE_MBUF_DEFAULT_BUF_SIZE, socketid);
>  			if (pktmbuf_pool[portid][socketid] == NULL)
>  				rte_exit(EXIT_FAILURE,


  reply	other threads:[~2024-10-17 11:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12  8:40 [PATCH] examples/l3fwd: add option to set RX burst size Jie Hai
2024-10-12  9:06 ` fengchengwen
2024-10-12 12:22 ` Morten Brørup
2024-10-17  8:58 ` [PATCH v2 0/2] examples/l3fwd: add more options Jie Hai
2024-10-17  8:58   ` [PATCH v2 1/2] examples/l3fwd: add option to set RX burst size Jie Hai
2024-10-17  9:37     ` lihuisong (C)
2024-10-17  8:58   ` [PATCH v2 2/2] examples/l3fwd: add option to set mbuf cache size Jie Hai
2024-10-17  9:40     ` lihuisong (C)
2024-10-17  9:18   ` [PATCH v2 0/2] examples/l3fwd: add more options Morten Brørup
2024-10-17  9:58 ` [PATCH v3 " Jie Hai
2024-10-17  9:58   ` [PATCH v3 1/2] examples/l3fwd: add option to set RX burst size Jie Hai
2024-10-17  9:58   ` [PATCH v3 2/2] examples/l3fwd: add option to set mbuf cache size Jie Hai
2024-10-17 11:10     ` fengchengwen [this message]
2024-10-18  1:08 ` [PATCH v4 0/2] examples/l3fwd: add more options Jie Hai
2024-10-18  1:08   ` [PATCH v4 1/2] examples/l3fwd: add option to set RX burst size Jie Hai
2024-10-18  1:08   ` [PATCH v4 2/2] examples/l3fwd: add option to set mbuf cache size Jie Hai

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=def58e5f-d8c7-4b96-ab2a-b1104adfebdb@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=haijie1@huawei.com \
    --cc=lihuisong@huawei.com \
    --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).