lkml.org 
[lkml]   [2004]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: bcopy and page faults
On Fri, 17 Dec 2004, Horst von Brand wrote:

> firnnauriel <rinoa012000@yahoo.com> said:
>> In general, is there a correlation between the number
>> of page faults occurred in the system and bcopy's
>> performance?
>
> No.
>
>> If the page fault is high, will the
>> bcopy's performance become slower? Kindly enlighten me
>> on this. If you can provide a URL that will support
>> your answer, I will really appreciate it. Thank you
>> very much!
>
> bcopy(3) copies stuff inside a process. If the memory areas copied from/to
> are available in RAM, the copy will go at full speed. If not, there will be
> delays (due to paging, etc). Now, the system might be paging like mad, but
> the memory _this_ process requires is available (== full speed bcopy), or
> there might be almost no paging activity, but the pages required for the
> copy aren't in RAM (== slowest possible).
>
> PS: Consider using memcpy(3), bcopy is non-standard.
> --
> Dr. Horst H. von Brand User #22616 counter.li.org
> Departamento de Informatica Fono: +56 32 654431
> Universidad Tecnica Federico Santa Maria +56 32 654239
> Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513

FYI `bcopy()` can copy overlapping buffers. It does this by
determining if the destination buffer is higher or lower than
the source buffer. If it's higher, it's an ordinary memcpy()
if it's lower, it copies backwards so that it doesn't end up
copying what was just copied, etc., the result being junk.

Both can cause page-faulting if the buffers are not in
memory. Because bcopy() has some additional starting logic,
it might be slower. Some POSIX man-pages claim that it's
deprecated and one should use memmove() instead. The Linux
man page claims one should use memcpy(), but this is wrong
because memcpy cannot successfully copy overlapping buffers.

So, if the buffers overlap, use memmove(). If not use memcpy().
This different usage might alert people who look at the code
in the future that there was some special reason for using
memmove().

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.048 / U:0.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site