lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7d1b2ab7-0cd8-44b4-bcb5-9bd31ce650e5@kernel.dk>
Date: Tue, 15 Jul 2025 11:14:02 -0600
From: Jens Axboe <axboe@...nel.dk>
To: Chaitanya Kulkarni <chaitanyak@...dia.com>, "axboe@...com" <axboe@...com>
Cc: "aurelien.aptel@...il.com" <aurelien.aptel@...il.com>,
 Shai Malin <smalin@...dia.com>, "malin1024@...il.com" <malin1024@...il.com>,
 Or Gerlitz <ogerlitz@...dia.com>, Yoray Zack <yorayz@...dia.com>,
 Boris Pismenny <borisp@...dia.com>, "davem@...emloft.net"
 <davem@...emloft.net>, "kbusch@...nel.org" <kbusch@...nel.org>,
 "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>,
 Gal Shalom <galshalom@...dia.com>, Max Gurtovoy <mgurtovoy@...dia.com>,
 Tariq Toukan <tariqt@...dia.com>,
 "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
 "gus@...labora.com" <gus@...labora.com>,
 "viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
 "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
 Aurelien Aptel <aaptel@...dia.com>, "sagi@...mberg.me" <sagi@...mberg.me>,
 "hch@....de" <hch@....de>, "kuba@...nel.org" <kuba@...nel.org>
Subject: Re: [PATCH v30 03/20] iov_iter: skip copy if src == dst for direct
 data placement

On 7/15/25 11:08 AM, Chaitanya Kulkarni wrote:
> Jens,
> 
> On 7/15/25 08:06, Jens Axboe wrote:
>> On 7/15/25 7:27 AM, Aurelien Aptel wrote:
>>> 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 f9193f952f49..47fdb32653a2 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;
>>>   }
>> This seems like entirely the wrong place to apply this logic...
>>
> 
> do you have any specific preference where it needs to be moved ?
> or any other way you would prefer ?

In the caller? First of all, having any kind of odd kconfig check in the
iov iter code makes zero sense. Why would a copy helper need to care at
all about what kind of drivers are enabled in the kernel? It's a gross
hack and layering violation.

-- 
Jens Axboe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