Re: [RFC PATCH 2/4] vhost: add byteswap routines

Cornelia Huck
2014-11-03T15:38:22Z

On Wed, 29 Oct 2014 09:38:43 +0100
Cédric Le Goater <clg@fr.ibm.com> wrote:

> This patch adds a few helper routines around get_user and put_user
> to ease byteswapping.
>
> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
> ---
>
> I am not sure these routines belong to this file. There is room for
> improvement to remove the ugly switch (sizeof(*(ptr))). Please
> comment !
>
> drivers/vhost/vhost.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 93 insertions(+)
>

I'm wondering whether it would be a good idea to introduce generic
{get,put}_user_reversed() routines.

That way, you would push the switch (sizeof(*(ptr)) into uaccess code,
where it needs to be done anyway. It also makes it possible to add
optimizations there.