Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64 add support kernel profiling on aarch64



details:   https://anonhg.NetBSD.org/src/rev/9f6c5d51c796
branches:  trunk
changeset: 1018628:9f6c5d51c796
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Feb 10 08:25:01 2021 +0000

description:
add support kernel profiling on aarch64

- add MCOUNT_ENTER, MCOUNT_EXIT macro
- __mcount() function should be aligned
- add "-fno-optimize-sibling-calls" option when PROF. for accurate profiling, it is better to suppress the tail call.

diffstat:

 sys/arch/aarch64/conf/Makefile.aarch64 |   7 ++++++-
 sys/arch/aarch64/conf/kern.ldscript    |   1 +
 sys/arch/aarch64/include/profile.h     |  11 +++++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diffs (64 lines):

diff -r ec47d6796555 -r 9f6c5d51c796 sys/arch/aarch64/conf/Makefile.aarch64
--- a/sys/arch/aarch64/conf/Makefile.aarch64    Wed Feb 10 07:19:54 2021 +0000
+++ b/sys/arch/aarch64/conf/Makefile.aarch64    Wed Feb 10 08:25:01 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.aarch64,v 1.21 2020/05/11 03:00:57 ryo Exp $
+#      $NetBSD: Makefile.aarch64,v 1.22 2021/02/10 08:25:01 ryo Exp $
 
 # Makefile for NetBSD
 #
@@ -39,6 +39,11 @@
 CFLAGS+=       -mno-omit-leaf-frame-pointer
 #CFLAGS+=      -mno-unaligned-access
 
+.if defined(PROF) && ${HAVE_GCC:U0} > 0
+# For accurate profiling, it is better to suppress the tail call.
+CFLAGS+=       -fno-optimize-sibling-calls
+.endif
+
 .if ${HAVE_LLVM:Uno} == "yes"
 .if ${ARMV83_PAC:U0} > 0 && ${ARMV85_BTI:U0} > 0
 CFLAGS+=       -mbranch-protection=pac-ret+bti
diff -r ec47d6796555 -r 9f6c5d51c796 sys/arch/aarch64/conf/kern.ldscript
--- a/sys/arch/aarch64/conf/kern.ldscript       Wed Feb 10 07:19:54 2021 +0000
+++ b/sys/arch/aarch64/conf/kern.ldscript       Wed Feb 10 08:25:01 2021 +0000
@@ -11,6 +11,7 @@
        .text :
        {
                PROVIDE(__kernel_text = .);
+               PROVIDE(kernel_text = .);
                *(.text)
                *(.text.*)
                *(.stub)
diff -r ec47d6796555 -r 9f6c5d51c796 sys/arch/aarch64/include/profile.h
--- a/sys/arch/aarch64/include/profile.h        Wed Feb 10 07:19:54 2021 +0000
+++ b/sys/arch/aarch64/include/profile.h        Wed Feb 10 08:25:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: profile.h,v 1.2 2020/04/23 23:22:41 jakllsch Exp $ */
+/* $NetBSD: profile.h,v 1.3 2021/02/10 08:25:01 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 
 #define        MCOUNT                                                          \
        __asm(".text");                                                 \
-       __asm(".align   0");                                            \
+       __asm(".align   6");                                            \
        __asm(".type    " MCOUNT_ASM_NAME ",@function");                \
        __asm(".global  " MCOUNT_ASM_NAME);                             \
        __asm(MCOUNT_ASM_NAME ":");                                     \
@@ -82,6 +82,13 @@
        __asm("ret");                                                   \
        __asm(".size    " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
 
+#ifdef _KERNEL
+#define MCOUNT_ENTER   \
+       __asm __volatile ("mrs %x0, daif; msr daifset, #3": "=r"(s):: "memory")
+#define MCOUNT_EXIT    \
+       __asm __volatile ("msr daif, %x0":: "r"(s): "memory")
+#endif /* _KERNEL */
+
 #elif defined(__arm__)
 
 #include <arm/profile.h>



Home | Main Index | Thread Index | Old Index