From mboxrd@z Thu Jan 1 00:00:00 1970 From: compudj@krystal.dyndns.org (Mathieu Desnoyers) Date: Wed, 4 Feb 2009 12:54:21 -0500 Subject: [ltt-dev] [PATCH] LTTng optimize write to page function In-Reply-To: <20090204155207.ECC6.KOSAKI.MOTOHIRO@jp.fujitsu.com> References: <20090204132458.ECC0.KOSAKI.MOTOHIRO@jp.fujitsu.com> <20090204054422.GD8231@Krystal> <20090204155207.ECC6.KOSAKI.MOTOHIRO@jp.fujitsu.com> Message-ID: <20090204175421.GA28035@Krystal> * KOSAKI Motohiro (kosaki.motohiro at jp.fujitsu.com) wrote: > > > > 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 :) > I will append it to the changelog. Thanks for asking such clarification while everything was still fresh in my mind. Mathieu > > > > _______________________________________________ > ltt-dev mailing list > ltt-dev at lists.casi.polymtl.ca > http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev > -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68