21 #include <linux/kernel.h>
28 #include <asm/cputable.h>
29 #include <asm/trace.h>
31 DEFINE_PER_CPU(
struct hcall_stats[HCALL_STAT_ARRAY_SIZE], hcall_stats);
38 if ((
int)*pos < (HCALL_STAT_ARRAY_SIZE-1))
39 return (
void *)(
unsigned long)(*pos + 1);
44 static void *hc_next(
struct seq_file *m,
void *
p, loff_t * pos)
48 return hc_start(m, pos);
51 static void hc_stop(
struct seq_file *m,
void *
p)
55 static int hc_show(
struct seq_file *m,
void *
p)
57 unsigned long h_num = (
unsigned long)p;
58 struct hcall_stats *hs = m->
private;
60 if (hs[h_num].num_calls) {
65 hs[h_num].purr_total);
87 rc =
seq_open(file, &hcall_inst_seq_ops);
95 .open = hcall_inst_seq_open,
101 #define HCALL_ROOT_DIR "hcall_inst"
102 #define CPU_NAME_BUF_SIZE 32
105 static void probe_hcall_entry(
void *
ignored,
unsigned long opcode,
unsigned long *args)
107 struct hcall_stats *
h;
109 if (opcode > MAX_HCALL_OPCODE)
113 h->tb_start = mftb();
114 h->purr_start =
mfspr(SPRN_PURR);
118 unsigned long *retbuf)
120 struct hcall_stats *
h;
122 if (opcode > MAX_HCALL_OPCODE)
127 h->tb_total += mftb() - h->tb_start;
128 h->purr_total +=
mfspr(SPRN_PURR) - h->purr_start;
131 static int __init hcall_inst_init(
void)
133 struct dentry *hcall_root;
134 struct dentry *hcall_file;
138 if (!firmware_has_feature(FW_FEATURE_LPAR))
141 if (register_trace_hcall_entry(probe_hcall_entry,
NULL))
144 if (register_trace_hcall_exit(probe_hcall_exit,
NULL)) {
145 unregister_trace_hcall_entry(probe_hcall_entry,
NULL);
158 &hcall_inst_seq_fops);