diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/hmm.h | 9 | ||||
-rw-r--r-- | include/linux/memremap.h | 22 | ||||
-rw-r--r-- | include/linux/migrate.h | 13 | ||||
-rw-r--r-- | include/linux/mm.h | 26 |
4 files changed, 43 insertions, 27 deletions
diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 8385e75356ca..28e14345bd8d 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h | |||
@@ -501,18 +501,21 @@ void hmm_device_put(struct hmm_device *hmm_device); | |||
501 | 501 | ||
502 | 502 | ||
503 | /* Below are for HMM internal use only! Not to be used by device driver! */ | 503 | /* Below are for HMM internal use only! Not to be used by device driver! */ |
504 | #if IS_ENABLED(CONFIG_HMM_MIRROR) | ||
504 | void hmm_mm_destroy(struct mm_struct *mm); | 505 | void hmm_mm_destroy(struct mm_struct *mm); |
505 | 506 | ||
506 | static inline void hmm_mm_init(struct mm_struct *mm) | 507 | static inline void hmm_mm_init(struct mm_struct *mm) |
507 | { | 508 | { |
508 | mm->hmm = NULL; | 509 | mm->hmm = NULL; |
509 | } | 510 | } |
511 | #else /* IS_ENABLED(CONFIG_HMM_MIRROR) */ | ||
512 | static inline void hmm_mm_destroy(struct mm_struct *mm) {} | ||
513 | static inline void hmm_mm_init(struct mm_struct *mm) {} | ||
514 | #endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */ | ||
510 | 515 | ||
511 | #else /* IS_ENABLED(CONFIG_HMM) */ | ||
512 | 516 | ||
513 | /* Below are for HMM internal use only! Not to be used by device driver! */ | 517 | #else /* IS_ENABLED(CONFIG_HMM) */ |
514 | static inline void hmm_mm_destroy(struct mm_struct *mm) {} | 518 | static inline void hmm_mm_destroy(struct mm_struct *mm) {} |
515 | static inline void hmm_mm_init(struct mm_struct *mm) {} | 519 | static inline void hmm_mm_init(struct mm_struct *mm) {} |
516 | |||
517 | #endif /* IS_ENABLED(CONFIG_HMM) */ | 520 | #endif /* IS_ENABLED(CONFIG_HMM) */ |
518 | #endif /* LINUX_HMM_H */ | 521 | #endif /* LINUX_HMM_H */ |
diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f8ee1c73ad2d..79f8ba7c3894 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h | |||
@@ -138,18 +138,6 @@ void *devm_memremap_pages(struct device *dev, struct resource *res, | |||
138 | struct dev_pagemap *find_dev_pagemap(resource_size_t phys); | 138 | struct dev_pagemap *find_dev_pagemap(resource_size_t phys); |
139 | 139 | ||
140 | static inline bool is_zone_device_page(const struct page *page); | 140 | static inline bool is_zone_device_page(const struct page *page); |
141 | |||
142 | static inline bool is_device_private_page(const struct page *page) | ||
143 | { | ||
144 | return is_zone_device_page(page) && | ||
145 | page->pgmap->type == MEMORY_DEVICE_PRIVATE; | ||
146 | } | ||
147 | |||
148 | static inline bool is_device_public_page(const struct page *page) | ||
149 | { | ||
150 | return is_zone_device_page(page) && | ||
151 | page->pgmap->type == MEMORY_DEVICE_PUBLIC; | ||
152 | } | ||
153 | #else | 141 | #else |
154 | static inline void *devm_memremap_pages(struct device *dev, | 142 | static inline void *devm_memremap_pages(struct device *dev, |
155 | struct resource *res, struct percpu_ref *ref, | 143 | struct resource *res, struct percpu_ref *ref, |
@@ -168,17 +156,21 @@ static inline struct dev_pagemap *find_dev_pagemap(resource_size_t phys) | |||
168 | { | 156 | { |
169 | return NULL; | 157 | return NULL; |
170 | } | 158 | } |
159 | #endif | ||
171 | 160 | ||
161 | #if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC) | ||
172 | static inline bool is_device_private_page(const struct page *page) | 162 | static inline bool is_device_private_page(const struct page *page) |
173 | { | 163 | { |
174 | return false; | 164 | return is_zone_device_page(page) && |
165 | page->pgmap->type == MEMORY_DEVICE_PRIVATE; | ||
175 | } | 166 | } |
176 | 167 | ||
177 | static inline bool is_device_public_page(const struct page *page) | 168 | static inline bool is_device_public_page(const struct page *page) |
178 | { | 169 | { |
179 | return false; | 170 | return is_zone_device_page(page) && |
171 | page->pgmap->type == MEMORY_DEVICE_PUBLIC; | ||
180 | } | 172 | } |
181 | #endif | 173 | #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ |
182 | 174 | ||
183 | /** | 175 | /** |
184 | * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn | 176 | * get_dev_pagemap() - take a new live reference on the dev_pagemap for @pfn |
diff --git a/include/linux/migrate.h b/include/linux/migrate.h index d4e6d12a0b40..643c7ae7d7b4 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h | |||
@@ -265,6 +265,7 @@ struct migrate_vma_ops { | |||
265 | void *private); | 265 | void *private); |
266 | }; | 266 | }; |
267 | 267 | ||
268 | #if defined(CONFIG_MIGRATE_VMA_HELPER) | ||
268 | int migrate_vma(const struct migrate_vma_ops *ops, | 269 | int migrate_vma(const struct migrate_vma_ops *ops, |
269 | struct vm_area_struct *vma, | 270 | struct vm_area_struct *vma, |
270 | unsigned long start, | 271 | unsigned long start, |
@@ -272,6 +273,18 @@ int migrate_vma(const struct migrate_vma_ops *ops, | |||
272 | unsigned long *src, | 273 | unsigned long *src, |
273 | unsigned long *dst, | 274 | unsigned long *dst, |
274 | void *private); | 275 | void *private); |
276 | #else | ||
277 | static inline int migrate_vma(const struct migrate_vma_ops *ops, | ||
278 | struct vm_area_struct *vma, | ||
279 | unsigned long start, | ||
280 | unsigned long end, | ||
281 | unsigned long *src, | ||
282 | unsigned long *dst, | ||
283 | void *private) | ||
284 | { | ||
285 | return -EINVAL; | ||
286 | } | ||
287 | #endif /* IS_ENABLED(CONFIG_MIGRATE_VMA_HELPER) */ | ||
275 | 288 | ||
276 | #endif /* CONFIG_MIGRATION */ | 289 | #endif /* CONFIG_MIGRATION */ |
277 | 290 | ||
diff --git a/include/linux/mm.h b/include/linux/mm.h index de66a1127db4..5195e272fc4a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -800,18 +800,27 @@ static inline bool is_zone_device_page(const struct page *page) | |||
800 | } | 800 | } |
801 | #endif | 801 | #endif |
802 | 802 | ||
803 | #if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC) | 803 | #if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC) |
804 | void put_zone_device_private_or_public_page(struct page *page); | 804 | void put_zone_device_private_or_public_page(struct page *page); |
805 | #else | 805 | DECLARE_STATIC_KEY_FALSE(device_private_key); |
806 | #define IS_HMM_ENABLED static_branch_unlikely(&device_private_key) | ||
807 | static inline bool is_device_private_page(const struct page *page); | ||
808 | static inline bool is_device_public_page(const struct page *page); | ||
809 | #else /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ | ||
806 | static inline void put_zone_device_private_or_public_page(struct page *page) | 810 | static inline void put_zone_device_private_or_public_page(struct page *page) |
807 | { | 811 | { |
808 | } | 812 | } |
813 | #define IS_HMM_ENABLED 0 | ||
814 | static inline bool is_device_private_page(const struct page *page) | ||
815 | { | ||
816 | return false; | ||
817 | } | ||
818 | static inline bool is_device_public_page(const struct page *page) | ||
819 | { | ||
820 | return false; | ||
821 | } | ||
809 | #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ | 822 | #endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */ |
810 | 823 | ||
811 | static inline bool is_device_private_page(const struct page *page); | ||
812 | static inline bool is_device_public_page(const struct page *page); | ||
813 | |||
814 | DECLARE_STATIC_KEY_FALSE(device_private_key); | ||
815 | 824 | ||
816 | static inline void get_page(struct page *page) | 825 | static inline void get_page(struct page *page) |
817 | { | 826 | { |
@@ -834,9 +843,8 @@ static inline void put_page(struct page *page) | |||
834 | * free and we need to inform the device driver through callback. See | 843 | * free and we need to inform the device driver through callback. See |
835 | * include/linux/memremap.h and HMM for details. | 844 | * include/linux/memremap.h and HMM for details. |
836 | */ | 845 | */ |
837 | if (static_branch_unlikely(&device_private_key) && | 846 | if (IS_HMM_ENABLED && unlikely(is_device_private_page(page) || |
838 | unlikely(is_device_private_page(page) || | 847 | unlikely(is_device_public_page(page)))) { |
839 | is_device_public_page(page))) { | ||
840 | put_zone_device_private_or_public_page(page); | 848 | put_zone_device_private_or_public_page(page); |
841 | return; | 849 | return; |
842 | } | 850 | } |