forked from mirrors/linux
		
	mm: improve readability of transparent_hugepage_enabled()
Turn the macro into a static inline and rewrite the condition checks for better readability in preparation for adding another condition. [ross.zwisler@linux.intel.com: fix logic to make conversion equivalent] [akpm@linux-foundation.org: resolve vs mm-make-pr_set_thp_disable-immediately-active.patch] [akpm@linux-foundation.org: include coredump.h for MMF_DISABLE_THP] Link: http://lkml.kernel.org/r/149739530612.20686.14760671150202647861.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Acked-by: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									7ab0e50ad0
								
							
						
					
					
						commit
						16981d7635
					
				
					 1 changed files with 29 additions and 12 deletions
				
			
		| 
						 | 
					@ -1,6 +1,8 @@
 | 
				
			||||||
#ifndef _LINUX_HUGE_MM_H
 | 
					#ifndef _LINUX_HUGE_MM_H
 | 
				
			||||||
#define _LINUX_HUGE_MM_H
 | 
					#define _LINUX_HUGE_MM_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <linux/sched/coredump.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern int do_huge_pmd_anonymous_page(struct vm_fault *vmf);
 | 
					extern int do_huge_pmd_anonymous_page(struct vm_fault *vmf);
 | 
				
			||||||
extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 | 
					extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 | 
				
			||||||
			 pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
 | 
								 pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
 | 
				
			||||||
| 
						 | 
					@ -85,15 +87,29 @@ extern struct kobj_attribute shmem_enabled_attr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern bool is_vma_temporary_stack(struct vm_area_struct *vma);
 | 
					extern bool is_vma_temporary_stack(struct vm_area_struct *vma);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define transparent_hugepage_enabled(__vma)				\
 | 
					extern unsigned long transparent_hugepage_flags;
 | 
				
			||||||
	((transparent_hugepage_flags &					\
 | 
					
 | 
				
			||||||
	  (1<<TRANSPARENT_HUGEPAGE_FLAG) ||				\
 | 
					static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma)
 | 
				
			||||||
	  (transparent_hugepage_flags &					\
 | 
					{
 | 
				
			||||||
	   (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG) &&			\
 | 
						if (vma->vm_flags & VM_NOHUGEPAGE)
 | 
				
			||||||
	   ((__vma)->vm_flags & VM_HUGEPAGE))) &&			\
 | 
							return false;
 | 
				
			||||||
	 !((__vma)->vm_flags & VM_NOHUGEPAGE) &&			\
 | 
					
 | 
				
			||||||
	 !test_bit(MMF_DISABLE_THP, &(__vma)->vm_mm->flags) &&		\
 | 
						if (is_vma_temporary_stack(vma))
 | 
				
			||||||
	 !is_vma_temporary_stack(__vma))
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG))
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (transparent_hugepage_flags &
 | 
				
			||||||
 | 
									(1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG))
 | 
				
			||||||
 | 
							return !!(vma->vm_flags & VM_HUGEPAGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define transparent_hugepage_use_zero_page()				\
 | 
					#define transparent_hugepage_use_zero_page()				\
 | 
				
			||||||
	(transparent_hugepage_flags &					\
 | 
						(transparent_hugepage_flags &					\
 | 
				
			||||||
	 (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG))
 | 
						 (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG))
 | 
				
			||||||
| 
						 | 
					@ -105,8 +121,6 @@ extern bool is_vma_temporary_stack(struct vm_area_struct *vma);
 | 
				
			||||||
#define transparent_hugepage_debug_cow() 0
 | 
					#define transparent_hugepage_debug_cow() 0
 | 
				
			||||||
#endif /* CONFIG_DEBUG_VM */
 | 
					#endif /* CONFIG_DEBUG_VM */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern unsigned long transparent_hugepage_flags;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern unsigned long thp_get_unmapped_area(struct file *filp,
 | 
					extern unsigned long thp_get_unmapped_area(struct file *filp,
 | 
				
			||||||
		unsigned long addr, unsigned long len, unsigned long pgoff,
 | 
							unsigned long addr, unsigned long len, unsigned long pgoff,
 | 
				
			||||||
		unsigned long flags);
 | 
							unsigned long flags);
 | 
				
			||||||
| 
						 | 
					@ -225,7 +239,10 @@ void mm_put_huge_zero_page(struct mm_struct *mm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define hpage_nr_pages(x) 1
 | 
					#define hpage_nr_pages(x) 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define transparent_hugepage_enabled(__vma) 0
 | 
					static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void prep_transhuge_page(struct page *page) {}
 | 
					static inline void prep_transhuge_page(struct page *page) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue