5 #include <linux/sched.h>
6 #include <linux/device.h>
13 #include <asm/hypervisor.h>
18 #define SHOW_MMUSTAT_ULONG(NAME) \
19 static ssize_t show_##NAME(struct device *dev, \
20 struct device_attribute *attr, char *buf) \
22 struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \
23 return sprintf(buf, "%lu\n", p->NAME); \
25 static DEVICE_ATTR(NAME, 0444, show_##NAME, NULL)
60 static struct attribute *mmu_stat_attrs[] = {
61 &dev_attr_immu_tsb_hits_ctx0_8k_tte.attr,
62 &dev_attr_immu_tsb_ticks_ctx0_8k_tte.attr,
63 &dev_attr_immu_tsb_hits_ctx0_64k_tte.attr,
64 &dev_attr_immu_tsb_ticks_ctx0_64k_tte.attr,
65 &dev_attr_immu_tsb_hits_ctx0_4mb_tte.attr,
66 &dev_attr_immu_tsb_ticks_ctx0_4mb_tte.attr,
67 &dev_attr_immu_tsb_hits_ctx0_256mb_tte.attr,
68 &dev_attr_immu_tsb_ticks_ctx0_256mb_tte.attr,
69 &dev_attr_immu_tsb_hits_ctxnon0_8k_tte.attr,
70 &dev_attr_immu_tsb_ticks_ctxnon0_8k_tte.attr,
71 &dev_attr_immu_tsb_hits_ctxnon0_64k_tte.attr,
72 &dev_attr_immu_tsb_ticks_ctxnon0_64k_tte.attr,
73 &dev_attr_immu_tsb_hits_ctxnon0_4mb_tte.attr,
74 &dev_attr_immu_tsb_ticks_ctxnon0_4mb_tte.attr,
75 &dev_attr_immu_tsb_hits_ctxnon0_256mb_tte.attr,
76 &dev_attr_immu_tsb_ticks_ctxnon0_256mb_tte.attr,
77 &dev_attr_dmmu_tsb_hits_ctx0_8k_tte.attr,
78 &dev_attr_dmmu_tsb_ticks_ctx0_8k_tte.attr,
79 &dev_attr_dmmu_tsb_hits_ctx0_64k_tte.attr,
80 &dev_attr_dmmu_tsb_ticks_ctx0_64k_tte.attr,
81 &dev_attr_dmmu_tsb_hits_ctx0_4mb_tte.attr,
82 &dev_attr_dmmu_tsb_ticks_ctx0_4mb_tte.attr,
83 &dev_attr_dmmu_tsb_hits_ctx0_256mb_tte.attr,
84 &dev_attr_dmmu_tsb_ticks_ctx0_256mb_tte.attr,
85 &dev_attr_dmmu_tsb_hits_ctxnon0_8k_tte.attr,
86 &dev_attr_dmmu_tsb_ticks_ctxnon0_8k_tte.attr,
87 &dev_attr_dmmu_tsb_hits_ctxnon0_64k_tte.attr,
88 &dev_attr_dmmu_tsb_ticks_ctxnon0_64k_tte.attr,
89 &dev_attr_dmmu_tsb_hits_ctxnon0_4mb_tte.attr,
90 &dev_attr_dmmu_tsb_ticks_ctxnon0_4mb_tte.attr,
91 &dev_attr_dmmu_tsb_hits_ctxnon0_256mb_tte.attr,
92 &dev_attr_dmmu_tsb_ticks_ctxnon0_256mb_tte.attr,
97 .attrs = mmu_stat_attrs,
102 static unsigned long run_on_cpu(
unsigned long cpu,
103 unsigned long (*
func)(
unsigned long),
116 set_cpus_allowed_ptr(
current, &old_affinity);
121 static unsigned long read_mmustat_enable(
unsigned long junk)
123 unsigned long ra = 0;
130 static unsigned long write_mmustat_enable(
unsigned long val)
132 unsigned long ra, orig_ra;
145 unsigned long val = run_on_cpu(s->
id, read_mmustat_enable, 0);
146 return sprintf(buf,
"%lx\n", val);
154 int ret =
sscanf(buf,
"%ld", &val);
159 err = run_on_cpu(s->
id, write_mmustat_enable, val);
166 static DEVICE_ATTR(mmustat_enable, 0644, show_mmustat_enable, store_mmustat_enable);
168 static int mmu_stats_supported;
170 static int register_mmu_stats(
struct device *s)
172 if (!mmu_stats_supported)
178 #ifdef CONFIG_HOTPLUG_CPU
179 static void unregister_mmu_stats(
struct device *s)
181 if (!mmu_stats_supported)
188 #define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \
189 static ssize_t show_##NAME(struct device *dev, \
190 struct device_attribute *attr, char *buf) \
192 cpuinfo_sparc *c = &cpu_data(dev->id); \
193 return sprintf(buf, "%lu\n", c->MEMBER); \
196 #define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \
197 static ssize_t show_##NAME(struct device *dev, \
198 struct device_attribute *attr, char *buf) \
200 cpuinfo_sparc *c = &cpu_data(dev->id); \
201 return sprintf(buf, "%u\n", c->MEMBER); \
213 __ATTR(clock_tick, 0444, show_clock_tick,
NULL),
214 __ATTR(l1_dcache_size, 0444, show_l1_dcache_size,
NULL),
215 __ATTR(l1_dcache_line_size, 0444, show_l1_dcache_line_size,
NULL),
216 __ATTR(l1_icache_size, 0444, show_l1_icache_size,
NULL),
217 __ATTR(l1_icache_line_size, 0444, show_l1_icache_line_size,
NULL),
218 __ATTR(l2_cache_size, 0444, show_l2_cache_size,
NULL),
219 __ATTR(l2_cache_line_size, 0444, show_l2_cache_line_size,
NULL),
224 static void register_cpu_online(
unsigned int cpu)
226 struct cpu *
c = &
per_cpu(cpu_devices, cpu);
230 for (i = 0; i <
ARRAY_SIZE(cpu_core_attrs); i++)
233 register_mmu_stats(s);
236 #ifdef CONFIG_HOTPLUG_CPU
237 static void unregister_cpu_online(
unsigned int cpu)
239 struct cpu *c = &
per_cpu(cpu_devices, cpu);
243 unregister_mmu_stats(s);
244 for (i = 0; i <
ARRAY_SIZE(cpu_core_attrs); i++)
250 unsigned long action,
void *hcpu)
252 unsigned int cpu = (
unsigned int)(
long)hcpu;
257 register_cpu_online(cpu);
259 #ifdef CONFIG_HOTPLUG_CPU
262 unregister_cpu_online(cpu);
270 .notifier_call = sysfs_cpu_notify,
273 static void __init check_mmu_stats(
void)
275 unsigned long dummy1,
err;
282 mmu_stats_supported = 1;
285 static void register_nodes(
void)
295 static int __init topology_init(
void)
303 register_cpu_notifier(&sysfs_cpu_nb);
306 struct cpu *c = &
per_cpu(cpu_devices, cpu);
310 register_cpu_online(cpu);