mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* bcopy and page faults
@ 2004-12-16  7:40 firnnauriel
  2004-12-17 13:53 ` Horst von Brand
  0 siblings, 1 reply; 3+ messages in thread
From: firnnauriel @ 2004-12-16  7:40 UTC (permalink / raw)
  To: linux-kernel

In general, is there a correlation between the number
of page faults occurred in the system and bcopy's
performance? 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!

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bcopy and page faults
  2004-12-16  7:40 bcopy and page faults firnnauriel
@ 2004-12-17 13:53 ` Horst von Brand
  2004-12-17 14:56   ` linux-os
  0 siblings, 1 reply; 3+ messages in thread
From: Horst von Brand @ 2004-12-17 13:53 UTC (permalink / raw)
  To: firnnauriel; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: bcopy and page faults
  2004-12-17 13:53 ` Horst von Brand
@ 2004-12-17 14:56   ` linux-os
  0 siblings, 0 replies; 3+ messages in thread
From: linux-os @ 2004-12-17 14:56 UTC (permalink / raw)
  To: Horst von Brand; +Cc: firnnauriel, linux-kernel

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-17 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-16  7:40 bcopy and page faults firnnauriel
2004-12-17 13:53 ` Horst von Brand
2004-12-17 14:56   ` linux-os

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®