performance: memcpy vs. __copy_tofrom_user
Paul Mackerras
paulus at samba.org
Thu Oct 9 13:34:02 EST 2008
Grant Likely writes:
> On Wed, Oct 08, 2008 at 04:39:13PM +0200, Dominik Bozek wrote:
> > Hi all,
> >
> > 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. So then
> > memcpy() shall be faster than __copy_tofrom_user(). Am I right?
> > Is here anybody, who can confirm such results and maybe is able to
> > improve the memcpy()?
When I looked at this last (which was a few years ago, I'll admit), I
found that the vast majority of memcpy calls were for small copies,
i.e. less than 128 bytes, whereas __copy_tofrom_user was often used
for larger copies (usually 1 page). So with memcpy the focus was more
on keeping the startup costs low, while __copy_tofrom_user was
optimized more for bandwidth.
The other point is that the kernel memcpy doesn't consume a noticeable
amount of CPU time (at least not on any workload I've seen), so it
hasn't been a target for aggressive optimization.
Paul.
More information about the Linuxppc-dev
mailing list