Skip to content

Commit b5a6b71

Browse files
author
Martin Schwidefsky
committed
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 <[email protected]>
1 parent 1ec2772 commit b5a6b71

File tree

6 files changed

+98
-14
lines changed

6 files changed

+98
-14
lines changed

arch/s390/include/asm/diag.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,8 @@ enum diag_stat_enum {
3333
NR_DIAG_STAT
3434
};
3535

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);
4638

4739
/*
4840
* Diagnose 10: Release page range

arch/s390/include/asm/trace/diag.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Tracepoint header for s390 diagnose calls
3+
*
4+
* Copyright IBM Corp. 2015
5+
* Author(s): Martin Schwidefsky <[email protected]>
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>

arch/s390/kernel/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ obj-$(CONFIG_UPROBES) += uprobes.o
6666
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o perf_cpum_sf.o
6767
obj-$(CONFIG_PERF_EVENTS) += perf_cpum_cf_events.o
6868

69+
obj-$(CONFIG_TRACEPOINTS) += trace.o
70+
6971
# vdso
7072
obj-y += vdso64/
7173
obj-$(CONFIG_COMPAT) += vdso32/

arch/s390/kernel/diag.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
#include <linux/seq_file.h>
1111
#include <linux/debugfs.h>
1212
#include <asm/diag.h>
13+
#include <asm/trace/diag.h>
1314

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);
1620

1721
struct diag_desc {
1822
int code;
@@ -114,6 +118,20 @@ static int __init show_diag_stat_init(void)
114118

115119
device_initcall(show_diag_stat_init);
116120

121+
void diag_stat_inc(enum diag_stat_enum nr)
122+
{
123+
this_cpu_inc(diag_stat.counter[nr]);
124+
trace_diagnose(diag_map[nr].code);
125+
}
126+
EXPORT_SYMBOL(diag_stat_inc);
127+
128+
void diag_stat_inc_norecursion(enum diag_stat_enum nr)
129+
{
130+
this_cpu_inc(diag_stat.counter[nr]);
131+
trace_diagnose_norecursion(diag_map[nr].code);
132+
}
133+
EXPORT_SYMBOL(diag_stat_inc_norecursion);
134+
117135
/*
118136
* Diagnose 14: Input spool file manipulation
119137
*/

arch/s390/kernel/smp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,11 @@ int smp_vcpu_scheduled(int cpu)
377377
void smp_yield_cpu(int cpu)
378378
{
379379
if (MACHINE_HAS_DIAG9C) {
380-
diag_stat_inc(DIAG_STAT_X09C);
380+
diag_stat_inc_norecursion(DIAG_STAT_X09C);
381381
asm volatile("diag %0,0,0x9c"
382382
: : "d" (pcpu_devices[cpu].address));
383383
} else if (MACHINE_HAS_DIAG44) {
384-
diag_stat_inc(DIAG_STAT_X044);
384+
diag_stat_inc_norecursion(DIAG_STAT_X044);
385385
asm volatile("diag 0,0,0x44");
386386
}
387387
}

arch/s390/kernel/trace.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Tracepoint definitions for s390
3+
*
4+
* Copyright IBM Corp. 2015
5+
* Author(s): Martin Schwidefsky <[email protected]>
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+
}

0 commit comments

Comments
 (0)