From: Nick Piggin <npiggin@suse.de>
To: akpm@linux-foundation.org
Cc: Nishanth Aravamudan <nacc@us.ibm.com>,
linux-mm@kvack.org, kniht@us.ibm.com, andi@firstfloor.org,
abh@cray.com, joachim.deguara@amd.com,
Dave Kleikamp <shaggy@austin.ibm.com>,
Andy Whitcroft <apw@shadowen.org>, Ingo Molnar <mingo@elte.hu>,
Thomas Gleixner <tglx@linutronix.de>,
Badari Pulavarty <pbadari@us.ibm.com>,
Zach Brown <zach.brown@oracle.com>,
Jens Axboe <jens.axboe@oracle.com>
Subject: [patch 1/1] x86: get_user_pages_lockless support 1GB hugepages
Date: Tue, 3 Jun 2008 12:29:02 +0200 [thread overview]
Message-ID: <20080603102902.GA23454@wotan.suse.de> (raw)
In-Reply-To: <20080603095956.781009952@amd.local0.net>
Hi,
This patch couples lockless get_user_pages with the 1GB hugepages for
x86: if one is merged upstream first, this patch has to be merged with
the other.
---
x86: support 1GB hugepages with get_user_pages_lockless()
Signed-off-by: Nick Piggin <npiggin@suse.de>
Index: linux-2.6/arch/x86/mm/gup.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/gup.c
+++ linux-2.6/arch/x86/mm/gup.c
@@ -122,7 +122,7 @@ static noinline int gup_huge_pmd(pmd_t p
refs = 0;
head = pte_page(pte);
- page = head + ((addr & ~HPAGE_MASK) >> PAGE_SHIFT);
+ page = head + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
do {
VM_BUG_ON(compound_head(page) != head);
pages[*nr] = page;
@@ -160,6 +160,38 @@ static int gup_pmd_range(pud_t pud, unsi
return 1;
}
+static noinline int gup_huge_pud(pud_t pud, unsigned long addr,
+ unsigned long end, int write, struct page **pages, int *nr)
+{
+ unsigned long mask;
+ pte_t pte = *(pte_t *)&pud;
+ struct page *head, *page;
+ int refs;
+
+ mask = _PAGE_PRESENT|_PAGE_USER;
+ if (write)
+ mask |= _PAGE_RW;
+ if ((pte_val(pte) & mask) != mask)
+ return 0;
+ /* hugepages are never "special" */
+ VM_BUG_ON(pte_val(pte) & _PAGE_SPECIAL);
+ VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
+
+ refs = 0;
+ head = pte_page(pte);
+ page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
+ do {
+ VM_BUG_ON(compound_head(page) != head);
+ pages[*nr] = page;
+ (*nr)++;
+ page++;
+ refs++;
+ } while (addr += PAGE_SIZE, addr != end);
+ get_head_page_multiple(head, refs);
+
+ return 1;
+}
+
static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end, int write, struct page **pages, int *nr)
{
unsigned long next;
@@ -172,8 +204,13 @@ static int gup_pud_range(pgd_t pgd, unsi
next = pud_addr_end(addr, end);
if (pud_none(pud))
return 0;
- if (!gup_pmd_range(pud, addr, next, write, pages, nr))
- return 0;
+ if (unlikely(pud_large(pud))) {
+ if (!gup_huge_pud(pud, addr, next, write, pages, nr))
+ return 0;
+ } else {
+ if (!gup_pmd_range(pud, addr, next, write, pages, nr))
+ return 0;
+ }
} while (pudp++, addr = next, addr != end);
return 1;
--
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:[~2008-06-03 10:29 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-03 9:59 [patch 00/21] hugetlb multi size, giant hugetlb support, etc npiggin
2008-06-03 9:59 ` [patch 01/21] hugetlb: factor out prep_new_huge_page npiggin
2008-06-03 9:59 ` [patch 02/21] hugetlb: modular state npiggin
2008-06-03 10:58 ` [patch 02/21] hugetlb: modular state (take 2) Nick Piggin
2008-06-03 9:59 ` [patch 03/21] hugetlb: multiple hstates npiggin
2008-06-03 10:00 ` [patch 04/21] hugetlbfs: per mount hstates npiggin
2008-06-03 10:00 ` [patch 05/21] hugetlb: new sysfs interface npiggin
2008-06-03 10:00 ` [patch 06/21] hugetlb: abstract numa round robin selection npiggin
2008-06-03 10:00 ` [patch 07/21] mm: introduce non panic alloc_bootmem npiggin
2008-06-03 10:00 ` [patch 08/21] mm: export prep_compound_page to mm npiggin
2008-06-03 10:00 ` [patch 09/21] hugetlb: support larger than MAX_ORDER npiggin
2008-06-03 10:00 ` [patch 10/21] hugetlb: support boot allocate different sizes npiggin
2008-06-03 10:00 ` [patch 11/21] hugetlb: printk cleanup npiggin
2008-06-03 10:00 ` [patch 12/21] hugetlb: introduce pud_huge npiggin
2008-06-03 10:00 ` [patch 13/21] x86: support GB hugepages on 64-bit npiggin
2008-06-03 10:00 ` [patch 14/21] x86: add hugepagesz option " npiggin
2008-06-03 17:48 ` Dave Hansen
2008-06-03 18:24 ` Andi Kleen
2008-06-03 18:59 ` Dave Hansen
2008-06-03 20:57 ` Andi Kleen
2008-06-03 21:27 ` Dave Hansen
2008-06-04 0:06 ` Andi Kleen
2008-06-04 1:04 ` Nick Piggin
2008-06-04 16:01 ` Dave Hansen
2008-06-06 16:09 ` Dave Hansen
2008-06-05 23:15 ` Nishanth Aravamudan
2008-06-06 0:29 ` Andi Kleen
2008-06-04 1:10 ` Nick Piggin
2008-06-05 23:12 ` Nishanth Aravamudan
2008-06-05 23:23 ` Nishanth Aravamudan
2008-06-03 19:00 ` Dave Hansen
2008-06-03 10:00 ` [patch 15/21] hugetlb: override default huge page size npiggin
2008-06-03 10:00 ` [patch 16/21] hugetlb: allow arch overried hugepage allocation npiggin
2008-06-03 10:00 ` [patch 17/21] powerpc: function to allocate gigantic hugepages npiggin
2008-06-03 10:00 ` [patch 18/21] powerpc: scan device tree for gigantic pages npiggin
2008-06-03 10:00 ` [patch 19/21] powerpc: define support for 16G hugepages npiggin
2008-06-03 10:00 ` [patch 20/21] fs: check for statfs overflow npiggin
2008-06-03 10:00 ` [patch 21/21] powerpc: support multiple hugepage sizes npiggin
2008-06-03 10:29 ` Nick Piggin [this message]
2008-06-03 10:57 ` [patch 00/21] hugetlb multi size, giant hugetlb support, etc Nick Piggin
2008-06-06 17:12 ` Andy Whitcroft
2008-06-04 8:29 ` Andrew Morton
2008-06-04 9:35 ` Nick Piggin
2008-06-04 9:46 ` Andrew Morton
2008-06-04 11:04 ` Nick Piggin
2008-06-04 11:33 ` Nick Piggin
2008-06-04 11:57 ` Andi Kleen
2008-06-04 18:39 ` Andrew Morton
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=20080603102902.GA23454@wotan.suse.de \
--to=npiggin@suse.de \
--cc=abh@cray.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=apw@shadowen.org \
--cc=jens.axboe@oracle.com \
--cc=joachim.deguara@amd.com \
--cc=kniht@us.ibm.com \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=nacc@us.ibm.com \
--cc=pbadari@us.ibm.com \
--cc=shaggy@austin.ibm.com \
--cc=tglx@linutronix.de \
--cc=zach.brown@oracle.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).