linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: huge_pte_offset() returns pte_t *, not integer
@ 2019-10-16  9:51 Ben Dooks (Codethink)
  2019-10-28 21:55 ` Mike Kravetz
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Dooks (Codethink) @ 2019-10-16  9:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ben Dooks (Codethink), Mike Kravetz, linux-mm, linux-kernel

The huge_pte_offset() returns a pte_t *, not an integer
so when huge-tlb is off, the replacement inline macro
should return a pte_t * too.

This fixes the following sparse warning:

mm/page_vma_mapped.c:156:29: warning: Using plain integer as NULL pointer

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 include/linux/hugetlb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 53fc34f930d0..e42c76aa1577 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -185,7 +185,7 @@ static inline void hugetlb_show_meminfo(void)
 #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
 #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
 				src_addr, pagep)	({ BUG(); 0; })
-#define huge_pte_offset(mm, address, sz)	0
+#define huge_pte_offset(mm, address, sz)	(pte_t *)NULL
 
 static inline bool isolate_huge_page(struct page *page, struct list_head *list)
 {
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: huge_pte_offset() returns pte_t *, not integer
  2019-10-16  9:51 [PATCH] mm: huge_pte_offset() returns pte_t *, not integer Ben Dooks (Codethink)
@ 2019-10-28 21:55 ` Mike Kravetz
  2019-10-29 12:35   ` Jason Gunthorpe
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Kravetz @ 2019-10-28 21:55 UTC (permalink / raw)
  To: Ben Dooks (Codethink), linux-kernel; +Cc: linux-mm, linux-kernel, Andrew Morton

Cc: Andrew
There are already a few hugetlbfs cleanups in the mm tree.

On 10/16/19 2:51 AM, Ben Dooks (Codethink) wrote:
> The huge_pte_offset() returns a pte_t *, not an integer
> so when huge-tlb is off, the replacement inline macro
> should return a pte_t * too.
> 
> This fixes the following sparse warning:
> 
> mm/page_vma_mapped.c:156:29: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

That is simple enough,
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
-- 
Mike Kravetz

> ---
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  include/linux/hugetlb.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 53fc34f930d0..e42c76aa1577 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -185,7 +185,7 @@ static inline void hugetlb_show_meminfo(void)
>  #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
>  #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
>  				src_addr, pagep)	({ BUG(); 0; })
> -#define huge_pte_offset(mm, address, sz)	0
> +#define huge_pte_offset(mm, address, sz)	(pte_t *)NULL
>  
>  static inline bool isolate_huge_page(struct page *page, struct list_head *list)
>  {
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: huge_pte_offset() returns pte_t *, not integer
  2019-10-28 21:55 ` Mike Kravetz
@ 2019-10-29 12:35   ` Jason Gunthorpe
  2019-10-29 23:28     ` Mike Kravetz
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2019-10-29 12:35 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: Ben Dooks (Codethink),
	linux-kernel, linux-mm, linux-kernel, Andrew Morton

On Mon, Oct 28, 2019 at 02:55:13PM -0700, Mike Kravetz wrote:

> > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> > index 53fc34f930d0..e42c76aa1577 100644
> > --- a/include/linux/hugetlb.h
> > +++ b/include/linux/hugetlb.h
> > @@ -185,7 +185,7 @@ static inline void hugetlb_show_meminfo(void)
> >  #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
> >  #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
> >  				src_addr, pagep)	({ BUG(); 0; })
> > -#define huge_pte_offset(mm, address, sz)	0
> > +#define huge_pte_offset(mm, address, sz)	(pte_t *)NULL

We have recently been converting functions like this to static
inlines, maybe that is more appropriate for this block of 'functions'
as well?

Jason


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm: huge_pte_offset() returns pte_t *, not integer
  2019-10-29 12:35   ` Jason Gunthorpe
@ 2019-10-29 23:28     ` Mike Kravetz
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Kravetz @ 2019-10-29 23:28 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Ben Dooks (Codethink),
	linux-kernel, linux-mm, linux-kernel, Andrew Morton

On 10/29/19 5:35 AM, Jason Gunthorpe wrote:
> On Mon, Oct 28, 2019 at 02:55:13PM -0700, Mike Kravetz wrote:
> 
>>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>>> index 53fc34f930d0..e42c76aa1577 100644
>>> --- a/include/linux/hugetlb.h
>>> +++ b/include/linux/hugetlb.h
>>> @@ -185,7 +185,7 @@ static inline void hugetlb_show_meminfo(void)
>>>  #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
>>>  #define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
>>>  				src_addr, pagep)	({ BUG(); 0; })
>>> -#define huge_pte_offset(mm, address, sz)	0
>>> +#define huge_pte_offset(mm, address, sz)	(pte_t *)NULL
> 
> We have recently been converting functions like this to static
> inlines, maybe that is more appropriate for this block of 'functions'
> as well?

Yes.  And thanks again Jason for converting some of these in the past!

How about this?

From ad7415f59f144ca36cf0c3b27504a5ee76b5e9e6 Mon Sep 17 00:00:00 2001
From: Mike Kravetz <mike.kravetz@oracle.com>
Date: Tue, 29 Oct 2019 14:26:08 -0700
Subject: [PATCH] hugetlbfs: convert macros to static inline, fix sparse
 warning

huge_pte_offset() produced a sparse warning due to an improper
return type when the kernel was built with !CONFIG_HUGETLB_PAGE.
Fix the bad type and also convert all the macros in this block
to static inline wrappers.  Two existing wrappers in this block
had lines in excess of 80 columns so clean those up as well.

