virtio_balloon.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. if (!virtio_has_feature(vb->vdev,
  133. VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
  134. adjust_managed_page_count(page, -1);
  135. }
  136. /* Did we get any? */
  137. if (vb->num_pfns != 0)
  138. tell_host(vb, vb->inflate_vq);
  139. mutex_unlock(&vb->balloon_lock);
  140. }
  141. static void release_pages_balloon(struct virtio_balloon *vb)
  142. {
  143. unsigned int i;
  144. /* Find pfns pointing at start of each page, get pages and free them. */
  145. for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
  146. struct page *page = balloon_pfn_to_page(vb->pfns[i]);
  147. if (!virtio_has_feature(vb->vdev,
  148. VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
  149. adjust_managed_page_count(page, 1);
  150. put_page(page); /* balloon reference */
  151. }
  152. }
  153. static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)
  154. {
  155. unsigned num_freed_pages;
  156. struct page *page;
  157. struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
  158. /* We can only do one array worth at a time. */
  159. num = min(num, ARRAY_SIZE(vb->pfns));
  160. mutex_lock(&vb->balloon_lock);
  161. for (vb->num_pfns = 0; vb->num_pfns < num;
  162. vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) {
  163. page = balloon_page_dequeue(vb_dev_info);
  164. if (!page)
  165. break;
  166. set_page_pfns(vb->pfns + vb->num_pfns, page);
  167. vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
  168. }
  169. num_freed_pages = vb->num_pfns;
  170. /*
  171. * Note that if
  172. * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
  173. * is true, we *have* to do it in this order
  174. */
  175. if (vb->num_pfns != 0)
  176. tell_host(vb, vb->deflate_vq);
  177. mutex_unlock(&vb->balloon_lock);
  178. release_pages_balloon(vb);
  179. return num_freed_pages;
  180. }
  181. static inline void update_stat(struct virtio_balloon *vb, int idx,
  182. u16 tag, u64 val)
  183. {
  184. BUG_ON(idx >= VIRTIO_BALLOON_S_NR);
  185. vb->stats[idx].tag = cpu_to_virtio16(vb->vdev, tag);
  186. vb->stats[idx].val = cpu_to_virtio64(vb->vdev, val);
  187. }
  188. #define pages_to_bytes(x) ((u64)(x) << PAGE_SHIFT)
  189. static void update_balloon_stats(struct virtio_balloon *vb)
  190. {
  191. unsigned long events[NR_VM_EVENT_ITEMS];
  192. struct sysinfo i;
  193. int idx = 0;
  194. all_vm_events(events);
  195. si_meminfo(&i);
  196. update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,
  197. pages_to_bytes(events[PSWPIN]));
  198. update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT,
  199. pages_to_bytes(events[PSWPOUT]));
  200. update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
  201. update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
  202. update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE,
  203. pages_to_bytes(i.freeram));
  204. update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,
  205. pages_to_bytes(i.totalram));
  206. }
  207. /*
  208. * While most virtqueues communicate guest-initiated requests to the hypervisor,
  209. * the stats queue operates in reverse. The driver initializes the virtqueue
  210. * with a single buffer. From that point forward, all conversations consist of
  211. * a hypervisor request (a call to this function) which directs us to refill
  212. * the virtqueue with a fresh stats buffer. Since stats collection can sleep,
  213. * we notify our kthread which does the actual work via stats_handle_request().
  214. */
  215. static void stats_request(struct virtqueue *vq)
  216. {
  217. struct virtio_balloon *vb = vq->vdev->priv;
  218. vb->need_stats_update = 1;
  219. wake_up(&vb->config_change);
  220. }
  221. static void stats_handle_request(struct virtio_balloon *vb)
  222. {
  223. struct virtqueue *vq;
  224. struct scatterlist sg;
  225. unsigned int len;
  226. vb->need_stats_update = 0;
  227. update_balloon_stats(vb);
  228. vq = vb->stats_vq;
  229. if (!virtqueue_get_buf(vq, &len))
  230. return;
  231. sg_init_one(&sg, vb->stats, sizeof(vb->stats));
  232. virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
  233. virtqueue_kick(vq);
  234. }
  235. static void virtballoon_changed(struct virtio_device *vdev)
  236. {
  237. struct virtio_balloon *vb = vdev->priv;
  238. wake_up(&vb->config_change);
  239. }
  240. static inline s64 towards_target(struct virtio_balloon *vb)
  241. {
  242. s64 target;
  243. u32 num_pages;
  244. virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages,
  245. &num_pages);
  246. /* Legacy balloon config space is LE, unlike all other devices. */
  247. if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
  248. num_pages = le32_to_cpu((__force __le32)num_pages);
  249. target = num_pages;
  250. return target - vb->num_pages;
  251. }
  252. static void update_balloon_size(struct virtio_balloon *vb)
  253. {
  254. u32 actual = vb->num_pages;
  255. /* Legacy balloon config space is LE, unlike all other devices. */
  256. if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
  257. actual = (__force u32)cpu_to_le32(actual);
  258. virtio_cwrite(vb->vdev, struct virtio_balloon_config, actual,
  259. &actual);
  260. }
  261. /*
  262. * virtballoon_oom_notify - release pages when system is under severe
  263. * memory pressure (called from out_of_memory())
  264. * @self : notifier block struct
  265. * @dummy: not used
  266. * @parm : returned - number of freed pages
  267. *
  268. * The balancing of memory by use of the virtio balloon should not cause
  269. * the termination of processes while there are pages in the balloon.
  270. * If virtio balloon manages to release some memory, it will make the
  271. * system return and retry the allocation that forced the OOM killer
  272. * to run.
  273. */
  274. static int virtballoon_oom_notify(struct notifier_block *self,
  275. unsigned long dummy, void *parm)
  276. {
  277. struct virtio_balloon *vb;
  278. unsigned long *freed;
  279. unsigned num_freed_pages;
  280. vb = container_of(self, struct virtio_balloon, nb);
  281. if (!virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
  282. return NOTIFY_OK;
  283. freed = parm;
  284. num_freed_pages = leak_balloon(vb, oom_pages);
  285. update_balloon_size(vb);
  286. *freed += num_freed_pages;
  287. return NOTIFY_OK;
  288. }
  289. static int balloon(void *_vballoon)
  290. {
  291. struct virtio_balloon *vb = _vballoon;
  292. DEFINE_WAIT_FUNC(wait, woken_wake_function);
  293. set_freezable();
  294. while (!kthread_should_stop()) {
  295. s64 diff;
  296. try_to_freeze();
  297. add_wait_queue(&vb->config_change, &wait);
  298. for (;;) {
  299. if ((diff = towards_target(vb)) != 0 ||
  300. vb->need_stats_update ||
  301. kthread_should_stop() ||
  302. freezing(current))
  303. break;
  304. wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
  305. }
  306. remove_wait_queue(&vb->config_change, &wait);
  307. if (vb->need_stats_update)
  308. stats_handle_request(vb);
  309. if (diff > 0)
  310. fill_balloon(vb, diff);
  311. else if (diff < 0)
  312. leak_balloon(vb, -diff);
  313. update_balloon_size(vb);
  314. /*
  315. * For large balloon changes, we could spend a lot of time
  316. * and always have work to do. Be nice if preempt disabled.
  317. */
  318. cond_resched();
  319. }
  320. return 0;
  321. }
  322. static int init_vqs(struct virtio_balloon *vb)
  323. {
  324. struct virtqueue *vqs[3];
  325. vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request };
  326. const char *names[] = { "inflate", "deflate", "stats" };
  327. int err, nvqs;
  328. /*
  329. * We expect two virtqueues: inflate and deflate, and
  330. * optionally stat.
  331. */
  332. nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2;
  333. err = vb->vdev->config->find_vqs(vb->vdev, nvqs, vqs, callbacks, names);
  334. if (err)
  335. return err;
  336. vb->inflate_vq = vqs[0];
  337. vb->deflate_vq = vqs[1];
  338. if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) {
  339. struct scatterlist sg;
  340. vb->stats_vq = vqs[2];
  341. /*
  342. * Prime this virtqueue with one buffer so the hypervisor can
  343. * use it to signal us later (it can't be broken yet!).
  344. */
  345. sg_init_one(&sg, vb->stats, sizeof vb->stats);
  346. if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL)
  347. < 0)
  348. BUG();
  349. virtqueue_kick(vb->stats_vq);
  350. }
  351. return 0;
  352. }
  353. #ifdef CONFIG_BALLOON_COMPACTION
  354. /*
  355. * virtballoon_migratepage - perform the balloon page migration on behalf of
  356. * a compation thread. (called under page lock)
  357. * @vb_dev_info: the balloon device
  358. * @newpage: page that will replace the isolated page after migration finishes.
  359. * @page : the isolated (old) page that is about to be migrated to newpage.
  360. * @mode : compaction mode -- not used for balloon page migration.
  361. *
  362. * After a ballooned page gets isolated by compaction procedures, this is the
  363. * function that performs the page migration on behalf of a compaction thread
  364. * The page migration for virtio balloon is done in a simple swap fashion which
  365. * follows these two macro steps:
  366. * 1) insert newpage into vb->pages list and update the host about it;
  367. * 2) update the host about the old page removed from vb->pages list;
  368. *
  369. * This function preforms the balloon page migration task.
  370. * Called through balloon_mapping->a_ops->migratepage
  371. */
  372. static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
  373. struct page *newpage, struct page *page, enum migrate_mode mode)
  374. {
  375. struct virtio_balloon *vb = container_of(vb_dev_info,
  376. struct virtio_balloon, vb_dev_info);
  377. unsigned long flags;
  378. /*
  379. * In order to avoid lock contention while migrating pages concurrently
  380. * to leak_balloon() or fill_balloon() we just give up the balloon_lock
  381. * this turn, as it is easier to retry the page migration later.
  382. * This also prevents fill_balloon() getting stuck into a mutex
  383. * recursion in the case it ends up triggering memory compaction
  384. * while it is attempting to inflate the ballon.
  385. */
  386. if (!mutex_trylock(&vb->balloon_lock))
  387. return -EAGAIN;
  388. get_page(newpage); /* balloon reference */
  389. /* balloon's page migration 1st step -- inflate "newpage" */
  390. spin_lock_irqsave(&vb_dev_info->pages_lock, flags);
  391. balloon_page_insert(vb_dev_info, newpage);
  392. vb_dev_info->isolated_pages--;
  393. __count_vm_event(BALLOON_MIGRATE);
  394. spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
  395. vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
  396. set_page_pfns(vb->pfns, newpage);
  397. tell_host(vb, vb->inflate_vq);
  398. /* balloon's page migration 2nd step -- deflate "page" */
  399. balloon_page_delete(page);
  400. vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
  401. set_page_pfns(vb->pfns, page);
  402. tell_host(vb, vb->deflate_vq);
  403. mutex_unlock(&vb->balloon_lock);
  404. put_page(page); /* balloon reference */
  405. return MIGRATEPAGE_SUCCESS;
  406. }
  407. #endif /* CONFIG_BALLOON_COMPACTION */
  408. static int virtballoon_probe(struct virtio_device *vdev)
  409. {
  410. struct virtio_balloon *vb;
  411. int err;
  412. if (!vdev->config->get) {
  413. dev_err(&vdev->dev, "%s failure: config access disabled\n",
  414. __func__);
  415. return -EINVAL;
  416. }
  417. vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
  418. if (!vb) {
  419. err = -ENOMEM;
  420. goto out;
  421. }
  422. vb->num_pages = 0;
  423. mutex_init(&vb->balloon_lock);
  424. init_waitqueue_head(&vb->config_change);
  425. init_waitqueue_head(&vb->acked);
  426. vb->vdev = vdev;
  427. vb->need_stats_update = 0;
  428. balloon_devinfo_init(&vb->vb_dev_info);
  429. #ifdef CONFIG_BALLOON_COMPACTION
  430. vb->vb_dev_info.migratepage = virtballoon_migratepage;
  431. #endif
  432. err = init_vqs(vb);
  433. if (err)
  434. goto out_free_vb;
  435. vb->nb.notifier_call = virtballoon_oom_notify;
  436. vb->nb.priority = VIRTBALLOON_OOM_NOTIFY_PRIORITY;
  437. err = register_oom_notifier(&vb->nb);
  438. if (err < 0)
  439. goto out_oom_notify;
  440. virtio_device_ready(vdev);
  441. vb->thread = kthread_run(balloon, vb, "vballoon");
  442. if (IS_ERR(vb->thread)) {
  443. err = PTR_ERR(vb->thread);
  444. goto out_del_vqs;
  445. }
  446. return 0;
  447. out_del_vqs:
  448. unregister_oom_notifier(&vb->nb);
  449. out_oom_notify:
  450. vdev->config->del_vqs(vdev);
  451. out_free_vb:
  452. kfree(vb);
  453. out:
  454. return err;
  455. }
  456. static void remove_common(struct virtio_balloon *vb)
  457. {
  458. /* There might be pages left in the balloon: free them. */
  459. while (vb->num_pages)
  460. leak_balloon(vb, vb->num_pages);
  461. update_balloon_size(vb);
  462. /* Now we reset the device so we can clean up the queues. */
  463. vb->vdev->config->reset(vb->vdev);
  464. vb->vdev->config->del_vqs(vb->vdev);
  465. }
  466. static void virtballoon_remove(struct virtio_device *vdev)
  467. {
  468. struct virtio_balloon *vb = vdev->priv;
  469. unregister_oom_notifier(&vb->nb);
  470. kthread_stop(vb->thread);
  471. remove_common(vb);
  472. kfree(vb);
  473. }
  474. #ifdef CONFIG_PM_SLEEP
  475. static int virtballoon_freeze(struct virtio_device *vdev)
  476. {
  477. struct virtio_balloon *vb = vdev->priv;
  478. /*
  479. * The kthread is already frozen by the PM core before this
  480. * function is called.
  481. */
  482. remove_common(vb);
  483. return 0;
  484. }
  485. static int virtballoon_restore(struct virtio_device *vdev)
  486. {
  487. struct virtio_balloon *vb = vdev->priv;
  488. int ret;
  489. ret = init_vqs(vdev->priv);
  490. if (ret)
  491. return ret;
  492. virtio_device_ready(vdev);
  493. fill_balloon(vb, towards_target(vb));
  494. update_balloon_size(vb);
  495. return 0;
  496. }
  497. #endif
  498. static unsigned int features[] = {
  499. VIRTIO_BALLOON_F_MUST_TELL_HOST,
  500. VIRTIO_BALLOON_F_STATS_VQ,
  501. VIRTIO_BALLOON_F_DEFLATE_ON_OOM,
  502. };
  503. static struct virtio_driver virtio_balloon_driver = {
  504. .feature_table = features,
  505. .feature_table_size = ARRAY_SIZE(features),
  506. .driver.name = KBUILD_MODNAME,
  507. .driver.owner = THIS_MODULE,
  508. .id_table = id_table,
  509. .probe = virtballoon_probe,
  510. .remove = virtballoon_remove,
  511. .config_changed = virtballoon_changed,
  512. #ifdef CONFIG_PM_SLEEP
  513. .freeze = virtballoon_freeze,
  514. .restore = virtballoon_restore,
  515. #endif
  516. };
  517. module_virtio_driver(virtio_balloon_driver);
  518. MODULE_DEVICE_TABLE(virtio, id_table);
  519. MODULE_DESCRIPTION("Virtio balloon driver");
  520. MODULE_LICENSE("GPL");