Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1257759

[PATCH] recordmcount: arm64: replace the ignored mcount call into nop

From Li Bin <huawei.libin@huawei.com>
Newsgroups linux.kernel
Subject [PATCH] recordmcount: arm64: replace the ignored mcount call into nop
Date 2015-10-28 09:10 +0100
Message-ID <qotXZ-8vm-43@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
 scripts/recordmcount.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 3d1984e..f697226 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,21 @@ 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;
+	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
@@ -353,7 +369,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";
-- 
1.7.12.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] recordmcount: arm64: replace the ignored mcount call into nop Li Bin <huawei.libin@huawei.com> - 2015-10-28 09:10 +0100
  Re: [PATCH] recordmcount: arm64: replace the ignored mcount call  into nop Steven Rostedt <rostedt@goodmis.org> - 2015-10-28 09:20 +0100
    Re: [PATCH] recordmcount: arm64: replace the ignored mcount call  into nop Will Deacon <will.deacon@arm.com> - 2015-10-28 13:00 +0100
      Re: [PATCH] recordmcount: arm64: replace the ignored mcount call into  nop AKASHI Takahiro <takahiro.akashi@linaro.org> - 2015-10-29 06:50 +0100
  Re: [PATCH] recordmcount: arm64: replace the ignored mcount call  into nop Will Deacon <will.deacon@arm.com> - 2015-10-29 16:10 +0100
    Re: [PATCH] recordmcount: arm64: replace the ignored mcount call into  nop libin <huawei.libin@huawei.com> - 2015-10-30 07:10 +0100

csiph-web