33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/capability.h>
44 #define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
46 #define BALLOON_CLASS_NAME "xen_memory"
48 static struct device balloon_dev;
50 static int register_balloon(
struct device *
dev);
54 const char **vec,
unsigned int len)
56 unsigned long long new_target;
71 .node =
"memory/target",
72 .callback = watch_target,
90 .notifier_call = balloon_init_watcher,
93 static int __init balloon_init(
void)
98 pr_info(
"xen-balloon: Initialising balloon driver.\n");
100 register_balloon(&balloon_dev);
110 static void balloon_exit(
void)
118 #define BALLOON_SHOW(name, format, args...) \
119 static ssize_t show_##name(struct device *dev, \
120 struct device_attribute *attr, \
123 return sprintf(buf, format, ##args); \
125 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
148 unsigned long long target_bytes;
161 show_target_kb, store_target_kb);
178 unsigned long long target_bytes;
183 target_bytes =
memparse(buf, &endchar);
191 show_target, store_target);
197 &dev_attr_schedule_delay.attr,
198 &dev_attr_max_schedule_delay.attr,
199 &dev_attr_retry_count.attr,
200 &dev_attr_max_retry_count.attr
203 static struct attribute *balloon_info_attrs[] = {
204 &dev_attr_current_kb.attr,
205 &dev_attr_low_kb.attr,
206 &dev_attr_high_kb.attr,
212 .attrs = balloon_info_attrs
215 static struct bus_type balloon_subsys = {
220 static int register_balloon(
struct device *dev)
229 dev->
bus = &balloon_subsys;
237 for (i = 0; i <
ARRAY_SIZE(balloon_attrs); i++) {