linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thp: call pmdp_invalidate() with correct virtual address
@ 2016-02-24 15:58 Kirill A. Shutemov
  2016-02-24 16:17 ` Will Deacon
  2016-02-24 18:49 ` Linus Torvalds
  0 siblings, 2 replies; 3+ messages in thread
From: Kirill A. Shutemov @ 2016-02-24 15:58 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds
  Cc: Gerald Schaefer, Christian Borntraeger, Will Deacon,
	Martin Schwidefsky, Andrea Arcangeli, linux-s390, linux-mm,
	linux-kernel, Kirill A. Shutemov

Sebastian Ott and Gerald Schaefer reported random crashes on s390.
It was bisected to my THP refcounting patchset.

The problem is that pmdp_invalidated() called with wrong virtual
address. It got offset up by HPAGE_PMD_SIZE by loop over ptes.

The solution is to introduce new variable to be used in loop and don't
touch 'haddr'.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Reported-by Sebastian Ott <sebott@linux.vnet.ibm.com>
---
 mm/huge_memory.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 1c317b85ea7d..e10a4fee88d2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2836,6 +2836,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
 	pgtable_t pgtable;
 	pmd_t _pmd;
 	bool young, write, dirty;
+	unsigned long addr;
 	int i;
 
 	VM_BUG_ON(haddr & ~HPAGE_PMD_MASK);
@@ -2865,7 +2866,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
 	pgtable = pgtable_trans_huge_withdraw(mm, pmd);
 	pmd_populate(mm, &_pmd, pgtable);
 
-	for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) {
+	for (i = 0, addr = haddr; i < HPAGE_PMD_NR; i++, addr += PAGE_SIZE) {
 		pte_t entry, *pte;
 		/*
 		 * Note that NUMA hinting access restrictions are not
@@ -2886,9 +2887,9 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
 		}
 		if (dirty)
 			SetPageDirty(page + i);
-		pte = pte_offset_map(&_pmd, haddr);
+		pte = pte_offset_map(&_pmd, addr);
 		BUG_ON(!pte_none(*pte));
-		set_pte_at(mm, haddr, pte, entry);
+		set_pte_at(mm, addr, pte, entry);
 		atomic_inc(&page[i]._mapcount);
 		pte_unmap(pte);
 	}
@@ -2938,7 +2939,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
 	pmd_populate(mm, pmd, pgtable);
 
 	if (freeze) {
-		for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) {
+		for (i = 0; i < HPAGE_PMD_NR; i++) {
 			page_remove_rmap(page + i, false);
 			put_page(page + i);
 		}
-- 
2.7.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] thp: call pmdp_invalidate() with correct virtual address
  2016-02-24 15:58 [PATCH] thp: call pmdp_invalidate() with correct virtual address Kirill A. Shutemov
@ 2016-02-24 16:17 ` Will Deacon
  2016-02-24 18:49 ` Linus Torvalds
  1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2016-02-24 16:17 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Linus Torvalds, Gerald Schaefer,
	Christian Borntraeger, Martin Schwidefsky, Andrea Arcangeli,
	linux-s390, linux-mm, linux-kernel

On Wed, Feb 24, 2016 at 06:58:03PM +0300, Kirill A. Shutemov wrote:
> Sebastian Ott and Gerald Schaefer reported random crashes on s390.
> It was bisected to my THP refcounting patchset.
> 
> The problem is that pmdp_invalidated() called with wrong virtual
> address. It got offset up by HPAGE_PMD_SIZE by loop over ptes.
> 
> The solution is to introduce new variable to be used in loop and don't
> touch 'haddr'.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Reported-by Sebastian Ott <sebott@linux.vnet.ibm.com>
> ---
>  mm/huge_memory.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Looks good to me:

Reviewed-by: Will Deacon <will.deacon@arm.com>

Thanks,

Will

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] thp: call pmdp_invalidate() with correct virtual address
  2016-02-24 15:58 [PATCH] thp: call pmdp_invalidate() with correct virtual address Kirill A. Shutemov
  2016-02-24 16:17 ` Will Deacon
@ 2016-02-24 18:49 ` Linus Torvalds
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 2016-02-24 18:49 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Gerald Schaefer, Christian Borntraeger,
	Will Deacon, Martin Schwidefsky, Andrea Arcangeli, linux-s390,
	linux-mm, Linux Kernel Mailing List

On Wed, Feb 24, 2016 at 7:58 AM, Kirill A. Shutemov
<kirill.shutemov@linux.intel.com> wrote:
> Sebastian Ott and Gerald Schaefer reported random crashes on s390.
> It was bisected to my THP refcounting patchset.
>
> The problem is that pmdp_invalidated() called with wrong virtual
> address. It got offset up by HPAGE_PMD_SIZE by loop over ptes.
>
> The solution is to introduce new variable to be used in loop and don't
> touch 'haddr'.

Thanks, I applied this directly rather than wait for this to go
through Andrew (which would have been "proper channels").

This issue has been worrying me for a while now and was my main core
worry for 4.5. Good to have it resolved, and thanks to everybody who
tested and got involved.

                 Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2016-02-24 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-24 15:58 [PATCH] thp: call pmdp_invalidate() with correct virtual address Kirill A. Shutemov
2016-02-24 16:17 ` Will Deacon
2016-02-24 18:49 ` Linus Torvalds

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).