No functional change.

Reported-by: Ben Dooks <ben.dooks@codethink.co.uk>
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 include/linux/hugetlb.h | 137 +++++++++++++++++++++++++++++++++-------
 1 file changed, 115 insertions(+), 22 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 53fc34f930d0..ef412fe0be3d 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -164,38 +164,130 @@ static inline void adjust_range_if_pmd_sharing_possible(
 {
 }
 
-#define follow_hugetlb_page(m,v,p,vs,a,b,i,w,n)	({ BUG(); 0; })
-#define follow_huge_addr(mm, addr, write)	ERR_PTR(-EINVAL)
-#define copy_hugetlb_page_range(src, dst, vma)	({ BUG(); 0; })
+static inline long follow_hugetlb_page(struct mm_struct *mm,
+			struct vm_area_struct *vma, struct page **pages,
+			struct vm_area_struct **vmas, unsigned long *position,
+			unsigned long *nr_pages, long i, unsigned int flags,
+			int *nonblocking)
+{
+	BUG();
+	return 0;
+}
+
+static inline struct page *follow_huge_addr(struct mm_struct *mm,
+					unsigned long address, int write)
+{
+	return ERR_PTR(-EINVAL);
+}
+
+static inline int copy_hugetlb_page_range(struct mm_struct *dst,
+			struct mm_struct *src, struct vm_area_struct *vma)
+{
+	BUG();
+	return 0;
+}
+
 static inline void hugetlb_report_meminfo(struct seq_file *m)
 {
 }
-#define hugetlb_report_node_meminfo(n, buf)	0
+
+static inline int hugetlb_report_node_meminfo(int nid, char *buf)
+{
+	return 0;
+}
+
 static inline void hugetlb_show_meminfo(void)
 {
 }
-#define follow_huge_pd(vma, addr, hpd, flags, pdshift) NULL
-#define follow_huge_pmd(mm, addr, pmd, flags)	NULL
-#define follow_huge_pud(mm, addr, pud, flags)	NULL
-#define follow_huge_pgd(mm, addr, pgd, flags)	NULL
-#define prepare_hugepage_range(file, addr, len)	(-EINVAL)
-#define pmd_huge(x)	0
-#define pud_huge(x)	0
-#define is_hugepage_only_range(mm, addr, len)	0
-#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; })
-#define hugetlb_mcopy_atomic_pte(dst_mm, dst_pte, dst_vma, dst_addr, \
-				src_addr, pagep)	({ BUG(); 0; })
-#define huge_pte_offset(mm, address, sz)	0
+
+static inline struct page *follow_huge_pd(struct vm_area_struct *vma,
+				unsigned long address, hugepd_t hpd, int flags,
+				int pdshift)
+{
+	return NULL;
+}
+
+static inline struct page *follow_huge_pmd(struct mm_struct *mm,
+				unsigned long address, pmd_t *pmd, int flags)
+{
+	return NULL;
+}
+
+static inline struct page *follow_huge_pud(struct mm_struct *mm,
+				unsigned long address, pud_t *pud, int flags)
+{
+	return NULL;
+}
+
+static inline struct page *follow_huge_pgd(struct mm_struct *mm,
+				unsigned long address, pgd_t *pgd, int flags)
+{
+	return NULL;
+}
+
+static inline int prepare_hugepage_range(struct file *file,
+				unsigned long addr, unsigned long len)
+{
+	return -EINVAL;
+}
+
+static inline int pmd_huge(pmd_t pmd)
+{
+	return 0;
+}
+
+static inline int pud_huge(pud_t pud)
+{
+	return 0;
+}
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+					unsigned long addr, unsigned long len)
+{
+	return 0;
+}
+
+static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
+				unsigned long addr, unsigned long end,
+				unsigned long floor, unsigned long ceiling)
+{
+	BUG();
+}
+
+static inline int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
+						pte_t *dst_pte,
+						struct vm_area_struct *dst_vma,
+						unsigned long dst_addr,
+						unsigned long src_addr,
+						struct page **pagep)
+{
+	BUG();
+	return 0;
+}
+
+static inline pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,
+					unsigned long sz)
+{
+	return NULL;
+}
 
 static inline bool isolate_huge_page(struct page *page, struct list_head *list)
 {
 	return false;
 }
-#define putback_active_hugepage(p)	do {} while (0)
-#define move_hugetlb_state(old, new, reason)	do {} while (0)
 
-static inline unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
-		unsigned long address, unsigned long end, pgprot_t newprot)
+static inline void putback_active_hugepage(struct page *page)
+{
+}
+
+static inline void move_hugetlb_state(struct page *oldpage,
+					struct page *newpage, int reason)
+{
+}
+
+static inline unsigned long hugetlb_change_protection(
+			struct vm_area_struct *vma, unsigned long address,
+			unsigned long end, pgprot_t newprot)
 {
 	return 0;
 }
@@ -213,9 +305,10 @@ static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
 {
 	BUG();
 }
+
 static inline vm_fault_t hugetlb_fault(struct mm_struct *mm,
-				struct vm_area_struct *vma, unsigned long address,
-				unsigned int flags)
+			struct vm_area_struct *vma, unsigned long address,
+			unsigned int flags)
 {
 	BUG();
 	return 0;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-29 23:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16  9:51 [PATCH] mm: huge_pte_offset() returns pte_t *, not integer Ben Dooks (Codethink)
2019-10-28 21:55 ` Mike Kravetz
2019-10-29 12:35   ` Jason Gunthorpe
2019-10-29 23:28     ` Mike Kravetz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).