diff mbox series

[hmm,5/6] mm/hmm: remove the CONFIG_TRANSPARENT_HUGEPAGE #ifdef

Message ID 20200320164905.21722-6-jgg@ziepe.ca (mailing list archive)
State New, archived
Headers show
Series [hmm,1/6] mm/hmm: remove pgmap checking for devmap pages | expand

Commit Message

Jason Gunthorpe March 20, 2020, 4:49 p.m. UTC
From: Jason Gunthorpe <jgg@mellanox.com>

This code can be compiled when CONFIG_TRANSPARENT_HUGEPAGE is off, so
remove the ifdef.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 mm/hmm.c | 6 ------
 1 file changed, 6 deletions(-)

Comments

Christoph Hellwig March 21, 2020, 8:43 a.m. UTC | #1
On Fri, Mar 20, 2020 at 01:49:04PM -0300, Jason Gunthorpe wrote:
> From: Jason Gunthorpe <jgg@mellanox.com>
> 
> This code can be compiled when CONFIG_TRANSPARENT_HUGEPAGE is off, so
> remove the ifdef.

It can compile, but will the compiler optimize it away?  Seems like
both pmd_trans_huge and pmd_devmap are stubs for
!CONFIG_TRANSPARENT_HUGEPAGE, so yes.  But that should be mentioned
in the commit message.
Jason Gunthorpe March 23, 2020, 5:33 p.m. UTC | #2
On Sat, Mar 21, 2020 at 09:43:17AM +0100, Christoph Hellwig wrote:
> On Fri, Mar 20, 2020 at 01:49:04PM -0300, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe <jgg@mellanox.com>
> > 
> > This code can be compiled when CONFIG_TRANSPARENT_HUGEPAGE is off, so
> > remove the ifdef.
> 
> It can compile, but will the compiler optimize it away?  

Yes, the enclosing conditional:

if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) {

is statically false if !CONFIG_TRANSPARENT_HUGEPAGE

This is proven today, as the fallback stub is a function prototype
with no implementation:

-int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr,
-		unsigned long end, uint64_t *pfns, pmd_t pmd);

If the compiler wasn't optimizing the above branch we'd get link
failures.

Jason
diff mbox series

Patch

diff --git a/mm/hmm.c b/mm/hmm.c
index 7f77fb6e35cf78..a09b4908e9c81a 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -192,7 +192,6 @@  static inline uint64_t pmd_to_hmm_pfn_flags(struct hmm_range *range, pmd_t pmd)
 				range->flags[HMM_PFN_VALID];
 }
 
-#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 static int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr,
 		unsigned long end, uint64_t *pfns, pmd_t pmd)
 {
@@ -215,11 +214,6 @@  static int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr,
 	hmm_vma_walk->last = end;
 	return 0;
 }
-#else /* CONFIG_TRANSPARENT_HUGEPAGE */
-/* stub to allow the code below to compile */
-int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr,
-		unsigned long end, uint64_t *pfns, pmd_t pmd);
-#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 
 static inline bool hmm_is_device_private_entry(struct hmm_range *range,
 		swp_entry_t entry)