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] [thread-next>] [day] [month] [year] [list]
Message-ID: <a779982fc59f4b9b94d619d0bb111738@AcuMS.aculab.com>
Date: Tue, 16 Apr 2024 20:30:09 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Aurelien Aptel' <aaptel@...dia.com>, "linux-nvme@...ts.infradead.org"
	<linux-nvme@...ts.infradead.org>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "sagi@...mberg.me" <sagi@...mberg.me>, "hch@....de"
	<hch@....de>, "kbusch@...nel.org" <kbusch@...nel.org>, "axboe@...com"
	<axboe@...com>, "chaitanyak@...dia.com" <chaitanyak@...dia.com>,
	"davem@...emloft.net" <davem@...emloft.net>, "kuba@...nel.org"
	<kuba@...nel.org>
CC: "aurelien.aptel@...il.com" <aurelien.aptel@...il.com>, "smalin@...dia.com"
	<smalin@...dia.com>, "malin1024@...il.com" <malin1024@...il.com>,
	"ogerlitz@...dia.com" <ogerlitz@...dia.com>, "yorayz@...dia.com"
	<yorayz@...dia.com>, "borisp@...dia.com" <borisp@...dia.com>,
	"galshalom@...dia.com" <galshalom@...dia.com>, "mgurtovoy@...dia.com"
	<mgurtovoy@...dia.com>, "viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>
Subject: RE: [PATCH v24 03/20] iov_iter: skip copy if src == dst for direct
 data placement

From: Aurelien Aptel
> Sent: 04 April 2024 13:37
> 
> 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.
...
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 4a6a9f419bd7..a85125485174 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 (iter_to != from + progress)
> +		memcpy(iter_to, from + progress, len);

How must does this conditional cost for the normal case
when it is true?
I suspect it is mispredicted 50% of the time.
So, while it may speed up your test, the overall system
impact will be negative.

	David

>  	return 0;
>  }
> 
> --
> 2.34.1
> 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