| .. | .. |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Common interface definitions for making balloon pages movable by compaction. |
|---|
| 6 | 6 | * |
|---|
| 7 | | - * Despite being perfectly possible to perform ballooned pages migration, they |
|---|
| 8 | | - * make a special corner case to compaction scans because balloon pages are not |
|---|
| 9 | | - * enlisted at any LRU list like the other pages we do compact / migrate. |
|---|
| 7 | + * Balloon page migration makes use of the general non-lru movable page |
|---|
| 8 | + * feature. |
|---|
| 9 | + * |
|---|
| 10 | + * page->private is used to reference the responsible balloon device. |
|---|
| 11 | + * page->mapping is used in context of non-lru page migration to reference |
|---|
| 12 | + * the address space operations for page isolation/migration/compaction. |
|---|
| 10 | 13 | * |
|---|
| 11 | 14 | * As the page isolation scanning step a compaction thread does is a lockless |
|---|
| 12 | 15 | * procedure (from a page standpoint), it might bring some racy situations while |
|---|
| 13 | 16 | * performing balloon page compaction. In order to sort out these racy scenarios |
|---|
| 14 | 17 | * and safely perform balloon's page compaction and migration we must, always, |
|---|
| 15 | | - * ensure following these three simple rules: |
|---|
| 18 | + * ensure following these simple rules: |
|---|
| 16 | 19 | * |
|---|
| 17 | 20 | * i. when updating a balloon's page ->mapping element, strictly do it under |
|---|
| 18 | 21 | * the following lock order, independently of the far superior |
|---|
| .. | .. |
|---|
| 21 | 24 | * +--spin_lock_irq(&b_dev_info->pages_lock); |
|---|
| 22 | 25 | * ... page->mapping updates here ... |
|---|
| 23 | 26 | * |
|---|
| 24 | | - * ii. before isolating or dequeueing a balloon page from the balloon device |
|---|
| 25 | | - * pages list, the page reference counter must be raised by one and the |
|---|
| 26 | | - * extra refcount must be dropped when the page is enqueued back into |
|---|
| 27 | | - * the balloon device page list, thus a balloon page keeps its reference |
|---|
| 28 | | - * counter raised only while it is under our special handling; |
|---|
| 29 | | - * |
|---|
| 30 | | - * iii. after the lockless scan step have selected a potential balloon page for |
|---|
| 31 | | - * isolation, re-test the PageBalloon mark and the PagePrivate flag |
|---|
| 32 | | - * under the proper page lock, to ensure isolating a valid balloon page |
|---|
| 33 | | - * (not yet isolated, nor under release procedure) |
|---|
| 34 | | - * |
|---|
| 35 | | - * iv. isolation or dequeueing procedure must clear PagePrivate flag under |
|---|
| 36 | | - * page lock together with removing page from balloon device page list. |
|---|
| 27 | + * ii. isolation or dequeueing procedure must remove the page from balloon |
|---|
| 28 | + * device page list under b_dev_info->pages_lock. |
|---|
| 37 | 29 | * |
|---|
| 38 | 30 | * The functions provided by this interface are placed to help on coping with |
|---|
| 39 | 31 | * the aforementioned balloon page corner case, as well as to ensure the simple |
|---|
| .. | .. |
|---|
| 72 | 64 | extern void balloon_page_enqueue(struct balloon_dev_info *b_dev_info, |
|---|
| 73 | 65 | struct page *page); |
|---|
| 74 | 66 | extern struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info); |
|---|
| 67 | +extern size_t balloon_page_list_enqueue(struct balloon_dev_info *b_dev_info, |
|---|
| 68 | + struct list_head *pages); |
|---|
| 69 | +extern size_t balloon_page_list_dequeue(struct balloon_dev_info *b_dev_info, |
|---|
| 70 | + struct list_head *pages, size_t n_req_pages); |
|---|
| 75 | 71 | |
|---|
| 76 | 72 | static inline void balloon_devinfo_init(struct balloon_dev_info *balloon) |
|---|
| 77 | 73 | { |
|---|
| .. | .. |
|---|
| 103 | 99 | static inline void balloon_page_insert(struct balloon_dev_info *balloon, |
|---|
| 104 | 100 | struct page *page) |
|---|
| 105 | 101 | { |
|---|
| 106 | | - __SetPageBalloon(page); |
|---|
| 102 | + __SetPageOffline(page); |
|---|
| 107 | 103 | __SetPageMovable(page, balloon->inode->i_mapping); |
|---|
| 108 | 104 | set_page_private(page, (unsigned long)balloon); |
|---|
| 109 | 105 | list_add(&page->lru, &balloon->pages); |
|---|
| .. | .. |
|---|
| 119 | 115 | */ |
|---|
| 120 | 116 | static inline void balloon_page_delete(struct page *page) |
|---|
| 121 | 117 | { |
|---|
| 122 | | - __ClearPageBalloon(page); |
|---|
| 118 | + __ClearPageOffline(page); |
|---|
| 123 | 119 | __ClearPageMovable(page); |
|---|
| 124 | 120 | set_page_private(page, 0); |
|---|
| 125 | 121 | /* |
|---|
| .. | .. |
|---|
| 149 | 145 | static inline void balloon_page_insert(struct balloon_dev_info *balloon, |
|---|
| 150 | 146 | struct page *page) |
|---|
| 151 | 147 | { |
|---|
| 152 | | - __SetPageBalloon(page); |
|---|
| 148 | + __SetPageOffline(page); |
|---|
| 153 | 149 | list_add(&page->lru, &balloon->pages); |
|---|
| 154 | 150 | } |
|---|
| 155 | 151 | |
|---|
| 156 | 152 | static inline void balloon_page_delete(struct page *page) |
|---|
| 157 | 153 | { |
|---|
| 158 | | - __ClearPageBalloon(page); |
|---|
| 154 | + __ClearPageOffline(page); |
|---|
| 159 | 155 | list_del(&page->lru); |
|---|
| 160 | | -} |
|---|
| 161 | | - |
|---|
| 162 | | -static inline bool __is_movable_balloon_page(struct page *page) |
|---|
| 163 | | -{ |
|---|
| 164 | | - return false; |
|---|
| 165 | | -} |
|---|
| 166 | | - |
|---|
| 167 | | -static inline bool balloon_page_movable(struct page *page) |
|---|
| 168 | | -{ |
|---|
| 169 | | - return false; |
|---|
| 170 | | -} |
|---|
| 171 | | - |
|---|
| 172 | | -static inline bool isolated_balloon_page(struct page *page) |
|---|
| 173 | | -{ |
|---|
| 174 | | - return false; |
|---|
| 175 | 156 | } |
|---|
| 176 | 157 | |
|---|
| 177 | 158 | static inline bool balloon_page_isolate(struct page *page) |
|---|