<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
<div><br>
<blockquote type="cite">
<div>On Feb 6, 2024, at 9:24 PM, Morten Brørup <mb@smartsharesystems.com> wrote:</div>
<br class="Apple-interchange-newline">
<div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">Caution:
This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
From: Akhil Goyal [<a href="mailto:gakhil@marvell.com">mailto:gakhil@marvell.com</a>]<br>
Sent: Tuesday, 6 February 2024 15.25<br>
<br>
<blockquote type="cite">Cache the most recent VA -> PA mapping found so that we can skip<br>
most of the system calls. With 4K pages this reduces pool create<br>
time by about 90%.<br>
<br>
Signed-off-by: Andrew Boyer <andrew.boyer@amd.com><br>
</blockquote>
<br>
I believe there should be a generic solution for this in mempool<br>
if it is not there already.<br>
Here, you are adding cache in mempool priv<br>
which does not seem to be a correct place.<br>
This optimization would be needed across all types of mempools.<br>
Adding more people for comments.<br>
<br>
<br>
<blockquote type="cite">---<br>
lib/cryptodev/rte_crypto.h | 5 +++++<br>
lib/cryptodev/rte_cryptodev.c | 23 ++++++++++++++++++++++-<br>
2 files changed, 27 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/lib/cryptodev/rte_crypto.h b/lib/cryptodev/rte_crypto.h<br>
index dbc2700da5..ee6aa1e40e 100644<br>
--- a/lib/cryptodev/rte_crypto.h<br>
+++ b/lib/cryptodev/rte_crypto.h<br>
@@ -220,6 +220,11 @@ struct rte_crypto_op_pool_private {<br>
/**< Crypto op pool type operation. */<br>
uint16_t priv_size;<br>
/**< Size of private area in each crypto operation. */<br>
+<br>
+ unsigned long vp_cache;<br>
+ /* Virtual page address of previous op. */<br>
+ rte_iova_t iovp_cache;<br>
+ /* I/O virtual page address of previous op. */<br>
};<br>
<br>
<br>
diff --git a/lib/cryptodev/rte_cryptodev.c<br>
</blockquote>
b/lib/cryptodev/rte_cryptodev.c<br>
<blockquote type="cite">index b233c0ecd7..d596f85a57 100644<br>
--- a/lib/cryptodev/rte_cryptodev.c<br>
+++ b/lib/cryptodev/rte_cryptodev.c<br>
@@ -10,6 +10,7 @@<br>
#include <errno.h><br>
#include <stdint.h><br>
#include <inttypes.h><br>
+#include <unistd.h><br>
<br>
#include <rte_log.h><br>
#include <rte_debug.h><br>
@@ -2568,12 +2569,32 @@ rte_crypto_op_init(struct rte_mempool<br>
</blockquote>
*mempool,<br>
<blockquote type="cite">{<br>
struct rte_crypto_op *op = _op_data;<br>
enum rte_crypto_op_type type = *(enum rte_crypto_op_type<br>
*)opaque_arg;<br>
+ struct rte_crypto_op_pool_private *priv;<br>
+ unsigned long virt_addr = (unsigned long)(uintptr_t)_op_data;<br>
+#ifdef RTE_EXEC_ENV_WINDOWS<br>
+ unsigned long page_mask = 4095;<br>
+#else<br>
+ unsigned long page_mask = sysconf(_SC_PAGESIZE) - 1;<br>
+#endif<br>
+ unsigned long virt_page = virt_addr & ~page_mask;<br>
<br>
memset(_op_data, 0, mempool->elt_size);<br>
<br>
__rte_crypto_op_reset(op, type);<br>
<br>
- op->phys_addr = rte_mem_virt2iova(_op_data);<br>
</blockquote>
</blockquote>
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">This
optimization is for rte_mem_virt2iova(_op_data) being slow.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">If
I'm not mistaken, _op_data is an object in a mempool, where the mempool object headers have already been initialized.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">In
this case, it could simply be optimized as this:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">-
op->phys_addr = rte_mem_virt2iova(_op_data);</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">+
op->phys_addr = rte_mempool_virt2iova(_op_data);</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
</div>
</blockquote>
</div>
<br>
<div>That certainly is shorter! Thanks, I was not aware of this function.</div>
<div><br>
</div>
<div>-Andrew</div>
</body>
</html>