aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/oprofile
diff options
context:
space:
mode:
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>2013-12-12 10:52:48 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-12-16 08:37:52 -0500
commite28bb79d9935293a8eea5f3c771fde89db645ba7 (patch)
tree0d552a218e87c70ca55b5b103b5ef2a71477d400 /arch/s390/oprofile
parent55baa2f831ae4a41da9617ab9e7cef5ebc991ec9 (diff)
s390/perf,oprofile: Share sampling facility
Introduce reserve/release functions to share the sampling facility between perf and oprofile. Also improve error handling for the sampling facility support in perf. Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/oprofile')
-rw-r--r--arch/s390/oprofile/hwsampler.c7
-rw-r--r--arch/s390/oprofile/init.c23
2 files changed, 27 insertions, 3 deletions
diff --git a/arch/s390/oprofile/hwsampler.c b/arch/s390/oprofile/hwsampler.c
index bbca76ad6e1b..eb095874540d 100644
--- a/arch/s390/oprofile/hwsampler.c
+++ b/arch/s390/oprofile/hwsampler.c
@@ -41,6 +41,7 @@ static DEFINE_MUTEX(hws_sem_oom);
41 41
42static unsigned char hws_flush_all; 42static unsigned char hws_flush_all;
43static unsigned int hws_oom; 43static unsigned int hws_oom;
44static unsigned int hws_alert;
44static struct workqueue_struct *hws_wq; 45static struct workqueue_struct *hws_wq;
45 46
46static unsigned int hws_state; 47static unsigned int hws_state;
@@ -182,6 +183,9 @@ static void hws_ext_handler(struct ext_code ext_code,
182 if (!(param32 & CPU_MF_INT_SF_MASK)) 183 if (!(param32 & CPU_MF_INT_SF_MASK))
183 return; 184 return;
184 185
186 if (!hws_alert)
187 return;
188
185 inc_irq_stat(IRQEXT_CMS); 189 inc_irq_stat(IRQEXT_CMS);
186 atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32); 190 atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32);
187 191
@@ -941,6 +945,7 @@ int hwsampler_deallocate(void)
941 goto deallocate_exit; 945 goto deallocate_exit;
942 946
943 irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT); 947 irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT);
948 hws_alert = 0;
944 deallocate_sdbt(); 949 deallocate_sdbt();
945 950
946 hws_state = HWS_DEALLOCATED; 951 hws_state = HWS_DEALLOCATED;
@@ -1055,6 +1060,7 @@ int hwsampler_shutdown(void)
1055 1060
1056 if (hws_state == HWS_STOPPED) { 1061 if (hws_state == HWS_STOPPED) {
1057 irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT); 1062 irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT);
1063 hws_alert = 0;
1058 deallocate_sdbt(); 1064 deallocate_sdbt();
1059 } 1065 }
1060 if (hws_wq) { 1066 if (hws_wq) {
@@ -1129,6 +1135,7 @@ start_all_exit:
1129 hws_oom = 1; 1135 hws_oom = 1;
1130 hws_flush_all = 0; 1136 hws_flush_all = 0;
1131 /* now let them in, 1407 CPUMF external interrupts */ 1137 /* now let them in, 1407 CPUMF external interrupts */
1138 hws_alert = 1;
1132 irq_subclass_register(IRQ_SUBCLASS_MEASUREMENT_ALERT); 1139 irq_subclass_register(IRQ_SUBCLASS_MEASUREMENT_ALERT);
1133 1140
1134 return 0; 1141 return 0;
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index 04e1b6a85362..9ffe645d5989 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/oprofile.h> 12#include <linux/oprofile.h>
13#include <linux/perf_event.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/errno.h> 15#include <linux/errno.h>
15#include <linux/fs.h> 16#include <linux/fs.h>
@@ -67,6 +68,21 @@ module_param_call(cpu_type, set_cpu_type, NULL, NULL, 0);
67MODULE_PARM_DESC(cpu_type, "Force legacy basic mode sampling" 68MODULE_PARM_DESC(cpu_type, "Force legacy basic mode sampling"
68 "(report cpu_type \"timer\""); 69 "(report cpu_type \"timer\"");
69 70
71static int __oprofile_hwsampler_start(void)
72{
73 int retval;
74
75 retval = hwsampler_allocate(oprofile_sdbt_blocks, oprofile_sdb_blocks);
76 if (retval)
77 return retval;
78
79 retval = hwsampler_start_all(oprofile_hw_interval);
80 if (retval)
81 hwsampler_deallocate();
82
83 return retval;
84}
85
70static int oprofile_hwsampler_start(void) 86static int oprofile_hwsampler_start(void)
71{ 87{
72 int retval; 88 int retval;
@@ -76,13 +92,13 @@ static int oprofile_hwsampler_start(void)
76 if (!hwsampler_running) 92 if (!hwsampler_running)
77 return timer_ops.start(); 93 return timer_ops.start();
78 94
79 retval = hwsampler_allocate(oprofile_sdbt_blocks, oprofile_sdb_blocks); 95 retval = perf_reserve_sampling();
80 if (retval) 96 if (retval)
81 return retval; 97 return retval;
82 98
83 retval = hwsampler_start_all(oprofile_hw_interval); 99 retval = __oprofile_hwsampler_start();
84 if (retval) 100 if (retval)
85 hwsampler_deallocate(); 101 perf_release_sampling();
86 102
87 return retval; 103 return retval;
88} 104}
@@ -96,6 +112,7 @@ static void oprofile_hwsampler_stop(void)
96 112
97 hwsampler_stop_all(); 113 hwsampler_stop_all();
98 hwsampler_deallocate(); 114 hwsampler_deallocate();
115 perf_release_sampling();
99 return; 116 return;
100} 117}
101 118