performance: memcpy vs. __copy_tofrom_user
Scott Wood
scottwood at freescale.com
Thu Oct 9 04:40:31 EST 2008
Dominik Bozek wrote:
> I have done a test of memcpy() and __copy_tofrom_user() on the mpc8313.
> And the major conclusion is that __copy_tofrom_user is more efficient
> than memcpy. Sometimes about 40%.
>
> If I good understand, the memcpy() just copy the data, while
> __copy_tofrom_user() take care if the memory wasn't swapped out.
There's not much overhead in dealing with bad pointers; it's mostly
fixup after the fault.
The performance difference most likely comes from the fact that copy
to/from user can assume that the memory is cacheable, while memcpy is
occasionally used on cache-inhibited memory -- so dcbz isn't used. We
may be better off handling the alignment fault on those occasions, and
we should use dcba on chips that support it.
I'm not sure why we don't use dcbt in memcpy(), as it's just ignored if
the memory is cache-inhibited.
> BTW. The memcpy() maybe optimized as it is on i32 when the size of block
> is known at compile time.
Yes, that would be nice.
-Scott
More information about the Linuxppc-embedded
mailing list