Re: csum_partial_copy_fromuser patch, #2

Tom May (ftom@netcom.com)
01 Feb 1997 13:30:17 -0800


Ingo Molnar <mingo@pc5829.hil.siemens.at> writes:

> ok, this patch is for real. No checksumming oops-es should happen, if yes,
> then please tell me ...

> comments welcome.

> +unsigned int csum_partial_copy_from_user( int * err, const char *src,
> + char *dst, int len, int sum);
> +
> +/*
> + * I hope GCC will optimize 'dummy' away ...
> + */
> +
> +unsigned int csum_partial_copy_nocheck_generic( int * err, const char *src, char *dst,
> + int len, int sum);
>
> +extern __inline__ unsigned int csum_partial_copy_nocheck ( const char *src, char *dst,
> + int len, int sum)
> +{
> + int dummy;
> +
> + return csum_partial_copy_nocheck_generic ( &dummy, src, dst, len, sum);
> +}

Regarding "I hope GCC will optimize 'dummy' away ...": it won't. It
*must* pass a pointer to non-inline function
csum_partial_copy_nocheck_generic(). It might work better to make
csum_partial_copy_nocheck_generic() and its variations inline but put
a non-inline wrapper around them, i.e., opposite of what you did. You
will still have to do some hacks to stop the asm stuff from setting
*err in the nocheck case though. It won't be pretty. You might end
up giving up on using a common macro and just write the checked and
unchecked cases out explicitly. It will probably make things more
obvious.

> + : "=a" (sum), "=r" (*__csum_err) \
> + : "0" (sum), "c" (len), "S" (src), "D" (dst), \
> + "1" (*__csum_err), "i" (-EFAULT) \
> + : "bx", "cx", "dx", "si", "di" ); \
> + \
> + return(sum); \
> +}

Have you tried "=g" to see whether it produces better code than "=r"?
There should be no reason to force the move through a register when it
could just drop -EFAULT directly into memory.

Tom.