mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-01 06:46:35 +01:00
mm: introduce clear_pages() and clear_user_pages()
Introduce clear_pages(), to be overridden by architectures that support more efficient clearing of consecutive pages. Also introduce clear_user_pages(), however, we will not expect this function to be overridden anytime soon. As we do for clear_user_page(), define clear_user_pages() only if the architecture does not define clear_user_highpage(). That is because if the architecture does define clear_user_highpage(), then it likely needs some flushing magic when clearing user pages or highpages. This means we can get away without defining clear_user_pages(), since, much like its single page sibling, its only potential user is the generic clear_user_highpages() which should instead be using clear_user_highpage(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ankur Arora <[email protected]> Acked-by: David Hildenbrand (Red Hat) <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: "Borislav Petkov (AMD)" <[email protected]> Cc: Boris Ostrovsky <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Konrad Rzessutek Wilk <[email protected]> Cc: Lance Yang <[email protected]> Cc: "Liam R. Howlett" <[email protected]> Cc: Li Zhe <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Mateusz Guzik <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Raghavendra K T <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
1 parent
8e38607aa4
commit
62a9f5a85b
2 files changed
+53
No files matched your search
@@ -218,6 +218,39 @@ static inline void clear_user_page(void *addr, unsigned long vaddr, struct page
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* clear_user_pages() - clear a page range to be mapped to user space
|
||||
* @addr: start address
|
||||
* @vaddr: start address of the user mapping
|
||||
* @page: start page
|
||||
* @npages: number of pages
|
||||
*
|
||||
* Assumes that the region (@addr, +@npages) has been validated
|
||||
* already so this does no exception handling.
|
||||
*
|
||||
* If the architecture provides a clear_user_page(), use that;
|
||||
* otherwise, we can safely use clear_pages().
|
||||
*/
|
||||
static inline void clear_user_pages(void *addr, unsigned long vaddr,
|
||||
struct page *page, unsigned int npages)
|
||||
{
|
||||
|
||||
#ifdef clear_user_page
|
||||
do {
|
||||
clear_user_page(addr, vaddr, page);
|
||||
addr += PAGE_SIZE;
|
||||
vaddr += PAGE_SIZE;
|
||||
page++;
|
||||
} while (--npages);
|
||||
#else
|
||||
/*
|
||||
* Prefer clear_pages() to allow for architectural optimizations
|
||||
* when operating on contiguous page ranges.
|
||||
*/
|
||||
clear_pages(addr, npages);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* when CONFIG_HIGHMEM is not set these will be plain clear/copy_page */
|
||||
static inline void clear_user_highpage(struct page *page, unsigned long vaddr)
|
||||
{
|
||||
|
||||
@@ -4198,6 +4198,26 @@ static inline void clear_page_guard(struct zone *zone, struct page *page,
|
||||
unsigned int order) {}
|
||||
#endif /* CONFIG_DEBUG_PAGEALLOC */
|
||||
|
||||
#ifndef clear_pages
|
||||
/**
|
||||
* clear_pages() - clear a page range for kernel-internal use.
|
||||
* @addr: start address
|
||||
* @npages: number of pages
|
||||
*
|
||||
* Use clear_user_pages() instead when clearing a page range to be
|
||||
* mapped to user space.
|
||||
*
|
||||
* Does absolutely no exception handling.
|
||||
*/
|
||||
static inline void clear_pages(void *addr, unsigned int npages)
|
||||
{
|
||||
do {
|
||||
clear_page(addr);
|
||||
addr += PAGE_SIZE;
|
||||
} while (--npages);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __HAVE_ARCH_GATE_AREA
|
||||
extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm);
|
||||
extern int in_gate_area_no_mm(unsigned long addr);
|
||||
|
||||
Reference in new issue
Block a user