[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240529160053.111531-4-aaptel@nvidia.com>
Date: Wed, 29 May 2024 16:00:36 +0000
From: Aurelien Aptel <aaptel@...dia.com>
To: linux-nvme@...ts.infradead.org,
netdev@...r.kernel.org,
sagi@...mberg.me,
hch@....de,
kbusch@...nel.org,
axboe@...com,
chaitanyak@...dia.com,
davem@...emloft.net,
kuba@...nel.org
Subject: [PATCH v25 03/20] iov_iter: skip copy if src == dst for direct data placement
From: Ben Ben-Ishay <benishay@...dia.com>
When using direct data placement (DDP) the NIC could write the payload
directly into the destination buffer and constructs SKBs such that
they point to this data. To skip copies when SKB data already resides
in the destination buffer we check if (src == dst), and skip the copy
when it's true.
Signed-off-by: Ben Ben-Ishay <benishay@...dia.com>
Signed-off-by: Boris Pismenny <borisp@...dia.com>
Signed-off-by: Or Gerlitz <ogerlitz@...dia.com>
Signed-off-by: Yoray Zack <yorayz@...dia.com>
Signed-off-by: Shai Malin <smalin@...dia.com>
Signed-off-by: Aurelien Aptel <aaptel@...dia.com>
Reviewed-by: Chaitanya Kulkarni <kch@...dia.com>
Reviewed-by: Max Gurtovoy <mgurtovoy@...dia.com>
---
lib/iov_iter.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 4a6a9f419bd7..8a250b120c4e 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -62,7 +62,14 @@ static __always_inline
size_t memcpy_to_iter(void *iter_to, size_t progress,
size_t len, void *from, void *priv2)
{
- memcpy(iter_to, from + progress, len);
+ /*
+ * When using direct data placement (DDP) the hardware writes
+ * data directly to the destination buffer, and constructs
+ * IOVs such that they point to this data.
+ * Thus, when the src == dst we skip the memcpy.
+ */
+ if (!(IS_ENABLED(CONFIG_ULP_DDP) && iter_to == from + progress))
+ memcpy(iter_to, from + progress, len);
return 0;
}
--
2.34.1
Powered by blists - more mailing lists