From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
Alex Thorlton <athorlton@sgi.com>,
Gerald Schaefer <gerald.schaefer@de.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-arch@vger.kernel.org,
Vineet Gupta <Vineet.Gupta1@synopsys.com>,
Andrea Arcangeli <aarcange@redhat.com>
Subject: [PATCH 1/2] mm,thp: refactor generic deposit/withdraw routines for wider usage
Date: Thu, 11 Feb 2016 14:58:26 +0530 [thread overview]
Message-ID: <1455182907-15445-2-git-send-email-vgupta@synopsys.com> (raw)
In-Reply-To: <1455182907-15445-1-git-send-email-vgupta@synopsys.com>
Generic pgtable_trans_huge_deposit()/pgtable_trans_huge_withdraw()
assume pgtable_t to be struct page * which is not true for all arches.
Thus arc, s390, sparch end up with their own copies despite no special
hardware requirements (unlike powerpc).
It seems massaging the code a bit can make it reusbale.
- Use explicit casts to (struct page *). For existing users, this
should be semantically no-op for existing users
- The only addition is zero'ing out of page->lru which for arc leaves
a stray entry in pgtable_t cause mm spew when such pgtable is freed.
| huge_memory: BUG: failure at
| ../mm/huge_memory.c:1858/__split_huge_page_map()!
| CPU: 0 PID: 901 Comm: bw_mem Not tainted 4.4.0-00015-g0569c1459cfa-dirty
|
| Stack Trace:
| arc_unwind_core.constprop.1+0x94/0x104
| split_huge_page_to_list+0x5c0/0x920
| __split_huge_page_pmd+0xc8/0x1b4
| vma_adjust_trans_huge+0x104/0x1c8
| vma_adjust+0xf8/0x6d8
| __split_vma.isra.40+0xf8/0x174
| do_munmap+0x360/0x428
| SyS_munmap+0x28/0x44
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-arch@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
mm/pgtable-generic.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index 75664ed7e3ab..c9f2f6f8c7bb 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -155,13 +155,17 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address,
void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
pgtable_t pgtable)
{
+ struct page *new = (struct page *)pgtable;
+ struct page *head;
+
assert_spin_locked(pmd_lockptr(mm, pmdp));
/* FIFO */
- if (!pmd_huge_pte(mm, pmdp))
- INIT_LIST_HEAD(&pgtable->lru);
+ head = (struct page *)pmd_huge_pte(mm, pmdp);
+ if (!head)
+ INIT_LIST_HEAD(&new->lru);
else
- list_add(&pgtable->lru, &pmd_huge_pte(mm, pmdp)->lru);
+ list_add(&new->lru, &head->lru);
pmd_huge_pte(mm, pmdp) = pgtable;
}
#endif
@@ -170,20 +174,23 @@ void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
/* no "address" argument so destroys page coloring of some arch */
pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
{
- pgtable_t pgtable;
+ struct page *page;
assert_spin_locked(pmd_lockptr(mm, pmdp));
+ page = (struct page *)pmd_huge_pte(mm, pmdp);
+
/* FIFO */
- pgtable = pmd_huge_pte(mm, pmdp);
- if (list_empty(&pgtable->lru))
+ if (list_empty(&page->lru))
pmd_huge_pte(mm, pmdp) = NULL;
else {
- pmd_huge_pte(mm, pmdp) = list_entry(pgtable->lru.next,
- struct page, lru);
- list_del(&pgtable->lru);
+ pmd_huge_pte(mm, pmdp) = (pgtable_t) list_entry(page->lru.next,
+ struct page, lru);
+ list_del(&page->lru);
}
- return pgtable;
+
+ memset(&page->lru, 0, sizeof(page->lru));
+ return (pgtable_t)page;
}
#endif
--
2.5.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>
next prev parent reply other threads:[~2016-02-11 9:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 9:28 [PATCH 0/2] Enable s390/arc/sparc to use generic thp deposit/withdraw Vineet Gupta
2016-02-11 9:28 ` Vineet Gupta [this message]
2016-02-11 10:22 ` [PATCH 1/2] mm,thp: refactor generic deposit/withdraw routines for wider usage Martin Schwidefsky
2016-02-11 10:22 ` Martin Schwidefsky
2016-02-11 10:53 ` Vineet Gupta
2016-02-11 11:20 ` Martin Schwidefsky
2016-02-11 12:29 ` Vineet Gupta
2016-02-11 9:28 ` [PATCH 2/2] ARC: mm: THP: use generic THP deposit/withdraw Vineet Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1455182907-15445-2-git-send-email-vgupta@synopsys.com \
--to=vineet.gupta1@synopsys.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=athorlton@sgi.com \
--cc=davem@davemloft.net \
--cc=gerald.schaefer@de.ibm.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-snps-arc@lists.infradead.org \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).