aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Martin <dave.martin@linaro.org>2013-02-06 10:45:23 -0500
committerNicolas Pitre <nicolas.pitre@linaro.org>2013-09-23 18:47:30 -0400
commitb09bbe5b1267b6af22a9584d614f5eec5d74f405 (patch)
tree37ed44d02645710a5a70d0853f8c9dc3459ed667
parent1bfbddb6f3a0dbb8c3996d1c4d4911d695737c15 (diff)
ARM: bL_switcher/trace: Add trace trigger for trace bootstrapping
When tracing switching, an external tracer needs a way to bootstrap its knowledge of the logical<->physical CPU mapping. This patch adds a sysfs attribute trace_trigger. A write to this attribute will generate a power:cpu_migrate_current event for each online CPU, indicating the current physical CPU for each logical CPU. Activating or deactivating the switcher also generates these events, so that the tracer knows about the resulting remapping of affected CPUs. Signed-off-by: Dave Martin <dave.martin@linaro.org>
-rw-r--r--arch/arm/common/bL_switcher.c36
-rw-r--r--include/trace/events/power_cpu_migrate.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 7002de360d23..f0dc025077d5 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -27,6 +27,7 @@
27#include <linux/notifier.h> 27#include <linux/notifier.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/smp.h>
30#include <linux/spinlock.h> 31#include <linux/spinlock.h>
31#include <linux/string.h> 32#include <linux/string.h>
32#include <linux/sysfs.h> 33#include <linux/sysfs.h>
@@ -531,6 +532,25 @@ static int bL_switcher_halve_cpus(void)
531 return 0; 532 return 0;
532} 533}
533 534
535static void bL_switcher_trace_trigger_cpu(void *__always_unused info)
536{
537 trace_cpu_migrate_current(get_ns(), read_mpidr());
538}
539
540static int bL_switcher_trace_trigger(void)
541{
542 int ret;
543
544 preempt_disable();
545
546 bL_switcher_trace_trigger_cpu(NULL);
547 ret = smp_call_function(bL_switcher_trace_trigger_cpu, NULL, true);
548
549 preempt_enable();
550
551 return ret;
552}
553
534static int bL_switcher_enable(void) 554static int bL_switcher_enable(void)
535{ 555{
536 int cpu, ret; 556 int cpu, ret;
@@ -553,6 +573,8 @@ static int bL_switcher_enable(void)
553 if (ret) 573 if (ret)
554 goto error; 574 goto error;
555 575
576 bL_switcher_trace_trigger();
577
556 for_each_online_cpu(cpu) { 578 for_each_online_cpu(cpu) {
557 struct bL_thread *t = &bL_threads[cpu]; 579 struct bL_thread *t = &bL_threads[cpu];
558 spin_lock_init(&t->lock); 580 spin_lock_init(&t->lock);
@@ -637,6 +659,8 @@ static void bL_switcher_disable(void)
637 } 659 }
638 660
639 bL_switcher_restore_cpus(); 661 bL_switcher_restore_cpus();
662 bL_switcher_trace_trigger();
663
640 bL_activation_notify(BL_NOTIFY_POST_DISABLE); 664 bL_activation_notify(BL_NOTIFY_POST_DISABLE);
641 665
642out: 666out:
@@ -670,11 +694,23 @@ static ssize_t bL_switcher_active_store(struct kobject *kobj,
670 return (ret >= 0) ? count : ret; 694 return (ret >= 0) ? count : ret;
671} 695}
672 696
697static ssize_t bL_switcher_trace_trigger_store(struct kobject *kobj,
698 struct kobj_attribute *attr, const char *buf, size_t count)
699{
700 int ret = bL_switcher_trace_trigger();
701
702 return ret ? ret : count;
703}
704
673static struct kobj_attribute bL_switcher_active_attr = 705static struct kobj_attribute bL_switcher_active_attr =
674 __ATTR(active, 0644, bL_switcher_active_show, bL_switcher_active_store); 706 __ATTR(active, 0644, bL_switcher_active_show, bL_switcher_active_store);
675 707
708static struct kobj_attribute bL_switcher_trace_trigger_attr =
709 __ATTR(trace_trigger, 0200, NULL, bL_switcher_trace_trigger_store);
710
676static struct attribute *bL_switcher_attrs[] = { 711static struct attribute *bL_switcher_attrs[] = {
677 &bL_switcher_active_attr.attr, 712 &bL_switcher_active_attr.attr,
713 &bL_switcher_trace_trigger_attr.attr,
678 NULL, 714 NULL,
679}; 715};
680 716
diff --git a/include/trace/events/power_cpu_migrate.h b/include/trace/events/power_cpu_migrate.h
index 3694af0f5bc5..f76dd4de625e 100644
--- a/include/trace/events/power_cpu_migrate.h
+++ b/include/trace/events/power_cpu_migrate.h
@@ -42,6 +42,7 @@ DECLARE_EVENT_CLASS(cpu_migrate,
42 42
43__define_cpu_migrate_event(begin); 43__define_cpu_migrate_event(begin);
44__define_cpu_migrate_event(finish); 44__define_cpu_migrate_event(finish);
45__define_cpu_migrate_event(current);
45 46
46#undef __define_cpu_migrate 47#undef __define_cpu_migrate
47#undef __cpu_migrate_proto 48#undef __cpu_migrate_proto