Re: [RFC PATCH] iov_iter: Convert iterate*() to inline funcs

From: David Howells
Date: Mon Aug 14 2023 - 09:14:41 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

>
> So I think you need to remove the changes you did to
> memcpy_from_iter(). The old code was an explicit conditional of direct
> calls:
>
> if (iov_iter_is_copy_mc(i))
> return (void *)copy_mc_to_kernel(to, from, size);
> return memcpy(to, from, size);
>
> and now you do that
>
> iov_iter_is_copy_mc(i) ?
> memcpy_from_iter_mc : memcpy_from_iter);
>
> to pass in a function pointer.
>
> Not ok. Not ok at all. It may look clever, but function pointers are
> bad. Avoid them like the plague.

Yeah. I was hoping that the compiler would manage to inline that, but it just
does an indirect call. I'm trying to avoid passing the iterator as that makes
things bigger. I think I can probably share the extra argument used for
passing checksums.

David