~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/kernel/perf_event.c

Version: ~ [ linux-5.16-rc3 ] ~ [ linux-5.15.5 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.82 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.162 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.218 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.256 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.291 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.293 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Linux performance counter support for MIPS.
  3  *
  4  * Copyright (C) 2010 MIPS Technologies, Inc.
  5  * Author: Deng-Cheng Zhu
  6  *
  7  * This code is based on the implementation for ARM, which is in turn
  8  * based on the sparc64 perf event code and the x86 code. Performance
  9  * counter access is based on the MIPS Oprofile code. And the callchain
 10  * support references the code of MIPS stacktrace.c.
 11  *
 12  * This program is free software; you can redistribute it and/or modify
 13  * it under the terms of the GNU General Public License version 2 as
 14  * published by the Free Software Foundation.
 15  */
 16 
 17 #include <linux/perf_event.h>
 18 
 19 #include <asm/stacktrace.h>
 20 
 21 /* Callchain handling code. */
 22 
 23 /*
 24  * Leave userspace callchain empty for now. When we find a way to trace
 25  * the user stack callchains, we will add it here.
 26  */
 27 
 28 static void save_raw_perf_callchain(struct perf_callchain_entry *entry,
 29         unsigned long reg29)
 30 {
 31         unsigned long *sp = (unsigned long *)reg29;
 32         unsigned long addr;
 33 
 34         while (!kstack_end(sp)) {
 35                 addr = *sp++;
 36                 if (__kernel_text_address(addr)) {
 37                         perf_callchain_store(entry, addr);
 38                         if (entry->nr >= PERF_MAX_STACK_DEPTH)
 39                                 break;
 40                 }
 41         }
 42 }
 43 
 44 void perf_callchain_kernel(struct perf_callchain_entry *entry,
 45                       struct pt_regs *regs)
 46 {
 47         unsigned long sp = regs->regs[29];
 48 #ifdef CONFIG_KALLSYMS
 49         unsigned long ra = regs->regs[31];
 50         unsigned long pc = regs->cp0_epc;
 51 
 52         if (raw_show_trace || !__kernel_text_address(pc)) {
 53                 unsigned long stack_page =
 54                         (unsigned long)task_stack_page(current);
 55                 if (stack_page && sp >= stack_page &&
 56                     sp <= stack_page + THREAD_SIZE - 32)
 57                         save_raw_perf_callchain(entry, sp);
 58                 return;
 59         }
 60         do {
 61                 perf_callchain_store(entry, pc);
 62                 if (entry->nr >= PERF_MAX_STACK_DEPTH)
 63                         break;
 64                 pc = unwind_stack(current, &sp, pc, &ra);
 65         } while (pc);
 66 #else
 67         save_raw_perf_callchain(entry, sp);
 68 #endif
 69 }
 70 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp