All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
@ 2017-03-28  5:25 Alexey Kardashevskiy
  2017-03-28 10:45 ` Michael Ellerman
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2017-03-28  5:25 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Alexey Kardashevskiy, Balbir Singh, Paul Mackerras,
	Aneesh Kumar K . V, Greg Kurz

The CMA pages migration code does not support compound pages at
the moment so it performs few tests before proceeding to actual page
migration.

One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
it should be called on head pages. Since we also test for PageCompound(),
and it contains PageTail(), we can simply move PageCompound() in front
of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

Some of actual POWER8 systems do crash on that BUG_ON.
---
 arch/powerpc/mm/mmu_context_iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
index 497130c5c742..ba7fccf993b3 100644
--- a/arch/powerpc/mm/mmu_context_iommu.c
+++ b/arch/powerpc/mm/mmu_context_iommu.c
@@ -81,7 +81,7 @@ struct page *new_iommu_non_cma_page(struct page *page, unsigned long private,
 	gfp_t gfp_mask = GFP_USER;
 	struct page *new_page;
 
-	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
+	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
 		return NULL;
 
 	if (PageHighMem(page))
@@ -100,7 +100,7 @@ static int mm_iommu_move_page_from_cma(struct page *page)
 	LIST_HEAD(cma_migrate_pages);
 
 	/* Ignore huge pages for now */
-	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
+	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
 		return -EBUSY;
 
 	lru_add_drain();
-- 
2.11.0

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-03-28  5:25 [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages Alexey Kardashevskiy
@ 2017-03-28 10:45 ` Michael Ellerman
  2017-03-28 11:58   ` Alexey Kardashevskiy
  2017-04-03  3:27 ` Balbir Singh
  2017-04-04  9:26 ` Aneesh Kumar K.V
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Ellerman @ 2017-03-28 10:45 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, Paul Mackerras, Aneesh Kumar K . V, Greg Kurz

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> The CMA pages migration code does not support compound pages at
> the moment so it performs few tests before proceeding to actual page
> migration.
>
> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
> it should be called on head pages. Since we also test for PageCompound(),
> and it contains PageTail(), we can simply move PageCompound() in front
> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Some of actual POWER8 systems do crash on that BUG_ON.

So this is:

Fixes: 2e5bbb5461f1 ("KVM: PPC: Book3S HV: Migrate pinned pages out of CMA")

And therefore:

Cc: stable@vger.kernel.org # v4.9+

?

cheers

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-03-28 10:45 ` Michael Ellerman
@ 2017-03-28 11:58   ` Alexey Kardashevskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Alexey Kardashevskiy @ 2017-03-28 11:58 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev
  Cc: Paul Mackerras, Aneesh Kumar K . V, Greg Kurz, Balbir Singh

On 28/03/17 21:45, Michael Ellerman wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> 
>> The CMA pages migration code does not support compound pages at
>> the moment so it performs few tests before proceeding to actual page
>> migration.
>>
>> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
>> it should be called on head pages. Since we also test for PageCompound(),
>> and it contains PageTail(), we can simply move PageCompound() in front
>> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> Some of actual POWER8 systems do crash on that BUG_ON.
> 
> So this is:
> 
> Fixes: 2e5bbb5461f1 ("KVM: PPC: Book3S HV: Migrate pinned pages out of CMA")
> 
> And therefore:
> 
> Cc: stable@vger.kernel.org # v4.9+
> 
> ?

May be, first I want to make sure this is enough fix, this is why I
(re)added Balbir in cc list.


-- 
Alexey

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-03-28  5:25 [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages Alexey Kardashevskiy
  2017-03-28 10:45 ` Michael Ellerman
@ 2017-04-03  3:27 ` Balbir Singh
  2017-04-04  9:26 ` Aneesh Kumar K.V
  2 siblings, 0 replies; 7+ messages in thread
From: Balbir Singh @ 2017-04-03  3:27 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Paul Mackerras, Aneesh Kumar K . V, Greg Kurz

On Tue, 2017-03-28 at 16:25 +1100, Alexey Kardashevskiy wrote:
> The CMA pages migration code does not support compound pages at
> the moment so it performs few tests before proceeding to actual page
> migration.
> 
> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
> it should be called on head pages. Since we also test for PageCompound(),
> and it contains PageTail(), we can simply move PageCompound() in front
> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---

The fix looks reasonable to me. I suspect the checks can be simplified
and we can support split and move of THP in the future.

For now, looks good

Acked-by: Balbir Singh <bsingharora@gmail.com>

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-03-28  5:25 [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages Alexey Kardashevskiy
  2017-03-28 10:45 ` Michael Ellerman
  2017-04-03  3:27 ` Balbir Singh
@ 2017-04-04  9:26 ` Aneesh Kumar K.V
  2017-04-05  2:59   ` Alexey Kardashevskiy
  2 siblings, 1 reply; 7+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04  9:26 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Alexey Kardashevskiy, Balbir Singh, Paul Mackerras, Greg Kurz

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> The CMA pages migration code does not support compound pages at
> the moment so it performs few tests before proceeding to actual page
> migration.
>
> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
> it should be called on head pages. Since we also test for PageCompound(),
> and it contains PageTail(), we can simply move PageCompound() in front
> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> Some of actual POWER8 systems do crash on that BUG_ON.
> ---
>  arch/powerpc/mm/mmu_context_iommu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
> index 497130c5c742..ba7fccf993b3 100644
> --- a/arch/powerpc/mm/mmu_context_iommu.c
> +++ b/arch/powerpc/mm/mmu_context_iommu.c
> @@ -81,7 +81,7 @@ struct page *new_iommu_non_cma_page(struct page *page, unsigned long private,
>  	gfp_t gfp_mask = GFP_USER;
>  	struct page *new_page;
>
> -	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
> +	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))


A checked for compound page should be sufficient here, because a
Huge/TransHuge page is also marked compound. If we want to indicate that
we don't handle hugetlb and THP pages, we can write that as a comment ?



>  		return NULL;
>
>  	if (PageHighMem(page))
> @@ -100,7 +100,7 @@ static int mm_iommu_move_page_from_cma(struct page *page)
>  	LIST_HEAD(cma_migrate_pages);
>
>  	/* Ignore huge pages for now */
> -	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
> +	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
>  		return -EBUSY;
>
>  	lru_add_drain();
> -- 
> 2.11.0

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-04-04  9:26 ` Aneesh Kumar K.V
@ 2017-04-05  2:59   ` Alexey Kardashevskiy
  2017-04-05  3:34     ` Aneesh Kumar K.V
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Kardashevskiy @ 2017-04-05  2:59 UTC (permalink / raw)
  To: Aneesh Kumar K.V, linuxppc-dev; +Cc: Balbir Singh, Paul Mackerras, Greg Kurz

On 04/04/17 19:26, Aneesh Kumar K.V wrote:
> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> 
>> The CMA pages migration code does not support compound pages at
>> the moment so it performs few tests before proceeding to actual page
>> migration.
>>
>> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
>> it should be called on head pages. Since we also test for PageCompound(),
>> and it contains PageTail(), we can simply move PageCompound() in front
>> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> Some of actual POWER8 systems do crash on that BUG_ON.
>> ---
>>  arch/powerpc/mm/mmu_context_iommu.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
>> index 497130c5c742..ba7fccf993b3 100644
>> --- a/arch/powerpc/mm/mmu_context_iommu.c
>> +++ b/arch/powerpc/mm/mmu_context_iommu.c
>> @@ -81,7 +81,7 @@ struct page *new_iommu_non_cma_page(struct page *page, unsigned long private,
>>  	gfp_t gfp_mask = GFP_USER;
>>  	struct page *new_page;
>>
>> -	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
>> +	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
> 
> 
> A checked for compound page should be sufficient here, because a
> Huge/TransHuge page is also marked compound.


But PageCompound() calls PageTail() so PageTail() will be called on a trans
page which is BUG_ON in PageTransHuge but it is not in PageCompound() -
this inconsistency is bothering me. Does not this BUG_ON tell us that we
should not be calling PageTail() on _any_ page?

In other words, should I get a head page (via compound_head()) first and
only then test the head page if it is thp/huge (as you suggested in a chat)?


> If we want to indicate that
> we don't handle hugetlb and THP pages, we can write that as a comment ?
> 
> 
> 
>>  		return NULL;
>>
>>  	if (PageHighMem(page))
>> @@ -100,7 +100,7 @@ static int mm_iommu_move_page_from_cma(struct page *page)
>>  	LIST_HEAD(cma_migrate_pages);
>>
>>  	/* Ignore huge pages for now */
>> -	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
>> +	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
>>  		return -EBUSY;
>>
>>  	lru_add_drain();
>> -- 
>> 2.11.0
> 


-- 
Alexey

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

* Re: [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages
  2017-04-05  2:59   ` Alexey Kardashevskiy
