Skip to content

Commit

Permalink
xtensa/perf: Convert the hotplug notifier to state machine callbacks
Browse files Browse the repository at this point in the history
Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-xtensa@linux-xtensa.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153334.852575891@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Sebastian Andrzej Siewior authored and Ingo Molnar committed Jul 14, 2016
1 parent fdc15a3 commit 25a77b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
26 changes: 9 additions & 17 deletions arch/xtensa/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static struct pmu xtensa_pmu = {
.read = xtensa_pmu_read,
};

static void xtensa_pmu_setup(void)
static int xtensa_pmu_setup(int cpu)
{
unsigned i;

Expand All @@ -413,29 +413,21 @@ static void xtensa_pmu_setup(void)
set_er(0, XTENSA_PMU_PMCTRL(i));
set_er(get_er(XTENSA_PMU_PMSTAT(i)), XTENSA_PMU_PMSTAT(i));
}
}

static int xtensa_pmu_notifier(struct notifier_block *self,
unsigned long action, void *data)
{
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_STARTING:
xtensa_pmu_setup();
break;

default:
break;
}

return NOTIFY_OK;
return 0;
}

static int __init xtensa_pmu_init(void)
{
int ret;
int irq = irq_create_mapping(NULL, XCHAL_PROFILING_INTERRUPT);

perf_cpu_notifier(xtensa_pmu_notifier);
ret = cpuhp_setup_state(CPUHP_AP_PERF_XTENSA_STARTING,
"AP_PERF_XTENSA_STARTING", xtensa_pmu_setup,
NULL);
if (ret) {
pr_err("xtensa_pmu: failed to register CPU-hotplug.\n");
return ret;
}
#if XTENSA_FAKE_NMI
enable_irq(irq);
#else
Expand Down
1 change: 1 addition & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum cpuhp_state {
CPUHP_AP_PERF_X86_AMD_IBS_STARTING,
CPUHP_AP_PERF_X86_CQM_STARTING,
CPUHP_AP_PERF_X86_CSTATE_STARTING,
CPUHP_AP_PERF_XTENSA_STARTING,
CPUHP_AP_NOTIFY_STARTING,
CPUHP_AP_ONLINE,
CPUHP_TEARDOWN_CPU,
Expand Down

0 comments on commit 25a77b5

Please sign in to comment.