From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 14 Jun 2017 14:45:20 +0200 From: Michal Hocko To: Dan Williams Cc: akpm@linux-foundation.org, Jan Kara , linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ross Zwisler , hch@lst.de, "Kirill A. Shutemov" Subject: Re: [PATCH v2 1/2] mm: improve readability of transparent_hugepage_enabled() Message-ID: <20170614124520.GA8537@dhcp22.suse.cz> References: <149739530052.20686.9000645746376519779.stgit@dwillia2-desk3.amr.corp.intel.com> <149739530612.20686.14760671150202647861.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <149739530612.20686.14760671150202647861.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org List-ID: On Tue 13-06-17 16:08:26, Dan Williams wrote: > Turn the macro into a static inline and rewrite the condition checks for > better readability in preparation for adding another condition. > > Cc: Jan Kara > Cc: Andrew Morton > Reviewed-by: Ross Zwisler > [ross: fix logic to make conversion equivalent] > Acked-by: "Kirill A. Shutemov" > Signed-off-by: Dan Williams This is really a nice deobfuscation! Please note this will conflict with http://lkml.kernel.org/r/1496415802-30944-1-git-send-email-rppt@linux.vnet.ibm.com Trivial to resolve but I thought I should give you a heads up. Acked-by: Michal Hocko > --- > include/linux/huge_mm.h | 32 +++++++++++++++++++++----------- > 1 file changed, 21 insertions(+), 11 deletions(-) > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h > index a3762d49ba39..c8119e856eb1 100644 > --- a/include/linux/huge_mm.h > +++ b/include/linux/huge_mm.h > @@ -85,14 +85,23 @@ extern struct kobj_attribute shmem_enabled_attr; > > extern bool is_vma_temporary_stack(struct vm_area_struct *vma); > > -#define transparent_hugepage_enabled(__vma) \ > - ((transparent_hugepage_flags & \ > - (1< - (transparent_hugepage_flags & \ > - (1< - ((__vma)->vm_flags & VM_HUGEPAGE))) && \ > - !((__vma)->vm_flags & VM_NOHUGEPAGE) && \ > - !is_vma_temporary_stack(__vma)) > +extern unsigned long transparent_hugepage_flags; > + > +static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) > +{ > + if ((vma->vm_flags & VM_NOHUGEPAGE) || is_vma_temporary_stack(vma)) > + 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() \ > (transparent_hugepage_flags & \ > (1< @@ -104,8 +113,6 @@ extern bool is_vma_temporary_stack(struct vm_area_struct *vma); > #define transparent_hugepage_debug_cow() 0 > #endif /* CONFIG_DEBUG_VM */ > > -extern unsigned long transparent_hugepage_flags; > - > extern unsigned long thp_get_unmapped_area(struct file *filp, > unsigned long addr, unsigned long len, unsigned long pgoff, > unsigned long flags); > @@ -223,7 +230,10 @@ void mm_put_huge_zero_page(struct mm_struct *mm); > > #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) {} > > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org