Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/cpum_cf: introduce kernel_cpumcf_alert() to obtain measurement alerts

During a __kernel_cpumcf_begin()/end() session, save measurement alerts
for the counter facility in the per-CPU cpu_cf_events variable.
Users can obtain and, optionally, clear the alerts by calling
kernel_cpumcf_alert() to specifically handle alerts.

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Hendrik Brueckner and committed by
Martin Schwidefsky
26b8317f f944bcdf

+20
+2
arch/s390/include/asm/cpu_mcf.h
··· 52 52 struct cpu_cf_events { 53 53 struct cpumf_ctr_info info; 54 54 atomic_t ctr_set[CPUMF_CTR_SET_MAX]; 55 + atomic64_t alert; 55 56 u64 state, tx_state; 56 57 unsigned int flags; 57 58 unsigned int txn_flags; ··· 60 59 DECLARE_PER_CPU(struct cpu_cf_events, cpu_cf_events); 61 60 62 61 int __kernel_cpumcf_begin(void); 62 + unsigned long kernel_cpumcf_alert(int clear); 63 63 void __kernel_cpumcf_end(void); 64 64 65 65 #endif /* _ASM_S390_CPU_MCF_H */
+18
arch/s390/kernel/perf_cpum_cf.c
··· 27 27 [CPUMF_CTR_SET_EXT] = ATOMIC_INIT(0), 28 28 [CPUMF_CTR_SET_MT_DIAG] = ATOMIC_INIT(0), 29 29 }, 30 + .alert = ATOMIC64_INIT(0), 30 31 .state = 0, 31 32 .flags = 0, 32 33 .txn_flags = 0, ··· 206 205 if (alert & CPU_MF_INT_CF_MTDA) 207 206 pr_warn("CPU[%i] MT counter data was lost\n", 208 207 smp_processor_id()); 208 + 209 + /* store alert for special handling by in-kernel users */ 210 + atomic64_or(alert, &cpuhw->alert); 209 211 } 210 212 211 213 #define PMC_INIT 0 ··· 258 254 return 0; 259 255 } 260 256 EXPORT_SYMBOL(__kernel_cpumcf_begin); 257 + 258 + /* Obtain the CPU-measurement alerts for the counter facility */ 259 + unsigned long kernel_cpumcf_alert(int clear) 260 + { 261 + struct cpu_cf_events *cpuhw = this_cpu_ptr(&cpu_cf_events); 262 + unsigned long alert; 263 + 264 + alert = atomic64_read(&cpuhw->alert); 265 + if (clear) 266 + atomic64_set(&cpuhw->alert, 0); 267 + 268 + return alert; 269 + } 270 + EXPORT_SYMBOL(kernel_cpumcf_alert); 261 271 262 272 /* Release the CPU-measurement counter facility */ 263 273 void __kernel_cpumcf_end(void)