From patchwork Fri Mar 25 12:26:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 64464 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp146225lbc; Fri, 25 Mar 2016 05:27:32 -0700 (PDT) X-Received: by 10.66.172.167 with SMTP id bd7mr20955019pac.116.1458908851352; Fri, 25 Mar 2016 05:27:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fn9si1546454pab.163.2016.03.25.05.27.31; Fri, 25 Mar 2016 05:27:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752742AbcCYM12 (ORCPT + 29 others); Fri, 25 Mar 2016 08:27:28 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:54389 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752551AbcCYM10 (ORCPT ); Fri, 25 Mar 2016 08:27:26 -0400 Received: from 172.24.1.50 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.50]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BYR74084; Fri, 25 Mar 2016 20:27:10 +0800 (CST) Received: from [127.0.0.1] (10.111.66.109) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Fri, 25 Mar 2016 20:26:59 +0800 Subject: Re: [PATCH 3/5] perf core: Prepare writing into ring buffer from end To: Peter Zijlstra References: <1457949585-191064-1-git-send-email-wangnan0@huawei.com> <1457949585-191064-4-git-send-email-wangnan0@huawei.com> <20160323095007.GW6344@twins.programming.kicks-ass.net> CC: , , He Kuang , Alexei Starovoitov , "Arnaldo Carvalho de Melo" , Brendan Gregg , "Jiri Olsa" , Masami Hiramatsu , Namhyung Kim , Zefan Li , From: "Wangnan (F)" Message-ID: <56F52E83.70409@huawei.com> Date: Fri, 25 Mar 2016 20:26:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160323095007.GW6344@twins.programming.kicks-ass.net> X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.56F52E9F.00F9, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9391db4aa22c80e2fb0d9f397f38fd66 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/3/23 17:50, Peter Zijlstra wrote: > On Mon, Mar 14, 2016 at 09:59:43AM +0000, Wang Nan wrote: >> Convert perf_output_begin to __perf_output_begin and make the later >> function able to write records from the end of the ring buffer. >> Following commits will utilize the 'backward' flag. >> >> This patch doesn't introduce any extra performance overhead since we >> use always_inline. > So while I agree that with __always_inline and constant propagation we > _should_ end up with the same code, we have: > > $ size defconfig-build/kernel/events/ring_buffer.o.{pre,post} > text data bss dec hex filename > 3785 2 0 3787 ecb defconfig-build/kernel/events/ring_buffer.o.pre > 3673 2 0 3675 e5b defconfig-build/kernel/events/ring_buffer.o.post > > The patch actually makes the file shrink. > > So I think we still want to have some actual performance numbers. In my environment the two objects are nearly idential: $ objdump -d kernel/events/ring_buffer.o.new > ./out.new.S $ objdump -d kernel/events/ring_buffer.o.old > ./out.old.S 4a2: e8 00 00 00 00 callq 4a7 @@ -874,7 +874,7 @@ c39: eb e7 jmp c22 c3b: 80 3d 00 00 00 00 00 cmpb $0x0,0x0(%rip) # c42 c42: 75 93 jne bd7 - c44: be 2b 01 00 00 mov $0x12b,%esi + c44: be 49 01 00 00 mov $0x149,%esi c49: 48 c7 c7 00 00 00 00 mov $0x0,%rdi c50: e8 00 00 00 00 callq c55 c55: c6 05 00 00 00 00 01 movb $0x1,0x0(%rip) # c5c I think you enabled some unusual config options? Thank you. --- ./out.old.S 2016-03-25 12:18:52.060656423 +0000 +++ ./out.new.S 2016-03-25 12:18:45.376630269 +0000 @@ -1,5 +1,5 @@ -kernel/events/ring_buffer.o.old: file format elf64-x86-64 +kernel/events/ring_buffer.o.new: file format elf64-x86-64 Disassembly of section .text: @@ -320,7 +320,7 @@ 402: 4d 8d 04 0f lea (%r15,%rcx,1),%r8 406: 48 89 c8 mov %rcx,%rax 409: 4c 0f b1 43 40 cmpxchg %r8,0x40(%rbx) - 40e: 48 39 c8 cmp %rcx,%rax + 40e: 48 39 c1 cmp %rax,%rcx 411: 75 b4 jne 3c7 413: 48 8b 73 58 mov 0x58(%rbx),%rsi 417: 48 8b 43 68 mov 0x68(%rbx),%rax @@ -357,7 +357,7 @@ 480: 85 c0 test %eax,%eax 482: 0f 85 02 ff ff ff jne 38a 488: 48 c7 c2 00 00 00 00 mov $0x0,%rdx - 48f: be 7c 00 00 00 mov $0x7c,%esi + 48f: be 89 00 00 00 mov $0x89,%esi 494: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 49b: c6 05 00 00 00 00 01 movb $0x1,0x0(%rip) # 4a2