From mboxrd@z Thu Jan 1 00:00:00 1970 From: huawei.libin@huawei.com (libin) Date: Fri, 30 Oct 2015 16:44:11 +0800 Subject: [PATCH 3/3] recordmcount: arm64: replace the ignored mcount call into nop In-Reply-To: <1446193864-24593-4-git-send-email-huawei.libin@huawei.com> References: <1446193864-24593-1-git-send-email-huawei.libin@huawei.com> <1446193864-24593-4-git-send-email-huawei.libin@huawei.com> Message-ID: <56332DDB.8060701@huawei.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org on 2015/10/30 16:31, Li Bin wrote: > By now, the recordmcount only records the function that in > following sections: > .text/.ref.text/.sched.text/.spinlock.text/.irqentry.text/ > .kprobes.text/.text.unlikely > > For the function that not in these sections, the call mcount > will be in place and not be replaced when kernel boot up. And > it will bring performance overhead, such as do_mem_abort (in > .exception.text section). This patch make the call mcount to > nop for this case in recordmcount. > > Cc: # 3.18+ > Signed-off-by: Li Bin Acked-by: Will Deacon https://lkml.org/lkml/2015/10/28/301 > --- > scripts/recordmcount.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c > index 8cc020b..698768b 100644 > --- a/scripts/recordmcount.c > +++ b/scripts/recordmcount.c > @@ -42,6 +42,7 @@ > > #ifndef EM_AARCH64 > #define EM_AARCH64 183 > +#define R_AARCH64_NONE 0 > #define R_AARCH64_ABS64 257 > #endif > > @@ -160,6 +161,22 @@ static int make_nop_x86(void *map, size_t const offset) > return 0; > } > > +static unsigned char ideal_nop4_arm64[4] = {0x1f, 0x20, 0x03, 0xd5}; > +static int make_nop_arm64(void *map, size_t const offset) > +{ > + uint32_t *ptr; > + > + ptr = map + offset; > + /* bl <_mcount> is 0x94000000 before relocation */ > + if (*ptr != 0x94000000) > + return -1; > + > + /* Convert to nop */ > + ulseek(fd_map, offset, SEEK_SET); > + uwrite(fd_map, ideal_nop, 4); > + return 0; > +} > + > /* > * Get the whole file as a programming convenience in order to avoid > * malloc+lseek+read+free of many pieces. If successful, then mmap > @@ -354,7 +371,12 @@ do_file(char const *const fname) > altmcount = "__gnu_mcount_nc"; > break; > case EM_AARCH64: > - reltype = R_AARCH64_ABS64; gpfx = '_'; break; > + reltype = R_AARCH64_ABS64; > + make_nop = make_nop_arm64; > + rel_type_nop = R_AARCH64_NONE; > + ideal_nop = ideal_nop4_arm64; > + gpfx = '_'; > + break; > case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; > case EM_METAG: reltype = R_METAG_ADDR32; > altmcount = "_mcount_wrapper"; > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030563AbbJ3ItH (ORCPT ); Fri, 30 Oct 2015 04:49:07 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:30069 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758604AbbJ3ItC (ORCPT ); Fri, 30 Oct 2015 04:49:02 -0400 Subject: Re: [PATCH 3/3] recordmcount: arm64: replace the ignored mcount call into nop To: , , , , References: <1446193864-24593-1-git-send-email-huawei.libin@huawei.com> <1446193864-24593-4-git-send-email-huawei.libin@huawei.com> CC: , , , , , From: libin Message-ID: <56332DDB.8060701@huawei.com> Date: Fri, 30 Oct 2015 16:44:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1446193864-24593-4-git-send-email-huawei.libin@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.78] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.56332DE9.0069,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: 445a9a01a1e38d17937df795782abe4d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org on 2015/10/30 16:31, Li Bin wrote: > By now, the recordmcount only records the function that in > following sections: > .text/.ref.text/.sched.text/.spinlock.text/.irqentry.text/ > .kprobes.text/.text.unlikely > > For the function that not in these sections, the call mcount > will be in place and not be replaced when kernel boot up. And > it will bring performance overhead, such as do_mem_abort (in > .exception.text section). This patch make the call mcount to > nop for this case in recordmcount. > > Cc: # 3.18+ > Signed-off-by: Li Bin Acked-by: Will Deacon https://lkml.org/lkml/2015/10/28/301 > --- > scripts/recordmcount.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c > index 8cc020b..698768b 100644 > --- a/scripts/recordmcount.c > +++ b/scripts/recordmcount.c > @@ -42,6 +42,7 @@ > > #ifndef EM_AARCH64 > #define EM_AARCH64 183 > +#define R_AARCH64_NONE 0 > #define R_AARCH64_ABS64 257 > #endif > > @@ -160,6 +161,22 @@ static int make_nop_x86(void *map, size_t const offset) > return 0; > } > > +static unsigned char ideal_nop4_arm64[4] = {0x1f, 0x20, 0x03, 0xd5}; > +static int make_nop_arm64(void *map, size_t const offset) > +{ > + uint32_t *ptr; > + > + ptr = map + offset; > + /* bl <_mcount> is 0x94000000 before relocation */ > + if (*ptr != 0x94000000) > + return -1; > + > + /* Convert to nop */ > + ulseek(fd_map, offset, SEEK_SET); > + uwrite(fd_map, ideal_nop, 4); > + return 0; > +} > + > /* > * Get the whole file as a programming convenience in order to avoid > * malloc+lseek+read+free of many pieces. If successful, then mmap > @@ -354,7 +371,12 @@ do_file(char const *const fname) > altmcount = "__gnu_mcount_nc"; > break; > case EM_AARCH64: > - reltype = R_AARCH64_ABS64; gpfx = '_'; break; > + reltype = R_AARCH64_ABS64; > + make_nop = make_nop_arm64; > + rel_type_nop = R_AARCH64_NONE; > + ideal_nop = ideal_nop4_arm64; > + gpfx = '_'; > + break; > case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; > case EM_METAG: reltype = R_METAG_ADDR32; > altmcount = "_mcount_wrapper"; >