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

s390/diag: add tracepoint for diagnose calls

To be able to analyse problems in regard to hypervisor overhead
add a tracepoing for diagnose calls. It reports the number of
the diagnose issued, e.g.

sshd-1385 [002] .... 42.701431: diagnose: nr=0x9c
<idle>-0 [001] ..s. 43.587528: diagnose: nr=0x9c

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+98 -14
+2 -10
arch/s390/include/asm/diag.h
··· 33 33 NR_DIAG_STAT 34 34 }; 35 35 36 - struct diag_stat { 37 - unsigned int counter[NR_DIAG_STAT]; 38 - }; 39 - 40 - DECLARE_PER_CPU(struct diag_stat, diag_stat); 41 - 42 - static inline void diag_stat_inc(enum diag_stat_enum nr) 43 - { 44 - this_cpu_inc(diag_stat.counter[nr]); 45 - } 36 + void diag_stat_inc(enum diag_stat_enum nr); 37 + void diag_stat_inc_norecursion(enum diag_stat_enum nr); 46 38 47 39 /* 48 40 * Diagnose 10: Release page range
+43
arch/s390/include/asm/trace/diag.h
··· 1 + /* 2 + * Tracepoint header for s390 diagnose calls 3 + * 4 + * Copyright IBM Corp. 2015 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #undef TRACE_SYSTEM 9 + #define TRACE_SYSTEM s390 10 + 11 + #if !defined(_TRACE_S390_DIAG_H) || defined(TRACE_HEADER_MULTI_READ) 12 + #define _TRACE_S390_DIAG_H 13 + 14 + #include <linux/tracepoint.h> 15 + 16 + #undef TRACE_INCLUDE_PATH 17 + #undef TRACE_INCLUDE_FILE 18 + 19 + #define TRACE_INCLUDE_PATH asm/trace 20 + #define TRACE_INCLUDE_FILE diag 21 + 22 + TRACE_EVENT(diagnose, 23 + TP_PROTO(unsigned short nr), 24 + TP_ARGS(nr), 25 + TP_STRUCT__entry( 26 + __field(unsigned short, nr) 27 + ), 28 + TP_fast_assign( 29 + __entry->nr = nr; 30 + ), 31 + TP_printk("nr=0x%x", __entry->nr) 32 + ); 33 + 34 + #ifdef CONFIG_TRACEPOINTS 35 + void trace_diagnose_norecursion(int diag_nr); 36 + #else 37 + static inline void trace_diagnose_norecursion(int diag_nr) { } 38 + #endif 39 + 40 + #endif /* _TRACE_S390_DIAG_H */ 41 + 42 + /* This part must be outside protection */ 43 + #include <trace/define_trace.h>
+2
arch/s390/kernel/Makefile
··· 66 66 obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o perf_cpum_sf.o 67 67 obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o 68 68 69 + obj-$(CONFIG_TRACEPOINTS) += trace.o 70 + 69 71 # vdso 70 72 obj-y += vdso64/ 71 73 obj-$(CONFIG_COMPAT) += vdso32/
+20 -2
arch/s390/kernel/diag.c
··· 10 10 #include <linux/seq_file.h> 11 11 #include <linux/debugfs.h> 12 12 #include <asm/diag.h> 13 + #include <asm/trace/diag.h> 13 14 14 - DEFINE_PER_CPU(struct diag_stat, diag_stat); 15 - EXPORT_PER_CPU_SYMBOL(diag_stat); 15 + struct diag_stat { 16 + unsigned int counter[NR_DIAG_STAT]; 17 + }; 18 + 19 + static DEFINE_PER_CPU(struct diag_stat, diag_stat); 16 20 17 21 struct diag_desc { 18 22 int code; ··· 117 113 } 118 114 119 115 device_initcall(show_diag_stat_init); 116 + 117 + void diag_stat_inc(enum diag_stat_enum nr) 118 + { 119 + this_cpu_inc(diag_stat.counter[nr]); 120 + trace_diagnose(diag_map[nr].code); 121 + } 122 + EXPORT_SYMBOL(diag_stat_inc); 123 + 124 + void diag_stat_inc_norecursion(enum diag_stat_enum nr) 125 + { 126 + this_cpu_inc(diag_stat.counter[nr]); 127 + trace_diagnose_norecursion(diag_map[nr].code); 128 + } 129 + EXPORT_SYMBOL(diag_stat_inc_norecursion); 120 130 121 131 /* 122 132 * Diagnose 14: Input spool file manipulation
+2 -2
arch/s390/kernel/smp.c
··· 377 377 void smp_yield_cpu(int cpu) 378 378 { 379 379 if (MACHINE_HAS_DIAG9C) { 380 - diag_stat_inc(DIAG_STAT_X09C); 380 + diag_stat_inc_norecursion(DIAG_STAT_X09C); 381 381 asm volatile("diag %0,0,0x9c" 382 382 : : "d" (pcpu_devices[cpu].address)); 383 383 } else if (MACHINE_HAS_DIAG44) { 384 - diag_stat_inc(DIAG_STAT_X044); 384 + diag_stat_inc_norecursion(DIAG_STAT_X044); 385 385 asm volatile("diag 0,0,0x44"); 386 386 } 387 387 }
+29
arch/s390/kernel/trace.c
··· 1 + /* 2 + * Tracepoint definitions for s390 3 + * 4 + * Copyright IBM Corp. 2015 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #include <linux/percpu.h> 9 + #define CREATE_TRACE_POINTS 10 + #include <asm/trace/diag.h> 11 + 12 + EXPORT_TRACEPOINT_SYMBOL(diagnose); 13 + 14 + static DEFINE_PER_CPU(unsigned int, diagnose_trace_depth); 15 + 16 + void trace_diagnose_norecursion(int diag_nr) 17 + { 18 + unsigned long flags; 19 + unsigned int *depth; 20 + 21 + local_irq_save(flags); 22 + depth = this_cpu_ptr(&diagnose_trace_depth); 23 + if (*depth == 0) { 24 + (*depth)++; 25 + trace_diagnose(diag_nr); 26 + (*depth)--; 27 + } 28 + local_irq_restore(flags); 29 + }