All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: Fix build with !ARCH_WANT_HUGE_PMD_SHARE
@ 2021-03-10 18:53 Peter Xu
  2021-03-10 19:21 ` Mike Kravetz
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Xu @ 2021-03-10 18:53 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: peterx, Andrew Morton, Mike Kravetz, Axel Rasmussen, Naresh Kamboju

want_pmd_share() is undefined with !ARCH_WANT_HUGE_PMD_SHARE since it's put
by accident into a "#ifdef ARCH_WANT_HUGE_PMD_SHARE" block.  Moving it out
won't work either since vma_shareable() is only defined within the block.
Define it for !ARCH_WANT_HUGE_PMD_SHARE instead.

Fixes: 5b109cc1cdcc ("hugetlb/userfaultfd: forbid huge pmd sharing when uffd enabled")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 mm/hugetlb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d58f1456fe27..8dda7e034477 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5469,9 +5469,6 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr)
 
 bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)
 {
-#ifndef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
-	return false;
-#endif
 #ifdef CONFIG_USERFAULTFD
 	if (uffd_disable_huge_pmd_share(vma))
 		return false;
@@ -5616,6 +5613,11 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
 				unsigned long *start, unsigned long *end)
 {
 }
+
+bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)
+{
+	return false;
+}
 #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */
 
 #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB
-- 
2.26.2


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

* Re: [PATCH] mm/hugetlb: Fix build with !ARCH_WANT_HUGE_PMD_SHARE
  2021-03-10 18:53 [PATCH] mm/hugetlb: Fix build with !ARCH_WANT_HUGE_PMD_SHARE Peter Xu
@ 2021-03-10 19:21 ` Mike Kravetz
  2021-03-10 19:40   ` Peter Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Kravetz @ 2021-03-10 19:21 UTC (permalink / raw)
  To: Peter Xu, linux-kernel, linux-mm
  Cc: Andrew Morton, Axel Rasmussen, Naresh Kamboju

On 3/10/21 10:53 AM, Peter Xu wrote:
> want_pmd_share() is undefined with !ARCH_WANT_HUGE_PMD_SHARE since it's put
> by accident into a "#ifdef ARCH_WANT_HUGE_PMD_SHARE" block.  Moving it out
> won't work either since vma_shareable() is only defined within the block.
> Define it for !ARCH_WANT_HUGE_PMD_SHARE instead.
> 
> Fixes: 5b109cc1cdcc ("hugetlb/userfaultfd: forbid huge pmd sharing when uffd enabled")

That commit id is from Andrew's tree and I don't think it is stable.
There is a different id in the next tree.  Not exactly sure how this is
supposed to be handled.

> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Axel Rasmussen <axelrasmussen@google.com>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  mm/hugetlb.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Thanks Peter,
Not your fault, but that header file is a bit of a mess.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
-- 
Mike Kravetz

> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index d58f1456fe27..8dda7e034477 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5469,9 +5469,6 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr)
>  
>  bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)
>  {
> -#ifndef CONFIG_ARCH_WANT_HUGE_PMD_SHARE
> -	return false;
> -#endif
>  #ifdef CONFIG_USERFAULTFD
>  	if (uffd_disable_huge_pmd_share(vma))
>  		return false;
> @@ -5616,6 +5613,11 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
>  				unsigned long *start, unsigned long *end)
>  {
>  }
> +
> +bool want_pmd_share(struct vm_area_struct *vma, unsigned long addr)
> +{
> +	return false;
> +}
>  #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */
>  
>  #ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB
> 

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

* Re: [PATCH] mm/hugetlb: Fix build with !ARCH_WANT_HUGE_PMD_SHARE
  2021-03-10 19:21 ` Mike Kravetz
@ 2021-03-10 19:40   ` Peter Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Xu @ 2021-03-10 19:40 UTC (permalink / raw)
  To: Mike Kravetz
  Cc: linux-kernel, linux-mm, Andrew Morton, Axel Rasmussen, Naresh Kamboju

On Wed, Mar 10, 2021 at 11:21:50AM -0800, Mike Kravetz wrote:
> On 3/10/21 10:53 AM, Peter Xu wrote:
> > want_pmd_share() is undefined with !ARCH_WANT_HUGE_PMD_SHARE since it's put
> > by accident into a "#ifdef ARCH_WANT_HUGE_PMD_SHARE" block.  Moving it out
> > won't work either since vma_shareable() is only defined within the block.
> > Define it for !ARCH_WANT_HUGE_PMD_SHARE instead.
> > 
> > Fixes: 5b109cc1cdcc ("hugetlb/userfaultfd: forbid huge pmd sharing when uffd enabled")
> 
> That commit id is from Andrew's tree and I don't think it is stable.
> There is a different id in the next tree.  Not exactly sure how this is
> supposed to be handled.

I see - it'll be even better if this patch can be squashed into it.

> 
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Mike Kravetz <mike.kravetz@oracle.com>
> > Cc: Axel Rasmussen <axelrasmussen@google.com>
> > Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> > Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  mm/hugetlb.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> Thanks Peter,
> Not your fault, but that header file is a bit of a mess.
> 
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

I'm still guilty on not noticing this before since I still could..  I think it
gives me some more clue to make less such mistake in the future.

Thanks for taking a quick look, Mike!

-- 
Peter Xu


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

end of thread, other threads:[~2021-03-10 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 18:53 [PATCH] mm/hugetlb: Fix build with !ARCH_WANT_HUGE_PMD_SHARE Peter Xu
2021-03-10 19:21 ` Mike Kravetz
2021-03-10 19:40   ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.