[ltt-dev] [PATCH] LTTng optimize write to page function

KOSAKI Motohiro kosaki.motohiro at jp.fujitsu.com
Wed Feb 4 03:09:59 EST 2009


> 
> void testfct_memcpy(void)
> {
>         asm ("/* begin */");
>         memcpy(dataout, datain, sizea);
>         asm ("/* end */");
> }
> 
> Turns into a function call because the size is not statically known :
> 
>         movslq  sizea(%rip),%rdx
>         movq    $datain, %rsi
>         movq    $dataout, %rdi
>         call    memcpy
> 
> 
> Below, when a constant is passed, both behave similarly :
> 
> void testfct_ltt_const(void)
> {
>         asm ("/* begin */");
>         ltt_relay_do_copy(dataout, datain, 8);
>         asm ("/* end*/");
> }
> 
>         movq    datain(%rip), %rax
>         movq    %rax, dataout(%rip)
> 
> 
> void testfct_memcpy_const(void)
> {
>         asm ("/* begin */");
>         memcpy(dataout, datain, 8);
>         asm ("/* end */");
> }
> 
>         movq    datain(%rip), %rax
>         movq    %rax, dataout(%rip)
> 
> 
> Therefore, I agree that when memcpy is passed a constant, it will do
> the same as my ltt_relay_do_copy. However, when we know we usually
> expect sizes of 1, 2, 4 and 8 bytes (unknown at compile-time), the jump
> table saves the costly function call to memcpy.

Thank you for good clarification!!

So, I hope to this result append to patch description.
I guess many lkml guys like this interesting analysis and result :)







More information about the lttng-dev mailing list