@@ -106,13 +106,27 @@ struct page {
pgoff_t index; /* Our offset within mapping. */
unsigned long share; /* share count for fsdax */
};
- /**
- * @private: Mapping-private opaque data.
- * Usually used for buffer_heads if PagePrivate.
- * Used for swp_entry_t if swapcache flag set.
- * Indicates order in the buddy system if PageBuddy.
- */
- unsigned long private;
+ union {
+ /**
+ * @private: Mapping-private opaque data.
+ * Usually used for buffer_heads if PagePrivate.
+ * Used for swp_entry_t if swapcache flag set.
+ * Indicates order in the buddy system if PageBuddy.
+ */
+ unsigned long private;
+ struct {
+ /*
+ * Indicates order in the buddy system if PageBuddy.
+ */
+ unsigned short order;
+
+ /*
+ * For tracking need of tlb flush,
+ * by luf(lazy unmap flush).
+ */
+ unsigned short luf_key;
+ };
+ };
};
struct { /* page_pool used by netstack */
/**
@@ -537,6 +551,20 @@ static inline void set_page_private(struct page *page, unsigned long private)
page->private = private;
}
+#define page_buddy_order(page) ((page)->order)
+
+static inline void set_page_buddy_order(struct page *page, unsigned int order)
+{
+ page->order = (unsigned short)order;
+}
+
+#define page_luf_key(page) ((page)->luf_key)
+
+static inline void set_page_luf_key(struct page *page, unsigned short luf_key)
+{
+ page->luf_key = luf_key;
+}
+
static inline void *folio_get_private(struct folio *folio)
{
return folio->private;
@@ -541,7 +541,7 @@ struct alloc_context {
static inline unsigned int buddy_order(struct page *page)
{
/* PageBuddy() must be checked by the caller */
- return page_private(page);
+ return page_buddy_order(page);
}
/*
@@ -555,7 +555,7 @@ static inline unsigned int buddy_order(struct page *page)
* times, potentially observing different values in the tests and the actual
* use of the result.
*/
-#define buddy_order_unsafe(page) READ_ONCE(page_private(page))
+#define buddy_order_unsafe(page) READ_ONCE(page_buddy_order(page))
/*
* This function checks whether a page is free && is the buddy
@@ -576,7 +576,7 @@ void prep_compound_page(struct page *page, unsigned int order)
static inline void set_buddy_order(struct page *page, unsigned int order)
{
- set_page_private(page, order);
+ set_page_buddy_order(page, order);
__SetPageBuddy(page);
}
Functionally, no change. This is a preparation for luf mechanism that tracks need of tlb flush for each page residing in buddy. Since the private field in struct page is used only to store page order in buddy, ranging from 0 to MAX_PAGE_ORDER, that can be covered with unsigned short. So splitted it into two smaller ones, order and luf_key, so that the both can be used in buddy at the same time. Signed-off-by: Byungchul Park <byungchul@sk.com> --- include/linux/mm_types.h | 42 +++++++++++++++++++++++++++++++++------- mm/internal.h | 4 ++-- mm/page_alloc.c | 2 +- 3 files changed, 38 insertions(+), 10 deletions(-)