DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <gakhil@marvell.com>
To: "Andrew Boyer" <andrew.boyer@amd.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Andrew Rybchenko" <andrew.rybchenko@oktetlabs.ru>
Cc: "thomas@monjalon.net" <thomas@monjalon.net>
Subject: RE: [EXT] [PATCH] cryptodev: add a simple mapping cache to speed up ops pool create
Date: Tue, 6 Feb 2024 14:24:57 +0000	[thread overview]
Message-ID: <CO6PR18MB448494DA505EB32BDCEF3E17D8462@CO6PR18MB4484.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20240119164122.11829-1-andrew.boyer@amd.com>


> Cache the most recent VA -> PA mapping found so that we can skip
> most of the system calls. With 4K pages this reduces pool create
> time by about 90%.
> 
> Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>

I believe there should be a generic solution for this in mempool
 if it is not there already.
Here, you are adding cache in mempool priv
which does not seem to be a correct place.
This optimization would be needed across all types of mempools.
Adding more people for comments.


> ---
>  lib/cryptodev/rte_crypto.h    |  5 +++++
>  lib/cryptodev/rte_cryptodev.c | 23 ++++++++++++++++++++++-
>  2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h
> index dbc2700da5..ee6aa1e40e 100644
> --- a/lib/cryptodev/rte_crypto.h
> +++ b/lib/cryptodev/rte_crypto.h
> @@ -220,6 +220,11 @@ struct rte_crypto_op_pool_private {
>  	/**< Crypto op pool type operation. */
>  	uint16_t priv_size;
>  	/**< Size of private area in each crypto operation. */
> +
> +	unsigned long vp_cache;
> +	/* Virtual page address of previous op. */
> +	rte_iova_t iovp_cache;
> +	/* I/O virtual page address of previous op. */
>  };
> 
> 
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index b233c0ecd7..d596f85a57 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -10,6 +10,7 @@
>  #include <errno.h>
>  #include <stdint.h>
>  #include <inttypes.h>
> +#include <unistd.h>
> 
>  #include <rte_log.h>
>  #include <rte_debug.h>
> @@ -2568,12 +2569,32 @@ rte_crypto_op_init(struct rte_mempool *mempool,
>  {
>  	struct rte_crypto_op *op = _op_data;
>  	enum rte_crypto_op_type type = *(enum rte_crypto_op_type
> *)opaque_arg;
> +	struct rte_crypto_op_pool_private *priv;
> +	unsigned long virt_addr = (unsigned long)(uintptr_t)_op_data;
> +#ifdef RTE_EXEC_ENV_WINDOWS
> +	unsigned long page_mask = 4095;
> +#else
> +	unsigned long page_mask = sysconf(_SC_PAGESIZE) - 1;
> +#endif
> +	unsigned long virt_page = virt_addr & ~page_mask;
> 
>  	memset(_op_data, 0, mempool->elt_size);
> 
>  	__rte_crypto_op_reset(op, type);
> 
> -	op->phys_addr = rte_mem_virt2iova(_op_data);
> +	priv = (struct rte_crypto_op_pool_private *)
> +		rte_mempool_get_priv(mempool);
> +
> +	if (virt_page == priv->vp_cache) {
> +		op->phys_addr = priv->iovp_cache + (virt_addr & page_mask);
> +	} else {
> +		op->phys_addr = rte_mem_virt2iova(_op_data);
> +
> +		/* Update cached values */
> +		priv->vp_cache = virt_page;
> +		priv->iovp_cache = op->phys_addr & ~page_mask;
> +	}
> +
>  	op->mempool = mempool;
>  }
> 
> --
> 2.17.1


  reply	other threads:[~2024-02-06 14:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 16:41 Andrew Boyer
2024-02-06 14:24 ` Akhil Goyal [this message]
2024-02-07  2:24   ` [EXT] " Morten Brørup
2024-02-07  3:02     ` Boyer, Andrew
2024-02-16 17:03 ` [PATCH v2] cryptodev: " Andrew Boyer
2024-02-16 17:18   ` Morten Brørup
2024-02-22  7:07   ` [EXT] " Akhil Goyal

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=CO6PR18MB448494DA505EB32BDCEF3E17D8462@CO6PR18MB4484.namprd18.prod.outlook.com \
    --to=gakhil@marvell.com \
    --cc=andrew.boyer@amd.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.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).