hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/include/linux/balloon_compaction.h
....@@ -4,15 +4,18 @@
44 *
55 * Common interface definitions for making balloon pages movable by compaction.
66 *
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.
1013 *
1114 * As the page isolation scanning step a compaction thread does is a lockless
1215 * procedure (from a page standpoint), it might bring some racy situations while
1316 * performing balloon page compaction. In order to sort out these racy scenarios
1417 * 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:
1619 *
1720 * i. when updating a balloon's page ->mapping element, strictly do it under
1821 * the following lock order, independently of the far superior
....@@ -21,19 +24,8 @@
2124 * +--spin_lock_irq(&b_dev_info->pages_lock);
2225 * ... page->mapping updates here ...
2326 *
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.
3729 *
3830 * The functions provided by this interface are placed to help on coping with
3931 * the aforementioned balloon page corner case, as well as to ensure the simple
....@@ -72,6 +64,10 @@
7264 extern void balloon_page_enqueue(struct balloon_dev_info *b_dev_info,
7365 struct page *page);
7466 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);
7571
7672 static inline void balloon_devinfo_init(struct balloon_dev_info *balloon)
7773 {
....@@ -103,7 +99,7 @@
10399 static inline void balloon_page_insert(struct balloon_dev_info *balloon,
104100 struct page *page)
105101 {
106
- __SetPageBalloon(page);
102
+ __SetPageOffline(page);
107103 __SetPageMovable(page, balloon->inode->i_mapping);
108104 set_page_private(page, (unsigned long)balloon);
109105 list_add(&page->lru, &balloon->pages);
....@@ -119,7 +115,7 @@
119115 */
120116 static inline void balloon_page_delete(struct page *page)
121117 {
122
- __ClearPageBalloon(page);
118
+ __ClearPageOffline(page);
123119 __ClearPageMovable(page);
124120 set_page_private(page, 0);
125121 /*
....@@ -149,29 +145,14 @@
149145 static inline void balloon_page_insert(struct balloon_dev_info *balloon,
150146 struct page *page)
151147 {
152
- __SetPageBalloon(page);
148
+ __SetPageOffline(page);
153149 list_add(&page->lru, &balloon->pages);
154150 }
155151
156152 static inline void balloon_page_delete(struct page *page)
157153 {
158
- __ClearPageBalloon(page);
154
+ __ClearPageOffline(page);
159155 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;
175156 }
176157
177158 static inline bool balloon_page_isolate(struct page *page)