mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
![Matt Fleming](/assets/img/avatar_default.png)
Now that we've got a generic perf-events based oprofile backend we might as well make use of it seeing as SH doesn't do anything special with its oprofile backend. Also introduce a new CONFIG_HW_PERF_EVENTS symbol so that we can fallback to using the timer interrupt for oprofile if the CPU doesn't support perf events. Also, to avoid a section mismatch warning we need to annotate oprofile_arch_exit() with an __exit marker. Signed-off-by: Matt Fleming <matt@console-pimps.org> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Robert Richter <robert.richter@amd.com>
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
/*
|
|
* arch/sh/oprofile/init.c
|
|
*
|
|
* Copyright (C) 2003 - 2008 Paul Mundt
|
|
*
|
|
* Based on arch/mips/oprofile/common.c:
|
|
*
|
|
* Copyright (C) 2004, 2005 Ralf Baechle
|
|
* Copyright (C) 2005 MIPS Technologies, Inc.
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*/
|
|
#include <linux/kernel.h>
|
|
#include <linux/oprofile.h>
|
|
#include <linux/init.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/perf_event.h>
|
|
#include <asm/processor.h>
|
|
|
|
#ifdef CONFIG_HW_PERF_EVENTS
|
|
extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
|
|
|
|
char *op_name_from_perf_id(void)
|
|
{
|
|
const char *pmu;
|
|
char buf[20];
|
|
int size;
|
|
|
|
pmu = perf_pmu_name();
|
|
if (!pmu)
|
|
return NULL;
|
|
|
|
size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
|
|
if (size > -1 && size < sizeof(buf))
|
|
return buf;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
|
{
|
|
ops->backtrace = sh_backtrace;
|
|
|
|
return oprofile_perf_init(ops);
|
|
}
|
|
|
|
void __exit oprofile_arch_exit(void)
|
|
{
|
|
oprofile_perf_exit();
|
|
}
|
|
#else
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
|
{
|
|
pr_info("oprofile: hardware counters not available\n");
|
|
return -ENODEV;
|
|
}
|
|
void __exit oprofile_arch_exit(void) {}
|
|
#endif /* CONFIG_HW_PERF_EVENTS */
|