migrate.h (dd19e6d8ffaa1289d75d7833de97faf1b6b2c8e4) | migrate.h (68f2736a858324c3ec852f6c2cddd9d1c777357d) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_MIGRATE_H 3#define _LINUX_MIGRATE_H 4 5#include <linux/mm.h> 6#include <linux/mempolicy.h> 7#include <linux/migrate_mode.h> 8#include <linux/hugetlb.h> --- 5 unchanged lines hidden (view full) --- 14 15/* 16 * Return values from addresss_space_operations.migratepage(): 17 * - negative errno on page migration failure; 18 * - zero on page migration success; 19 */ 20#define MIGRATEPAGE_SUCCESS 0 21 | 1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_MIGRATE_H 3#define _LINUX_MIGRATE_H 4 5#include <linux/mm.h> 6#include <linux/mempolicy.h> 7#include <linux/migrate_mode.h> 8#include <linux/hugetlb.h> --- 5 unchanged lines hidden (view full) --- 14 15/* 16 * Return values from addresss_space_operations.migratepage(): 17 * - negative errno on page migration failure; 18 * - zero on page migration success; 19 */ 20#define MIGRATEPAGE_SUCCESS 0 21 |
22/** 23 * struct movable_operations - Driver page migration 24 * @isolate_page: 25 * The VM calls this function to prepare the page to be moved. The page 26 * is locked and the driver should not unlock it. The driver should 27 * return ``true`` if the page is movable and ``false`` if it is not 28 * currently movable. After this function returns, the VM uses the 29 * page->lru field, so the driver must preserve any information which 30 * is usually stored here. 31 * 32 * @migrate_page: 33 * After isolation, the VM calls this function with the isolated 34 * @src page. The driver should copy the contents of the 35 * @src page to the @dst page and set up the fields of @dst page. 36 * Both pages are locked. 37 * If page migration is successful, the driver should call 38 * __ClearPageMovable(@src) and return MIGRATEPAGE_SUCCESS. 39 * If the driver cannot migrate the page at the moment, it can return 40 * -EAGAIN. The VM interprets this as a temporary migration failure and 41 * will retry it later. Any other error value is a permanent migration 42 * failure and migration will not be retried. 43 * The driver shouldn't touch the @src->lru field while in the 44 * migrate_page() function. It may write to @dst->lru. 45 * 46 * @putback_page: 47 * If migration fails on the isolated page, the VM informs the driver 48 * that the page is no longer a candidate for migration by calling 49 * this function. The driver should put the isolated page back into 50 * its own data structure. 51 */ 52struct movable_operations { 53 bool (*isolate_page)(struct page *, isolate_mode_t); 54 int (*migrate_page)(struct page *dst, struct page *src, 55 enum migrate_mode); 56 void (*putback_page)(struct page *); 57}; 58 |
|
22/* Defined in mm/debug.c: */ 23extern const char *migrate_reason_names[MR_TYPES]; 24 25#ifdef CONFIG_MIGRATION 26 27extern void putback_movable_pages(struct list_head *l); 28extern int migrate_page(struct address_space *mapping, 29 struct page *newpage, struct page *page, --- 56 unchanged lines hidden (view full) --- 86static inline int next_demotion_node(int node) 87{ 88 return NUMA_NO_NODE; 89} 90#define numa_demotion_enabled false 91#endif 92 93#ifdef CONFIG_COMPACTION | 59/* Defined in mm/debug.c: */ 60extern const char *migrate_reason_names[MR_TYPES]; 61 62#ifdef CONFIG_MIGRATION 63 64extern void putback_movable_pages(struct list_head *l); 65extern int migrate_page(struct address_space *mapping, 66 struct page *newpage, struct page *page, --- 56 unchanged lines hidden (view full) --- 123static inline int next_demotion_node(int node) 124{ 125 return NUMA_NO_NODE; 126} 127#define numa_demotion_enabled false 128#endif 129 130#ifdef CONFIG_COMPACTION |
94extern int PageMovable(struct page *page); 95extern void __SetPageMovable(struct page *page, struct address_space *mapping); 96extern void __ClearPageMovable(struct page *page); | 131bool PageMovable(struct page *page); 132void __SetPageMovable(struct page *page, const struct movable_operations *ops); 133void __ClearPageMovable(struct page *page); |
97#else | 134#else |
98static inline int PageMovable(struct page *page) { return 0; } | 135static inline bool PageMovable(struct page *page) { return false; } |
99static inline void __SetPageMovable(struct page *page, | 136static inline void __SetPageMovable(struct page *page, |
100 struct address_space *mapping) | 137 const struct movable_operations *ops) |
101{ 102} 103static inline void __ClearPageMovable(struct page *page) 104{ 105} 106#endif 107 108static inline bool folio_test_movable(struct folio *folio) 109{ 110 return PageMovable(&folio->page); 111} 112 | 138{ 139} 140static inline void __ClearPageMovable(struct page *page) 141{ 142} 143#endif 144 145static inline bool folio_test_movable(struct folio *folio) 146{ 147 return PageMovable(&folio->page); 148} 149 |
150static inline 151const struct movable_operations *page_movable_ops(struct page *page) 152{ 153 VM_BUG_ON(!__PageMovable(page)); 154 155 return (const struct movable_operations *) 156 ((unsigned long)page->mapping - PAGE_MAPPING_MOVABLE); 157} 158 |
|
113#ifdef CONFIG_NUMA_BALANCING 114extern int migrate_misplaced_page(struct page *page, 115 struct vm_area_struct *vma, int node); 116#else 117static inline int migrate_misplaced_page(struct page *page, 118 struct vm_area_struct *vma, int node) 119{ 120 return -EAGAIN; /* can't migrate now */ --- 22 unchanged lines hidden (view full) --- 143static inline unsigned long migrate_pfn(unsigned long pfn) 144{ 145 return (pfn << MIGRATE_PFN_SHIFT) | MIGRATE_PFN_VALID; 146} 147 148enum migrate_vma_direction { 149 MIGRATE_VMA_SELECT_SYSTEM = 1 << 0, 150 MIGRATE_VMA_SELECT_DEVICE_PRIVATE = 1 << 1, | 159#ifdef CONFIG_NUMA_BALANCING 160extern int migrate_misplaced_page(struct page *page, 161 struct vm_area_struct *vma, int node); 162#else 163static inline int migrate_misplaced_page(struct page *page, 164 struct vm_area_struct *vma, int node) 165{ 166 return -EAGAIN; /* can't migrate now */ --- 22 unchanged lines hidden (view full) --- 189static inline unsigned long migrate_pfn(unsigned long pfn) 190{ 191 return (pfn << MIGRATE_PFN_SHIFT) | MIGRATE_PFN_VALID; 192} 193 194enum migrate_vma_direction { 195 MIGRATE_VMA_SELECT_SYSTEM = 1 << 0, 196 MIGRATE_VMA_SELECT_DEVICE_PRIVATE = 1 << 1, |
151 MIGRATE_VMA_SELECT_DEVICE_COHERENT = 1 << 2, | |
152}; 153 154struct migrate_vma { 155 struct vm_area_struct *vma; 156 /* 157 * Both src and dst array must be big enough for 158 * (end - start) >> PAGE_SHIFT entries. 159 * --- 29 unchanged lines hidden --- | 197}; 198 199struct migrate_vma { 200 struct vm_area_struct *vma; 201 /* 202 * Both src and dst array must be big enough for 203 * (end - start) >> PAGE_SHIFT entries. 204 * --- 29 unchanged lines hidden --- |