@ 2017-04-05  3:34     ` Aneesh Kumar K.V
  0 siblings, 0 replies; 7+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-05  3:34 UTC (permalink / raw)
  To: Alexey Kardashevskiy, linuxppc-dev
  Cc: Balbir Singh, Paul Mackerras, Greg Kurz



On Wednesday 05 April 2017 08:29 AM, Alexey Kardashevskiy wrote:
> On 04/04/17 19:26, Aneesh Kumar K.V wrote:
>> Alexey Kardashevskiy <aik@ozlabs.ru> writes:
>>
>>> The CMA pages migration code does not support compound pages at
>>> the moment so it performs few tests before proceeding to actual page
>>> migration.
>>>
>>> One of the tests - PageTransHuge() - has VM_BUG_ON_PAGE(PageTail()) as
>>> it should be called on head pages. Since we also test for PageCompound(),
>>> and it contains PageTail(), we can simply move PageCompound() in front
>>> of PageTransHuge() and therefore avoid possible VM_BUG_ON_PAGE.
>>>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>> ---
>>>
>>> Some of actual POWER8 systems do crash on that BUG_ON.
>>> ---
>>>  arch/powerpc/mm/mmu_context_iommu.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
>>> index 497130c5c742..ba7fccf993b3 100644
>>> --- a/arch/powerpc/mm/mmu_context_iommu.c
>>> +++ b/arch/powerpc/mm/mmu_context_iommu.c
>>> @@ -81,7 +81,7 @@ struct page *new_iommu_non_cma_page(struct page *page, unsigned long private,
>>>  	gfp_t gfp_mask = GFP_USER;
>>>  	struct page *new_page;
>>>
>>> -	if (PageHuge(page) || PageTransHuge(page) || PageCompound(page))
>>> +	if (PageCompound(page) || PageHuge(page) || PageTransHuge(page))
>>
>>
>> A checked for compound page should be sufficient here, because a
>> Huge/TransHuge page is also marked compound.
>
>
> But PageCompound() calls PageTail() so PageTail() will be called on a trans
> page which is BUG_ON in PageTransHuge but it is not in PageCompound() -
> this inconsistency is bothering me. Does not this BUG_ON tell us that we
> should not be calling PageTail() on _any_ page?
>
> In other words, should I get a head page (via compound_head()) first and
> only then test the head page if it is thp/huge (as you suggested in a chat)?
>
>
>

I was suggesting to replace that if () condition with just

/* We don't handle hugetlb/THP pages yet */
if (PageCompund(page)) {

}

-aneesh

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

end of thread, other threads:[~2017-04-05  3:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28  5:25 [PATCH kernel] powerpc/iommu: Do not call PageTransHuge() on tail pages Alexey Kardashevskiy
2017-03-28 10:45 ` Michael Ellerman
2017-03-28 11:58   ` Alexey Kardashevskiy
2017-04-03  3:27 ` Balbir Singh
2017-04-04  9:26 ` Aneesh Kumar K.V
2017-04-05  2:59   ` Alexey Kardashevskiy
2017-04-05  3:34     ` Aneesh Kumar K.V

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.