RE: [RFC,iov_iter v2 3/8] iov_iter: add copyin_iovec helper

From: David Laight
Date: Mon Jun 13 2022 - 03:55:27 EST


From: Joe Damato
> Sent: 12 June 2022 09:58
>
> copyin_iovec is a helper which wraps copyin and selects the right copy
> method based on the iter_copy_type.

A pretty bad description.

> Signed-off-by: Joe Damato <jdamato@xxxxxxxxxx>
> ---
> lib/iov_iter.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index d32d7e5..6720cb2 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -168,6 +168,15 @@ static int copyin(void *to, const void __user *from, size_t n)
> return n;
> }
>
> +static int copyin_iovec(void *to, const void __user *from, size_t n,
> + struct iov_iter *i)
> +{
> + if (unlikely(iov_iter_copy_is_nt(i)))
> + return __copy_from_user_nocache(to, from, n);
> + else
> + return copyin(to, from, n);
> +}

Isn't this extra conditional going to have a measurable impact
on all the normal copy paths?

The additional costs of all the 'iovec' types is bad enough
already.

David

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