aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/include/asm/timex.h11
-rw-r--r--litmus/color.c11
-rw-r--r--litmus/litmus.c31
3 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm/include/asm/timex.h b/arch/arm/include/asm/timex.h
index 8a102a383a36..12a53699cd20 100644
--- a/arch/arm/include/asm/timex.h
+++ b/arch/arm/include/asm/timex.h
@@ -16,6 +16,17 @@
16 16
17typedef unsigned long cycles_t; 17typedef unsigned long cycles_t;
18 18
19#if defined(CONFIG_CPU_V7) && !defined(CONFIG_HW_PERF_EVENTS)
20static inline cycles_t v7_get_cycles (void)
21{
22 u32 value;
23 /* read CCNT register */
24 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(value));
25 return value;
26}
27#define get_cycles v7_get_cycles
28#endif
29
19#ifndef get_cycles 30#ifndef get_cycles
20static inline cycles_t get_cycles (void) 31static inline cycles_t get_cycles (void)
21{ 32{
diff --git a/litmus/color.c b/litmus/color.c
index 976366e7e39c..278f541e07c1 100644
--- a/litmus/color.c
+++ b/litmus/color.c
@@ -340,6 +340,12 @@ out:
340 return err; 340 return err;
341} 341}
342 342
343static void __init print_cycle_count(void *_unused)
344{
345 cycles_t cycles = get_cycles();
346 printk("CPU %2d: %10lu cycles\n", smp_processor_id(), cycles);
347}
348
343static int __init init_color(void) 349static int __init init_color(void)
344{ 350{
345 int err = 0; 351 int err = 0;
@@ -354,6 +360,11 @@ static int __init init_color(void)
354 360
355 BUG_ON(LOCKDEP_MAX_NR_COLORS < color_cache_info.nr_colors); 361 BUG_ON(LOCKDEP_MAX_NR_COLORS < color_cache_info.nr_colors);
356 err = init_color_groups(); 362 err = init_color_groups();
363
364 printk("Cycle counter test:\n");
365 print_cycle_count(NULL);
366 smp_call_function(print_cycle_count, NULL, 0);
367
357 return err; 368 return err;
358} 369}
359 370
diff --git a/litmus/litmus.c b/litmus/litmus.c
index 1bbad8db1a55..531a2245133d 100644
--- a/litmus/litmus.c
+++ b/litmus/litmus.c
@@ -656,6 +656,35 @@ static struct sysrq_key_op sysrq_kill_rt_tasks_op = {
656 656
657extern struct sched_plugin linux_sched_plugin; 657extern struct sched_plugin linux_sched_plugin;
658 658
659#if defined(CONFIG_CPU_V7) && !defined(CONFIG_HW_PERF_EVENTS)
660static void __init litmus_enable_perfcounters_v7(void *_ignore)
661{
662 u32 enable_val;
663
664 /* write 1 to enable user-mode access to the performance counter */
665 asm volatile("mcr p15, 0, %0, c9, c14, 0" : : "r" (1));
666
667 /* disable counter overflow interrupts (just in case) */
668 asm volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (0x8000000f));
669
670 enable_val = 1; /* bit 1 enables the counters */
671 enable_val |= 2; /* resets cycle counter to zero */
672 /* performance monitor control register: enable all counters */
673 asm volatile("mcr p15, 0, %0, c9, c12, 0" : : "r"(enable_val));
674
675 /* enables counters (currently just cycle counter) */
676 asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r"(0x80000000));
677}
678
679static void __init litmus_enable_perfcounters(void)
680{
681 litmus_enable_perfcounters_v7(NULL);
682 smp_call_function(litmus_enable_perfcounters_v7, NULL, 0);
683}
684#else
685#define litmus_enable_perfcounters() do { } while (0)
686#endif
687
659static int __init _init_litmus(void) 688static int __init _init_litmus(void)
660{ 689{
661 /* Common initializers, 690 /* Common initializers,
@@ -691,6 +720,8 @@ static int __init _init_litmus(void)
691 init_topology(); 720 init_topology();
692#endif 721#endif
693 722
723 litmus_enable_perfcounters();
724
694 return 0; 725 return 0;
695} 726}
696 727