virtio_balloon.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * Virtio balloon implementation, inspired by Dor Laor and Marcelo
  3. * Tosatti's implementations.
  4. *
  5. * Copyright 2008 Rusty Russell IBM Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <linux/virtio.h>
  22. #include <linux/virtio_balloon.h>
  23. #include <linux/swap.h>
  24. #include <linux/kthread.h>
  25. #include <linux/freezer.h>
  26. #include <linux/delay.h>
  27. #include <linux/slab.h>
  28. #include <linux/module.h>
  29. #include <linux/balloon_compaction.h>
  30. #include <linux/oom.h>
  31. #include <linux/wait.h>
  32. /*
  33. * Balloon device works in 4K page units. So each page is pointed to by
  34. * multiple balloon pages. All memory counters in this driver are in balloon
  35. * page units.
  36. */
  37. #define VIRTIO_BALLOON_PAGES_PER_PAGE (unsigned)(PAGE_SIZE >> VIRTIO_BALLOON_PFN_SHIFT)
  38. #define VIRTIO_BALLOON_ARRAY_PFNS_MAX 256
  39. #define OOM_VBALLOON_DEFAULT_PAGES 256
  40. #define VIRTBALLOON_OOM_NOTIFY_PRIORITY 80
  41. static int oom_pages = OOM_VBALLOON_DEFAULT_PAGES;
  42. module_param(oom_pages, int, S_IRUSR | S_IWUSR);
  43. MODULE_PARM_DESC(oom_pages, "pages to free on OOM");
  44. struct virtio_balloon {
  45. struct virtio_device *vdev;
  46. struct virtqueue *inflate_vq, *deflate_vq, *stats_vq;
  47. /* Where the ballooning thread waits for config to change. */
  48. wait_queue_head_t config_change;
  49. /* The thread servicing the balloon. */
  50. struct task_struct *thread;
  51. /* Waiting for host to ack the pages we released. */
  52. wait_queue_head_t acked;
  53. /* Number of balloon pages we've told the Host we're not using. */
  54. unsigned int num_pages;
  55. /*
  56. * The pages we've told the Host we're not using are enqueued
  57. * at vb_dev_info->pages list.
  58. * Each page on this list adds VIRTIO_BALLOON_PAGES_PER_PAGE
  59. * to num_pages above.
  60. */
  61. struct balloon_dev_info vb_dev_info;
  62. /* Synchronize access/update to this struct virtio_balloon elements */
  63. struct mutex balloon_lock;
  64. /* The array of pfns we tell the Host about. */
  65. unsigned int num_pfns;
  66. u32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX];
  67. /* Memory statistics */
  68. int need_stats_update;
  69. struct virtio_balloon_stat stats[VIRTIO_BALLOON_S_NR];
  70. /* To register callback in oom notifier call chain */
  71. struct notifier_block nb;
  72. };
  73. static struct virtio_device_id id_table[] = {
  74. { VIRTIO_ID_BALLOON, VIRTIO_DEV_ANY_ID },
  75. { 0 },
  76. };
  77. static u32 page_to_balloon_pfn(struct page *page)
  78. {
  79. unsigned long pfn = page_to_pfn(page);
  80. BUILD_BUG_ON(PAGE_SHIFT < VIRTIO_BALLOON_PFN_SHIFT);
  81. /* Convert pfn from Linux page size to balloon page size. */
  82. return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE;
  83. }
  84. static struct page *balloon_pfn_to_page(u32 pfn)
  85. {
  86. BUG_ON(pfn % VIRTIO_BALLOON_PAGES_PER_PAGE);
  87. return pfn_to_page(pfn / VIRTIO_BALLOON_PAGES_PER_PAGE);
  88. }
  89. static void balloon_ack(struct virtqueue *vq)
  90. {
  91. struct virtio_balloon *vb = vq->vdev->priv;
  92. wake_up(&vb->acked);
  93. }
  94. static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
  95. {
  96. struct scatterlist sg;
  97. unsigned int len;
  98. sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
  99. /* We should always be able to add one buffer to an empty queue. */
  100. virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
  101. virtqueue_kick(vq);
  102. /* When host has read buffer, this completes via balloon_ack */
  103. wait_event(vb->acked, virtqueue_get_buf(vq, &len));
  104. }
  105. static void set_page_pfns(u32 pfns[], struct page *page)
  106. {
  107. unsigned int i;
  108. /* Set balloon pfns pointing at this page.
  109. * Note that the first pfn points at start of the page. */
  110. for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++)
  111. pfns[i] = page_to_balloon_pfn(page) + i;
  112. }
  113. static void fill_balloon(struct virtio_balloon *vb, size_t num)
  114. {
  115. struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
  116. /* We can only do one array worth at a time. */
  117. num = min(num, ARRAY_SIZE(vb->pfns));
  118. mutex_lock(&vb->balloon_lock);
  119. for (vb->num_pfns = 0; vb->num_pfns < num;
  120. vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) {
  121. struct page *page = balloon_page_enqueue(vb_dev_info);
  122. if (!page) {
  123. dev_info_ratelimited(&vb->vdev->dev,
  124. "Out of puff! Can't get %u pages\n",
  125. VIRTIO_BALLOON_PAGES_PER_PAGE);
  126. /* Sleep for at least 1/5 of a second before retry. */
  127. msleep(200);
  128. break;
  129. }
  130. set_page_pfns(vb->pfns + vb->num_pfns, page);
  131. vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE;
  132. adjust_managed_page_count(page, -1);
  133. }
  134. /* Did we get any? */
  135. if (vb->num_pfns != 0)
  136. tell_host(vb, vb->inflate_vq);
  137. mutex_unlock(&vb->balloon_lock);
  138. }
  139. static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
  140. {
  141. unsigned int i;
  142. /* Find pfns pointing at start of each page, get pages and free them. */
  143. for (i = 0; i < num; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
  144. struct page *page = balloon_pfn_to_page(pfns[i]);
  145. adjust_managed_page_count(page, 1);
  146. put_page(page); /* balloon reference */
  147. }
  148. }
  149. static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)
  150. {
  151. unsigned num_freed_pages;
  152. struct page *page;
  153. struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
  154. /* We can only do one array worth at a time. */
  155. num = min(num, ARRAY_SIZE(vb->pfns));
  156. mutex_lock(&vb->balloon_lock);
  157. for (vb->num_pfns = 0; vb->num_pfns < num;
  158. vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) {
  159. page = balloon_page_dequeue(vb_dev_info);
  160. if (!page)
  161. break;
  162. set_page_pfns(vb->pfns + vb->num_pfns, page);
  163. vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
  164. }
  165. num_freed_pages = vb->num_pfns;
  166. /*
  167. * Note that if
  168. * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
  169. * is true, we *have* to do it in this order
  170. */
  171. if (vb->num_pfns != 0)
  172. tell_host(vb, vb->deflate_vq);
  173. mutex_unlock(&vb->balloon_lock);
  174. release_pages_by_pfn(vb->pfns, vb->num_pfns);
  175. return num_freed_pages;
  176. }
  177. static inline void update_stat(struct virtio_balloon *vb, int idx,
  178. u16 tag, u64 val)
  179. {
  180. BUG_ON(idx >= VIRTIO_BALLOON_S_NR);
  181. vb->stats[idx].tag = cpu_to_virtio16(vb->vdev, tag);
  182. vb->stats[idx].val = cpu_to_virtio64(vb->vdev, val);
  183. }
  184. #define pages_to_bytes(x) ((u64)(x) << PAGE_SHIFT)
  185. static void update_balloon_stats(struct virtio_balloon *vb)
  186. {
  187. unsigned long events[NR_VM_EVENT_ITEMS];
  188. struct sysinfo i;
  189. int idx = 0;
  190. all_vm_events(events);
  191. si_meminfo(&i);
  192. update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,
  193. pages_to_bytes(events[PSWPIN]));
  194. update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT,
  195. pages_to_bytes(events[PSWPOUT]));
  196. update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  197. update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
  198. update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  199. pages_to_bytes(i.freeram));
  200. update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
  201. pages_to_bytes(i.totalram));
  202. }
  203. /*
  204. * While most virtqueues communicate guest-initiated requests to the hypervisor,
  205. * the stats queue operates in reverse. The driver initializes the virtqueue
  206. * with a single buffer. From that point forward, all conversations consist of
  207. * a hypervisor request (a call to this function) which directs us to refill
  208. * the virtqueue with a fresh stats buffer. Since stats collection can sleep,
  209. * we notify our kthread which does the actual work via stats_handle_request().
  210. */
  211. static void stats_request(struct virtqueue *vq)
  212. {
  213. struct virtio_balloon *vb = vq->vdev->priv;
  214. vb->need_stats_update = 1;
  215. wake_up(&vb->config_change);
  216. }
  217. static void stats_handle_request(struct virtio_balloon *vb)
  218. {
  219. struct virtqueue *vq;
  220. struct scatterlist sg;
  221. unsigned int len;
  222. vb->need_stats_update = 0;
  223. update_balloon_stats(vb);
  224. vq = vb->stats_vq;
  225. if (!virtqueue_get_buf(vq, &len))
  226. return;
  227. sg_init_one(&sg, vb->stats, sizeof(vb->stats));
  228. virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
  229. virtqueue_kick(vq);
  230. }
  231. static void virtballoon_changed(struct virtio_device *vdev)
  232. {
  233. struct virtio_balloon *vb = vdev->priv;
  234. wake_up(&vb->config_change);
  235. }
  236. static inline s64 towards_target(struct virtio_balloon *vb)
  237. {
  238. s64 target;
  239. u32 num_pages;
  240. virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages,
  241. &num_pages);
  242. /* Legacy balloon config space is LE, unlike all other devices. */
  243. if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
  244. num_pages = le32_to_cpu((__force __le32)num_pages);
  245. target = num_pages;
  246. return target - vb->num_pages;
  247. }
  248. static void update_balloon_size(struct virtio_balloon *vb)
  249. {
  250. u32 actual = vb->num_pages;
  251. /* Legacy balloon config space is LE, unlike all other devices. */
  252. if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
  253. actual = (__force u32)cpu_to_le32(actual);
  254. virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual,
  255. &actual);
  256. }
  257. /*
  258. * virtballoon_oom_notify - release pages when system is under severe
  259. * memory pressure (called from out_of_memory())
  260. * @self : notifier block struct
  261. * @dummy: not used
  262. * @parm : returned - number of freed pages
  263. *
  264. * The balancing of memory by use of the virtio balloon should not cause
  265. * the termination of processes while there are pages in the balloon.
  266. * If virtio balloon manages to release some memory, it will make the
  267. * system return and retry the allocation that forced the OOM killer
  268. * to run.
  269. */
  270. static int virtballoon_oom_notify(struct notifier_block *self,
  271. unsigned long dummy, void *parm)
  272. {
  273. struct virtio_balloon *vb;
  274. unsigned long *freed;
  275. unsigned num_freed_pages;
  276. vb = container_of(self, struct virtio_balloon, nb);
  277. if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
  278. return NOTIFY_OK;
  279. freed = parm;
  280. num_freed_pages = leak_balloon(vb, oom_pages);
  281. update_balloon_size(vb);
  282. *freed += num_freed_pages;
  283. return NOTIFY_OK;
  284. }
  285. static int balloon(void *_vballoon)
  286. {
  287. struct virtio_balloon *vb = _vballoon;
  288. DEFINE_WAIT_FUNC(wait, woken_wake_function);
  289. set_freezable();
  290. while (!kthread_should_stop()) {
  291. s64 diff;
  292. try_to_freeze();
  293. add_wait_queue(&vb->config_change, &wait);
  294. for (;;) {
  295. if ((diff = towards_target(vb)) != 0 ||
  296. vb->need_stats_update ||
  297. kthread_should_stop() ||
  298. freezing(current))
  299. break;
  300. wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
  301. }
  302. remove_wait_queue(&vb->config_change, &wait);
  303. if (vb->need_stats_update)
  304. stats_handle_request(vb);
  305. if (diff > 0)
  306. fill_balloon(vb, diff);
  307. else if (diff < 0)
  308. leak_balloon(vb, -diff);
  309. update_balloon_size(vb);
  310. /*
  311. * For large balloon changes, we could spend a lot of time
  312. * and always have work to do. Be nice if preempt disabled.
  313. */
  314. cond_resched();
  315. }
  316. return 0;
  317. }
  318. static int init_vqs(struct virtio_balloon *vb)
  319. {
  320. struct virtqueue *vqs[3];
  321. vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request };
  322. const char *names[] = { "inflate", "deflate", "stats" };
  323. int err, nvqs;
  324. /*
  325. * We expect two virtqueues: inflate and deflate, and
  326. * optionally stat.
  327. */
  328. nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2;
  329. err = vb->vdev->config->find_vqs(vb->vdev, nvqs, vqs, callbacks, names);
  330. if (err)
  331. return err;
  332. vb->inflate_vq = vqs[0];
  333. vb->deflate_vq = vqs[1];
  334. if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) {
  335. struct scatterlist sg;
  336. vb->stats_vq = vqs[2];
  337. /*
  338. * Prime this virtqueue with one buffer so the hypervisor can
  339. * use it to signal us later (it can't be broken yet!).
  340. */
  341. sg_init_one(&sg, vb->stats, sizeof vb->stats);
  342. if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL)
  343. < 0)
  344. BUG();
  345. virtqueue_kick(vb->stats_vq);
  346. }
  347. return 0;
  348. }
  349. #ifdef CONFIG_BALLOON_COMPACTION
  350. /*
  351. * virtballoon_migratepage - perform the balloon page migration on behalf of
  352. * a compation thread. (called under page lock)
  353. * @vb_dev_info: the balloon device
  354. * @newpage: page that will replace the isolated page after migration finishes.
  355. * @page : the isolated (old) page that is about to be migrated to newpage.
  356. * @mode : compaction mode -- not used for balloon page migration.
  357. *
  358. * After a ballooned page gets isolated by compaction procedures, this is the
  359. * function that performs the page migration on behalf of a compaction thread
  360. * The page migration for virtio balloon is done in a simple swap fashion which
  361. * follows these two macro steps:
  362. * 1) insert newpage into vb->pages list and update the host about it;
  363. * 2) update the host about the old page removed from vb->pages list;
  364. *
  365. * This function preforms the balloon page migration task.
  366. * Called through balloon_mapping->a_ops->migratepage
  367. */
  368. static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
  369. struct page *newpage, struct page *page, enum migrate_mode mode)
  370. {
  371. struct virtio_balloon *vb = container_of(vb_dev_info,
  372. struct virtio_balloon, vb_dev_info);
  373. unsigned long flags;
  374. /*
  375. * In order to avoid lock contention while migrating pages concurrently
  376. * to leak_balloon() or fill_balloon() we just give up the balloon_lock
  377. * this turn, as it is easier to retry the page migration later.
  378. * This also prevents fill_balloon() getting stuck into a mutex
  379. * recursion in the case it ends up triggering memory compaction
  380. * while it is attempting to inflate the ballon.
  381. */
  382. if (!mutex_trylock(&vb->balloon_lock))
  383. return -EAGAIN;
  384. get_page(newpage); /* balloon reference */
  385. /* balloon's page migration 1st step -- inflate "newpage" */
  386. spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
  387. balloon_page_insert(vb_dev_info, newpage);
  388. vb_dev_info->isolated_pages--;
  389. __count_vm_event(BALLOON_MIGRATE);
  390. spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
  391. vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
  392. set_page_pfns(vb->pfns, newpage);
  393. tell_host(vb, vb->inflate_vq);
  394. /* balloon's page migration 2nd step -- deflate "page" */
  395. balloon_page_delete(page);
  396. vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
  397. set_page_pfns(vb->pfns, page);
  398. tell_host(vb, vb->deflate_vq);
  399. mutex_unlock(&vb->balloon_lock);
  400. put_page(page); /* balloon reference */
  401. return MIGRATEPAGE_SUCCESS;
  402. }
  403. #endif /* CONFIG_BALLOON_COMPACTION */
  404. static int virtballoon_probe(struct virtio_device *vdev)
  405. {
  406. struct virtio_balloon *vb;
  407. int err;
  408. if (!vdev->config->get) {
  409. dev_err(&vdev->dev, "%s failure: config access disabled\n",
  410. __func__);
  411. return -EINVAL;
  412. }
  413. vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
  414. if (!vb) {
  415. err = -ENOMEM;
  416. goto out;
  417. }
  418. vb->num_pages = 0;
  419. mutex_init(&vb->balloon_lock);
  420. init_waitqueue_head(&vb->config_change);
  421. init_waitqueue_head(&vb->acked);
  422. vb->vdev = vdev;
  423. vb->need_stats_update = 0;
  424. balloon_devinfo_init(&vb->vb_dev_info);
  425. #ifdef CONFIG_BALLOON_COMPACTION
  426. vb->vb_dev_info.migratepage = virtballoon_migratepage;
  427. #endif
  428. err = init_vqs(vb);
  429. if (err)
  430. goto out_free_vb;
  431. vb->nb.notifier_call = virtballoon_oom_notify;
  432. vb->nb.priority = VIRTBALLOON_OOM_NOTIFY_PRIORITY;
  433. err = register_oom_notifier(&vb->nb);
  434. if (err < 0)
  435. goto out_oom_notify;
  436. virtio_device_ready(vdev);
  437. vb->thread = kthread_run(balloon, vb, "vballoon");
  438. if (IS_ERR(vb->thread)) {
  439. err = PTR_ERR(vb->thread);
  440. goto out_del_vqs;
  441. }
  442. return 0;
  443. out_del_vqs:
  444. unregister_oom_notifier(&vb->nb);
  445. out_oom_notify:
  446. vdev->config->del_vqs(vdev);
  447. out_free_vb:
  448. kfree(vb);
  449. out:
  450. return err;
  451. }
  452. static void remove_common(struct virtio_balloon *vb)
  453. {
  454. /* There might be pages left in the balloon: free them. */
  455. while (vb->num_pages)
  456. leak_balloon(vb, vb->num_pages);
  457. update_balloon_size(vb);
  458. /* Now we reset the device so we can clean up the queues. */
  459. vb->vdev->config->reset(vb->vdev);
  460. vb->vdev->config->del_vqs(vb->vdev);
  461. }
  462. static void virtballoon_remove(struct virtio_device *vdev)
  463. {
  464. struct virtio_balloon *vb = vdev->priv;
  465. unregister_oom_notifier(&vb->nb);
  466. kthread_stop(vb->thread);
  467. remove_common(vb);
  468. kfree(vb);
  469. }
  470. #ifdef CONFIG_PM_SLEEP
  471. static int virtballoon_freeze(struct virtio_device *vdev)
  472. {
  473. struct virtio_balloon *vb = vdev->priv;
  474. /*
  475. * The kthread is already frozen by the PM core before this
  476. * function is called.
  477. */
  478. remove_common(vb);
  479. return 0;
  480. }
  481. static int virtballoon_restore(struct virtio_device *vdev)
  482. {
  483. struct virtio_balloon *vb = vdev->priv;
  484. int ret;
  485. ret = init_vqs(vdev->priv);
  486. if (ret)
  487. return ret;
  488. virtio_device_ready(vdev);
  489. fill_balloon(vb, towards_target(vb));
  490. update_balloon_size(vb);
  491. return 0;
  492. }
  493. #endif
  494. static unsigned int features[] = {
  495. VIRTIO_BALLOON_F_MUST_TELL_HOST,
  496. VIRTIO_BALLOON_F_STATS_VQ,
  497. VIRTIO_BALLOON_F_DEFLATE_ON_OOM,
  498. };
  499. static struct virtio_driver virtio_balloon_driver = {
  500. .feature_table = features,
  501. .feature_table_size = ARRAY_SIZE(features),
  502. .driver.name = KBUILD_MODNAME,
  503. .driver.owner = THIS_MODULE,
  504. .id_table = id_table,
  505. .probe = virtballoon_probe,
  506. .remove = virtballoon_remove,
  507. .config_changed = virtballoon_changed,
  508. #ifdef CONFIG_PM_SLEEP
  509. .freeze = virtballoon_freeze,
  510. .restore = virtballoon_restore,
  511. #endif
  512. };
  513. module_virtio_driver(virtio_balloon_driver);
  514. MODULE_DEVICE_TABLE(virtio, id_table);
  515. MODULE_DESCRIPTION("Virtio balloon driver");
  516. MODULE_LICENSE("GPL");