From mboxrd@z Thu Jan 1 00:00:00 1970 From: kosaki.motohiro@jp.fujitsu.com (KOSAKI Motohiro) Date: Wed, 4 Feb 2009 17:09:59 +0900 (JST) Subject: [ltt-dev] [PATCH] LTTng optimize write to page function In-Reply-To: <20090204054422.GD8231@Krystal> References: <20090204132458.ECC0.KOSAKI.MOTOHIRO@jp.fujitsu.com> <20090204054422.GD8231@Krystal> Message-ID: <20090204155207.ECC6.KOSAKI.MOTOHIRO@jp.fujitsu.com> > > 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 :)