diff mbox series

[1/9] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h

Message ID 20210408234327.624367-2-axelrasmussen@google.com
State New
Headers show
Series [1/9] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h | expand

Commit Message

Axel Rasmussen April 8, 2021, 11:43 p.m. UTC
Minimizing header file inclusion is desirable. In this case, we can do
so just by forward declaring the enumeration our signature relies upon.

Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
---
 include/linux/hugetlb.h | 5 ++++-
 mm/hugetlb.c            | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Peter Xu April 12, 2021, 11:47 p.m. UTC | #1
On Thu, Apr 08, 2021 at 04:43:19PM -0700, Axel Rasmussen wrote:
> Minimizing header file inclusion is desirable. In this case, we can do

> so just by forward declaring the enumeration our signature relies upon.

> 

> Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>

> ---

>  include/linux/hugetlb.h | 5 ++++-

>  mm/hugetlb.c            | 1 +

>  2 files changed, 5 insertions(+), 1 deletion(-)

> 

> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h

> index 1d3246b31a41..dfb749eaf348 100644

> --- a/include/linux/hugetlb.h

> +++ b/include/linux/hugetlb.h

> @@ -11,7 +11,6 @@

>  #include <linux/kref.h>

>  #include <linux/pgtable.h>

>  #include <linux/gfp.h>

> -#include <linux/userfaultfd_k.h>

>  

>  struct ctl_table;

>  struct user_struct;

> @@ -136,6 +135,8 @@ unsigned long hugetlb_total_pages(void);

>  vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,

>  			unsigned long address, unsigned int flags);

>  #ifdef CONFIG_USERFAULTFD

> +enum mcopy_atomic_mode;


(I'm not 100% sure, but.. maybe this can be moved even out of ifdef?  Then you
 can define it once at the top rather than twice?)

Reviewed-by: Peter Xu <peterx@redhat.com>


-- 
Peter Xu
diff mbox series

Patch

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 1d3246b31a41..dfb749eaf348 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -11,7 +11,6 @@ 
 #include <linux/kref.h>
 #include <linux/pgtable.h>
 #include <linux/gfp.h>
-#include <linux/userfaultfd_k.h>
 
 struct ctl_table;
 struct user_struct;
@@ -136,6 +135,8 @@  unsigned long hugetlb_total_pages(void);
 vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
 			unsigned long address, unsigned int flags);
 #ifdef CONFIG_USERFAULTFD
+enum mcopy_atomic_mode;
+
 int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, pte_t *dst_pte,
 				struct vm_area_struct *dst_vma,
 				unsigned long dst_addr,
@@ -315,6 +316,8 @@  static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
 }
 
 #ifdef CONFIG_USERFAULTFD
+enum mcopy_atomic_mode;
+
 static inline int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
 						pte_t *dst_pte,
 						struct vm_area_struct *dst_vma,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9973dec4976c..3b93bbf8c80f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -40,6 +40,7 @@ 
 #include <linux/hugetlb_cgroup.h>
 #include <linux/node.h>
 #include <linux/page_owner.h>
+#include <linux/userfaultfd_k.h>
 #include "internal.h"
 
 int hugetlb_max_hstate __read_mostly;