common.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * arch/sh/oprofile/init.c
  3. *
  4. * Copyright (C) 2003 - 2010 Paul Mundt
  5. *
  6. * Based on arch/mips/oprofile/common.c:
  7. *
  8. * Copyright (C) 2004, 2005 Ralf Baechle
  9. * Copyright (C) 2005 MIPS Technologies, Inc.
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/oprofile.h>
  17. #include <linux/init.h>
  18. #include <linux/errno.h>
  19. #include <linux/smp.h>
  20. #include <linux/perf_event.h>
  21. #include <linux/slab.h>
  22. #include <asm/processor.h>
  23. extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
  24. #ifdef CONFIG_HW_PERF_EVENTS
  25. /*
  26. * This will need to be reworked when multiple PMUs are supported.
  27. */
  28. static char *sh_pmu_op_name;
  29. char *op_name_from_perf_id(void)
  30. {
  31. return sh_pmu_op_name;
  32. }
  33. int __init oprofile_arch_init(struct oprofile_operations *ops)
  34. {
  35. ops->backtrace = sh_backtrace;
  36. if (perf_num_counters() == 0)
  37. return -ENODEV;
  38. sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
  39. UTS_MACHINE, perf_pmu_name());
  40. if (unlikely(!sh_pmu_op_name))
  41. return -ENOMEM;
  42. return oprofile_perf_init(ops);
  43. }
  44. void oprofile_arch_exit(void)
  45. {
  46. oprofile_perf_exit();
  47. kfree(sh_pmu_op_name);
  48. }
  49. #else
  50. int __init oprofile_arch_init(struct oprofile_operations *ops)
  51. {
  52. ops->backtrace = sh_backtrace;
  53. return -ENODEV;
  54. }
  55. void oprofile_arch_exit(void) {}
  56. #endif /* CONFIG_HW_PERF_EVENTS */