Skip to content

Commit 1ec2772

Browse files
author
Martin Schwidefsky
committed
s390/diag: add a statistic for diagnose calls
Introduce /sys/debug/kernel/diag_stat with a statistic how many diagnose calls have been done by each CPU in the system. Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent acdc9fc commit 1ec2772

File tree

19 files changed

+282
-19
lines changed

19 files changed

+282
-19
lines changed

arch/s390/hypfs/hypfs_diag.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/string.h>
1616
#include <linux/vmalloc.h>
1717
#include <linux/mm.h>
18+
#include <asm/diag.h>
1819
#include <asm/ebcdic.h>
1920
#include "hypfs.h"
2021

@@ -336,7 +337,7 @@ static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr)
336337

337338
/* Diagnose 204 functions */
338339

339-
static int diag204(unsigned long subcode, unsigned long size, void *addr)
340+
static inline int __diag204(unsigned long subcode, unsigned long size, void *addr)
340341
{
341342
register unsigned long _subcode asm("0") = subcode;
342343
register unsigned long _size asm("1") = size;
@@ -351,6 +352,12 @@ static int diag204(unsigned long subcode, unsigned long size, void *addr)
351352
return _size;
352353
}
353354

355+
static int diag204(unsigned long subcode, unsigned long size, void *addr)
356+
{
357+
diag_stat_inc(DIAG_STAT_X204);
358+
return __diag204(subcode, size, addr);
359+
}
360+
354361
/*
355362
* For the old diag subcode 4 with simple data format we have to use real
356363
* memory. If we use subcode 6 or 7 with extended data format, we can (and
@@ -505,6 +512,7 @@ static int diag224(void *ptr)
505512
{
506513
int rc = -EOPNOTSUPP;
507514

515+
diag_stat_inc(DIAG_STAT_X224);
508516
asm volatile(
509517
" diag %1,%2,0x224\n"
510518
"0: lhi %0,0x0\n"

arch/s390/hypfs/hypfs_diag0c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/slab.h>
1010
#include <linux/cpu.h>
11+
#include <asm/diag.h>
1112
#include <asm/hypfs.h>
1213
#include "hypfs.h"
1314

@@ -18,6 +19,7 @@
1819
*/
1920
static void diag0c(struct hypfs_diag0c_entry *entry)
2021
{
22+
diag_stat_inc(DIAG_STAT_X00C);
2123
asm volatile (
2224
" sam31\n"
2325
" diag %0,%0,0x0c\n"

arch/s390/hypfs/hypfs_sprp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/types.h>
1414
#include <linux/uaccess.h>
1515
#include <asm/compat.h>
16+
#include <asm/diag.h>
1617
#include <asm/sclp.h>
1718
#include "hypfs.h"
1819

@@ -22,7 +23,7 @@
2223

2324
#define DIAG304_CMD_MAX 2
2425

25-
static unsigned long hypfs_sprp_diag304(void *data, unsigned long cmd)
26+
static inline unsigned long __hypfs_sprp_diag304(void *data, unsigned long cmd)
2627
{
2728
register unsigned long _data asm("2") = (unsigned long) data;
2829
register unsigned long _rc asm("3");
@@ -34,6 +35,12 @@ static unsigned long hypfs_sprp_diag304(void *data, unsigned long cmd)
3435
return _rc;
3536
}
3637

38+
static unsigned long hypfs_sprp_diag304(void *data, unsigned long cmd)
39+
{
40+
diag_stat_inc(DIAG_STAT_X304);
41+
return __hypfs_sprp_diag304(data, cmd);
42+
}
43+
3744
static void hypfs_sprp_free(const void *data)
3845
{
3946
free_page((unsigned long) data);

arch/s390/hypfs/hypfs_vm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/errno.h>
1010
#include <linux/string.h>
1111
#include <linux/vmalloc.h>
12+
#include <asm/diag.h>
1213
#include <asm/ebcdic.h>
1314
#include <asm/timex.h>
1415
#include "hypfs.h"
@@ -66,6 +67,7 @@ static int diag2fc(int size, char* query, void *addr)
6667
memset(parm_list.aci_grp, 0x40, NAME_LEN);
6768
rc = -1;
6869

70+
diag_stat_inc(DIAG_STAT_X2FC);
6971
asm volatile(
7072
" diag %0,%1,0x2fc\n"
7173
"0:\n"

arch/s390/include/asm/appldata.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _ASM_S390_APPLDATA_H
88
#define _ASM_S390_APPLDATA_H
99

10+
#include <asm/diag.h>
1011
#include <asm/io.h>
1112

1213
#define APPLDATA_START_INTERVAL_REC 0x80
@@ -53,6 +54,7 @@ static inline int appldata_asm(struct appldata_product_id *id,
5354
parm_list.buffer_length = length;
5455
parm_list.product_id_addr = (unsigned long) id;
5556
parm_list.buffer_addr = virt_to_phys(buffer);
57+
diag_stat_inc(DIAG_STAT_X0DC);
5658
asm volatile(
5759
" diag %1,%0,0xdc"
5860
: "=d" (ry)

arch/s390/include/asm/diag.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,42 @@
88
#ifndef _ASM_S390_DIAG_H
99
#define _ASM_S390_DIAG_H
1010

11+
#include <linux/percpu.h>
12+
13+
enum diag_stat_enum {
14+
DIAG_STAT_X008,
15+
DIAG_STAT_X00C,
16+
DIAG_STAT_X010,
17+
DIAG_STAT_X014,
18+
DIAG_STAT_X044,
19+
DIAG_STAT_X064,
20+
DIAG_STAT_X09C,
21+
DIAG_STAT_X0DC,
22+
DIAG_STAT_X204,
23+
DIAG_STAT_X210,
24+
DIAG_STAT_X224,
25+
DIAG_STAT_X250,
26+
DIAG_STAT_X258,
27+
DIAG_STAT_X288,
28+
DIAG_STAT_X2C4,
29+
DIAG_STAT_X2FC,
30+
DIAG_STAT_X304,
31+
DIAG_STAT_X308,
32+
DIAG_STAT_X500,
33+
NR_DIAG_STAT
34+
};
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+
}
46+
1147
/*
1248
* Diagnose 10: Release page range
1349
*/
@@ -18,6 +54,7 @@ static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn)
1854
start_addr = start_pfn << PAGE_SHIFT;
1955
end_addr = (start_pfn + num_pfn - 1) << PAGE_SHIFT;
2056

57+
diag_stat_inc(DIAG_STAT_X010);
2158
asm volatile(
2259
"0: diag %0,%1,0x10\n"
2360
"1:\n"

arch/s390/include/asm/kvm_para.h

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
#define __S390_KVM_PARA_H
2828

2929
#include <uapi/asm/kvm_para.h>
30+
#include <asm/diag.h>
3031

31-
32-
33-
static inline long kvm_hypercall0(unsigned long nr)
32+
static inline long __kvm_hypercall0(unsigned long nr)
3433
{
3534
register unsigned long __nr asm("1") = nr;
3635
register long __rc asm("2");
@@ -40,7 +39,13 @@ static inline long kvm_hypercall0(unsigned long nr)
4039
return __rc;
4140
}
4241

43-
static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
42+
static inline long kvm_hypercall0(unsigned long nr)
43+
{
44+
diag_stat_inc(DIAG_STAT_X500);
45+
return __kvm_hypercall0(nr);
46+
}
47+
48+
static inline long __kvm_hypercall1(unsigned long nr, unsigned long p1)
4449
{
4550
register unsigned long __nr asm("1") = nr;
4651
register unsigned long __p1 asm("2") = p1;
@@ -51,7 +56,13 @@ static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
5156
return __rc;
5257
}
5358

54-
static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
59+
static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
60+
{
61+
diag_stat_inc(DIAG_STAT_X500);
62+
return __kvm_hypercall1(nr, p1);
63+
}
64+
65+
static inline long __kvm_hypercall2(unsigned long nr, unsigned long p1,
5566
unsigned long p2)
5667
{
5768
register unsigned long __nr asm("1") = nr;
@@ -65,7 +76,14 @@ static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
6576
return __rc;
6677
}
6778

68-
static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
79+
static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
80+
unsigned long p2)
81+
{
82+
diag_stat_inc(DIAG_STAT_X500);
83+
return __kvm_hypercall2(nr, p1, p2);
84+
}
85+
86+
static inline long __kvm_hypercall3(unsigned long nr, unsigned long p1,
6987
unsigned long p2, unsigned long p3)
7088
{
7189
register unsigned long __nr asm("1") = nr;
@@ -80,8 +98,14 @@ static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
8098
return __rc;
8199
}
82100

101+
static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
102+
unsigned long p2, unsigned long p3)
103+
{
104+
diag_stat_inc(DIAG_STAT_X500);
105+
return __kvm_hypercall3(nr, p1, p2, p3);
106+
}
83107

84-
static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
108+
static inline long __kvm_hypercall4(unsigned long nr, unsigned long p1,
85109
unsigned long p2, unsigned long p3,
86110
unsigned long p4)
87111
{
@@ -98,7 +122,15 @@ static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
98122
return __rc;
99123
}
100124

101-
static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
125+
static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
126+
unsigned long p2, unsigned long p3,
127+
unsigned long p4)
128+
{
129+
diag_stat_inc(DIAG_STAT_X500);
130+
return __kvm_hypercall4(nr, p1, p2, p3, p4);
131+
}
132+
133+
static inline long __kvm_hypercall5(unsigned long nr, unsigned long p1,
102134
unsigned long p2, unsigned long p3,
103135
unsigned long p4, unsigned long p5)
104136
{
@@ -116,7 +148,15 @@ static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
116148
return __rc;
117149
}
118150

119-
static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
151+
static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
152+
unsigned long p2, unsigned long p3,
153+
unsigned long p4, unsigned long p5)
154+
{
155+
diag_stat_inc(DIAG_STAT_X500);
156+
return __kvm_hypercall5(nr, p1, p2, p3, p4, p5);
157+
}
158+
159+
static inline long __kvm_hypercall6(unsigned long nr, unsigned long p1,
120160
unsigned long p2, unsigned long p3,
121161
unsigned long p4, unsigned long p5,
122162
unsigned long p6)
@@ -137,6 +177,15 @@ static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
137177
return __rc;
138178
}
139179

180+
static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
181+
unsigned long p2, unsigned long p3,
182+
unsigned long p4, unsigned long p5,
183+
unsigned long p6)
184+
{
185+
diag_stat_inc(DIAG_STAT_X500);
186+
return __kvm_hypercall6(nr, p1, p2, p3, p4, p5, p6);
187+
}
188+
140189
/* kvm on s390 is always paravirtualization enabled */
141190
static inline int kvm_para_available(void)
142191
{

arch/s390/kernel/cpcmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/spinlock.h>
1515
#include <linux/stddef.h>
1616
#include <linux/string.h>
17+
#include <asm/diag.h>
1718
#include <asm/ebcdic.h>
1819
#include <asm/cpcmd.h>
1920
#include <asm/io.h>
@@ -70,6 +71,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code)
7071
memcpy(cpcmd_buf, cmd, cmdlen);
7172
ASCEBC(cpcmd_buf, cmdlen);
7273

74+
diag_stat_inc(DIAG_STAT_X008);
7375
if (response) {
7476
memset(response, 0, rlen);
7577
response_len = rlen;

0 commit comments

Comments
 (0)