Commit b03d541a authored by Jan Glauber's avatar Jan Glauber Committed by Martin Schwidefsky

[S390] oprofile: Allow multiple users of the measurement alert interrupt

Prepare the measurement facility which is currently only used by oprofile
for multiple users.  To achieve that the measurement alert interrupt control
bit needs to be protected.  The measurement alert definitions are moved
to a header file and an interrupt mask is added so that users can discard
interrupts if they are for a different measurement subsystem.
Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarJan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 61d84979
#ifndef _ASM_S390_CPU_MF_H
#define _ASM_S390_CPU_MF_H
#define CPU_MF_INT_SF_MASK 0xffc00000
#define CPU_MF_INT_SF_IAE (1 << 31) /* invalid entry address */
#define CPU_MF_INT_SF_ISE (1 << 30) /* incorrect SDBT entry */
#define CPU_MF_INT_SF_PRA (1 << 29) /* program request alert */
#define CPU_MF_INT_SF_SACA (1 << 23) /* sampler auth. change alert */
#define CPU_MF_INT_SF_LSDA (1 << 22) /* loss of sample data alert */
#endif
...@@ -45,5 +45,7 @@ int register_external_interrupt(u16 code, ext_int_handler_t handler); ...@@ -45,5 +45,7 @@ int register_external_interrupt(u16 code, ext_int_handler_t handler);
int unregister_external_interrupt(u16 code, ext_int_handler_t handler); int unregister_external_interrupt(u16 code, ext_int_handler_t handler);
void service_subclass_irq_register(void); void service_subclass_irq_register(void);
void service_subclass_irq_unregister(void); void service_subclass_irq_unregister(void);
void measurement_alert_subclass_register(void);
void measurement_alert_subclass_unregister(void);
#endif /* _ASM_IRQ_H */ #endif /* _ASM_IRQ_H */
...@@ -255,3 +255,26 @@ void service_subclass_irq_unregister(void) ...@@ -255,3 +255,26 @@ void service_subclass_irq_unregister(void)
spin_unlock(&sc_irq_lock); spin_unlock(&sc_irq_lock);
} }
EXPORT_SYMBOL(service_subclass_irq_unregister); EXPORT_SYMBOL(service_subclass_irq_unregister);
static DEFINE_SPINLOCK(ma_subclass_lock);
static int ma_subclass_refcount;
void measurement_alert_subclass_register(void)
{
spin_lock(&ma_subclass_lock);
if (!ma_subclass_refcount)
ctl_set_bit(0, 5);
ma_subclass_refcount++;
spin_unlock(&ma_subclass_lock);
}
EXPORT_SYMBOL(measurement_alert_subclass_register);
void measurement_alert_subclass_unregister(void)
{
spin_lock(&ma_subclass_lock);
ma_subclass_refcount--;
if (!ma_subclass_refcount)
ctl_clear_bit(0, 5);
spin_unlock(&ma_subclass_lock);
}
EXPORT_SYMBOL(measurement_alert_subclass_unregister);
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <linux/oom.h> #include <linux/oom.h>
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <asm/cpu_mf.h>
#include <asm/lowcore.h>
#include <asm/irq.h> #include <asm/irq.h>
#include "hwsampler.h" #include "hwsampler.h"
...@@ -30,12 +29,6 @@ ...@@ -30,12 +29,6 @@
#define ALERT_REQ_MASK 0x4000000000000000ul #define ALERT_REQ_MASK 0x4000000000000000ul
#define BUFFER_FULL_MASK 0x8000000000000000ul #define BUFFER_FULL_MASK 0x8000000000000000ul
#define EI_IEA (1 << 31) /* invalid entry address */
#define EI_ISE (1 << 30) /* incorrect SDBT entry */
#define EI_PRA (1 << 29) /* program request alert */
#define EI_SACA (1 << 23) /* sampler authorization change alert */
#define EI_LSDA (1 << 22) /* loss of sample data alert */
DECLARE_PER_CPU(struct hws_cpu_buffer, sampler_cpu_buffer); DECLARE_PER_CPU(struct hws_cpu_buffer, sampler_cpu_buffer);
struct hws_execute_parms { struct hws_execute_parms {
...@@ -232,9 +225,20 @@ static inline unsigned long *trailer_entry_ptr(unsigned long v) ...@@ -232,9 +225,20 @@ static inline unsigned long *trailer_entry_ptr(unsigned long v)
return (unsigned long *) ret; return (unsigned long *) ret;
} }
/* prototypes for external interrupt handler and worker */
static void hws_ext_handler(struct ext_code ext_code, static void hws_ext_handler(struct ext_code ext_code,
unsigned int param32, unsigned long param64); unsigned int param32, unsigned long param64)
{
struct hws_cpu_buffer *cb = &__get_cpu_var(sampler_cpu_buffer);
if (!(param32 & CPU_MF_INT_SF_MASK))
return;
kstat_cpu(smp_processor_id()).irqs[EXTINT_CPM]++;
atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32);
if (hws_wq)
queue_work(hws_wq, &cb->worker);
}
static void worker(struct work_struct *work); static void worker(struct work_struct *work);
...@@ -673,18 +677,6 @@ int hwsampler_activate(unsigned int cpu) ...@@ -673,18 +677,6 @@ int hwsampler_activate(unsigned int cpu)
return rc; return rc;
} }
static void hws_ext_handler(struct ext_code ext_code,
unsigned int param32, unsigned long param64)
{
struct hws_cpu_buffer *cb;
kstat_cpu(smp_processor_id()).irqs[EXTINT_CPM]++;
cb = &__get_cpu_var(sampler_cpu_buffer);
atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32);
if (hws_wq)
queue_work(hws_wq, &cb->worker);
}
static int check_qsi_on_setup(void) static int check_qsi_on_setup(void)
{ {
int rc; int rc;
...@@ -760,23 +752,23 @@ static int worker_check_error(unsigned int cpu, int ext_params) ...@@ -760,23 +752,23 @@ static int worker_check_error(unsigned int cpu, int ext_params)
if (!sdbt || !*sdbt) if (!sdbt || !*sdbt)
return -EINVAL; return -EINVAL;
if (ext_params & EI_PRA) if (ext_params & CPU_MF_INT_SF_PRA)
cb->req_alert++; cb->req_alert++;
if (ext_params & EI_LSDA) if (ext_params & CPU_MF_INT_SF_LSDA)
cb->loss_of_sample_data++; cb->loss_of_sample_data++;
if (ext_params & EI_IEA) { if (ext_params & CPU_MF_INT_SF_IAE) {
cb->invalid_entry_address++; cb->invalid_entry_address++;
rc = -EINVAL; rc = -EINVAL;
} }
if (ext_params & EI_ISE) { if (ext_params & CPU_MF_INT_SF_ISE) {
cb->incorrect_sdbt_entry++; cb->incorrect_sdbt_entry++;
rc = -EINVAL; rc = -EINVAL;
} }
if (ext_params & EI_SACA) { if (ext_params & CPU_MF_INT_SF_SACA) {
cb->sample_auth_change_alert++; cb->sample_auth_change_alert++;
rc = -EINVAL; rc = -EINVAL;
} }
...@@ -1009,7 +1001,7 @@ int hwsampler_deallocate(void) ...@@ -1009,7 +1001,7 @@ int hwsampler_deallocate(void)
if (hws_state != HWS_STOPPED) if (hws_state != HWS_STOPPED)
goto deallocate_exit; goto deallocate_exit;
ctl_clear_bit(0, 5); /* set bit 58 CR0 off */ measurement_alert_subclass_unregister();
deallocate_sdbt(); deallocate_sdbt();
hws_state = HWS_DEALLOCATED; hws_state = HWS_DEALLOCATED;
...@@ -1123,7 +1115,7 @@ int hwsampler_shutdown(void) ...@@ -1123,7 +1115,7 @@ int hwsampler_shutdown(void)
mutex_lock(&hws_sem); mutex_lock(&hws_sem);
if (hws_state == HWS_STOPPED) { if (hws_state == HWS_STOPPED) {
ctl_clear_bit(0, 5); /* set bit 58 CR0 off */ measurement_alert_subclass_unregister();
deallocate_sdbt(); deallocate_sdbt();
} }
if (hws_wq) { if (hws_wq) {
...@@ -1198,7 +1190,7 @@ int hwsampler_start_all(unsigned long rate) ...@@ -1198,7 +1190,7 @@ int hwsampler_start_all(unsigned long rate)
hws_oom = 1; hws_oom = 1;
hws_flush_all = 0; hws_flush_all = 0;
/* now let them in, 1407 CPUMF external interrupts */ /* now let them in, 1407 CPUMF external interrupts */
ctl_set_bit(0, 5); /* set CR0 bit 58 */ measurement_alert_subclass_register();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment