| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | 2 | #include <linux/init.h> |
|---|
| 3 | | -#include <linux/bootmem.h> |
|---|
| 3 | +#include <linux/memblock.h> |
|---|
| 4 | 4 | #include <linux/fs.h> |
|---|
| 5 | 5 | #include <linux/sysfs.h> |
|---|
| 6 | 6 | #include <linux/kobject.h> |
|---|
| 7 | +#include <linux/memory_hotplug.h> |
|---|
| 7 | 8 | #include <linux/mm.h> |
|---|
| 8 | 9 | #include <linux/mmzone.h> |
|---|
| 9 | 10 | #include <linux/pagemap.h> |
|---|
| .. | .. |
|---|
| 30 | 31 | */ |
|---|
| 31 | 32 | static struct page *page_idle_get_page(unsigned long pfn) |
|---|
| 32 | 33 | { |
|---|
| 33 | | - struct page *page; |
|---|
| 34 | | - struct zone *zone; |
|---|
| 34 | + struct page *page = pfn_to_online_page(pfn); |
|---|
| 35 | + pg_data_t *pgdat; |
|---|
| 35 | 36 | |
|---|
| 36 | | - if (!pfn_valid(pfn)) |
|---|
| 37 | | - return NULL; |
|---|
| 38 | | - |
|---|
| 39 | | - page = pfn_to_page(pfn); |
|---|
| 40 | 37 | if (!page || !PageLRU(page) || |
|---|
| 41 | 38 | !get_page_unless_zero(page)) |
|---|
| 42 | 39 | return NULL; |
|---|
| 43 | 40 | |
|---|
| 44 | | - zone = page_zone(page); |
|---|
| 45 | | - spin_lock_irq(zone_lru_lock(zone)); |
|---|
| 41 | + pgdat = page_pgdat(page); |
|---|
| 42 | + spin_lock_irq(&pgdat->lru_lock); |
|---|
| 46 | 43 | if (unlikely(!PageLRU(page))) { |
|---|
| 47 | 44 | put_page(page); |
|---|
| 48 | 45 | page = NULL; |
|---|
| 49 | 46 | } |
|---|
| 50 | | - spin_unlock_irq(zone_lru_lock(zone)); |
|---|
| 47 | + spin_unlock_irq(&pgdat->lru_lock); |
|---|
| 51 | 48 | return page; |
|---|
| 52 | 49 | } |
|---|
| 53 | 50 | |
|---|
| .. | .. |
|---|
| 95 | 92 | static void page_idle_clear_pte_refs(struct page *page) |
|---|
| 96 | 93 | { |
|---|
| 97 | 94 | /* |
|---|
| 98 | | - * Since rwc.arg is unused, rwc is effectively immutable, so we |
|---|
| 99 | | - * can make it static const to save some cycles and stack. |
|---|
| 95 | + * Since rwc.try_lock is unused, rwc is effectively immutable, so we |
|---|
| 96 | + * can make it static to save some cycles and stack. |
|---|
| 100 | 97 | */ |
|---|
| 101 | | - static const struct rmap_walk_control rwc = { |
|---|
| 98 | + static struct rmap_walk_control rwc = { |
|---|
| 102 | 99 | .rmap_one = page_idle_clear_pte_refs_one, |
|---|
| 103 | 100 | .anon_lock = page_lock_anon_vma_read, |
|---|
| 104 | 101 | }; |
|---|
| .. | .. |
|---|
| 213 | 210 | .bin_attrs = page_idle_bin_attrs, |
|---|
| 214 | 211 | .name = "page_idle", |
|---|
| 215 | 212 | }; |
|---|
| 216 | | - |
|---|
| 217 | | -#ifndef CONFIG_64BIT |
|---|
| 218 | | -static bool need_page_idle(void) |
|---|
| 219 | | -{ |
|---|
| 220 | | - return true; |
|---|
| 221 | | -} |
|---|
| 222 | | -struct page_ext_operations page_idle_ops = { |
|---|
| 223 | | - .need = need_page_idle, |
|---|
| 224 | | -}; |
|---|
| 225 | | -#endif |
|---|
| 226 | 213 | |
|---|
| 227 | 214 | static int __init page_idle_init(void) |
|---|
| 228 | 215 | { |
|---|