From: Nick Piggin <npiggin@suse.de>
To: Hugh Dickins <hugh@veritas.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
tee@sgi.com, holt@sgi.com, Andrea Arcangeli <andrea@suse.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [rfc] no ZERO_PAGE?
Date: Wed, 4 Apr 2007 05:37:26 +0200 [thread overview]
Message-ID: <20070404033726.GE18507@wotan.suse.de> (raw)
In-Reply-To: <20070330024048.GG19407@wotan.suse.de>
On Fri, Mar 30, 2007 at 04:40:48AM +0200, Nick Piggin wrote:
>
> Well it would make life easier if we got rid of ZERO_PAGE completely,
> which I definitely wouldn't complain about ;)
So, what bad things (apart from my bugs in untested code) happen
if we do this? We can actually go further, and probably remove the
ZERO_PAGE completely (just need an extra get_user_pages flag or
something for the core dumping issue).
Shall I do a more complete patchset and ask Andrew to give it a
run in -mm?
--
ZERO_PAGE for anonymous pages seems to only be designed to help stupid
programs, so remove it. This solves issues with ZERO_PAGE refcounting
and NUMA un-awareness.
(Actually, not quite. We should also remove all the zeromap stuff that
also seems to not do much except help stupid programs).
Index: linux-2.6/mm/memory.c
===================================================================
--- linux-2.6.orig/mm/memory.c
+++ linux-2.6/mm/memory.c
@@ -1613,16 +1613,10 @@ gotten:
if (unlikely(anon_vma_prepare(vma)))
goto oom;
- if (old_page == ZERO_PAGE(address)) {
- new_page = alloc_zeroed_user_highpage(vma, address);
- if (!new_page)
- goto oom;
- } else {
- new_page = alloc_page_vma(GFP_HIGHUSER, vma, address);
- if (!new_page)
- goto oom;
- cow_user_page(new_page, old_page, address, vma);
- }
+ new_page = alloc_page_vma(GFP_HIGHUSER, vma, address);
+ if (!new_page)
+ goto oom;
+ cow_user_page(new_page, old_page, address, vma);
/*
* Re-check the pte - we dropped the lock
@@ -2130,52 +2124,33 @@ static int do_anonymous_page(struct mm_s
spinlock_t *ptl;
pte_t entry;
- if (write_access) {
- /* Allocate our own private page. */
- pte_unmap(page_table);
+ /* Allocate our own private page. */
+ pte_unmap(page_table);
- if (unlikely(anon_vma_prepare(vma)))
- goto oom;
- page = alloc_zeroed_user_highpage(vma, address);
- if (!page)
- goto oom;
+ if (unlikely(anon_vma_prepare(vma)))
+ return VM_FAULT_OOM;
+ page = alloc_zeroed_user_highpage(vma, address);
+ if (!page)
+ return VM_FAULT_OOM;
- entry = mk_pte(page, vma->vm_page_prot);
- entry = maybe_mkwrite(pte_mkdirty(entry), vma);
+ entry = mk_pte(page, vma->vm_page_prot);
+ entry = maybe_mkwrite(pte_mkdirty(entry), vma);
- page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
- if (!pte_none(*page_table))
- goto release;
+ page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
+ if (likely(!pte_none(*page_table))) {
inc_mm_counter(mm, anon_rss);
lru_cache_add_active(page);
page_add_new_anon_rmap(page, vma, address);
- } else {
- /* Map the ZERO_PAGE - vm_page_prot is readonly */
- page = ZERO_PAGE(address);
- page_cache_get(page);
- entry = mk_pte(page, vma->vm_page_prot);
-
- ptl = pte_lockptr(mm, pmd);
- spin_lock(ptl);
- if (!pte_none(*page_table))
- goto release;
- inc_mm_counter(mm, file_rss);
- page_add_file_rmap(page);
- }
-
- set_pte_at(mm, address, page_table, entry);
+ set_pte_at(mm, address, page_table, entry);
- /* No need to invalidate - it was non-present before */
- update_mmu_cache(vma, address, entry);
- lazy_mmu_prot_update(entry);
-unlock:
+ /* No need to invalidate - it was non-present before */
+ update_mmu_cache(vma, address, entry);
+ lazy_mmu_prot_update(entry);
+ } else
+ page_cache_release(page);
pte_unmap_unlock(page_table, ptl);
+
return VM_FAULT_MINOR;
-release:
- page_cache_release(page);
- goto unlock;
-oom:
- return VM_FAULT_OOM;
}
/*
--
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:[~2007-04-04 3:37 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-29 7:58 [rfc][patch 1/2] mm: dont account ZERO_PAGE Nick Piggin
2007-03-29 7:58 ` [rfc][patch 2/2] mips: reinstate move_pte Nick Piggin
2007-03-29 17:49 ` Linus Torvalds
2007-03-29 13:10 ` [rfc][patch 1/2] mm: dont account ZERO_PAGE Hugh Dickins
2007-03-30 1:46 ` Nick Piggin
2007-03-30 2:59 ` Robin Holt
2007-03-30 3:09 ` Nick Piggin
2007-03-30 9:23 ` Robin Holt
2007-03-30 2:40 ` Nick Piggin
2007-04-04 3:37 ` Nick Piggin [this message]
2007-04-04 9:45 ` [rfc] no ZERO_PAGE? Hugh Dickins
2007-04-04 10:24 ` Nick Piggin
2007-04-04 12:27 ` Andrea Arcangeli
2007-04-04 13:55 ` Dan Aloni
2007-04-04 14:14 ` Andrea Arcangeli
2007-04-04 14:44 ` Dan Aloni
2007-04-04 15:03 ` Hugh Dickins
2007-04-04 15:34 ` Andrea Arcangeli
2007-04-04 15:41 ` Hugh Dickins
2007-04-04 16:07 ` Andrea Arcangeli
2007-04-04 16:14 ` Linus Torvalds
2007-04-04 15:27 ` Andrea Arcangeli
2007-04-04 16:15 ` Dan Aloni
2007-04-04 16:48 ` Andrea Arcangeli
2007-04-04 12:45 ` Hugh Dickins
2007-04-04 13:05 ` Andrea Arcangeli
2007-04-04 13:32 ` Hugh Dickins
2007-04-04 13:40 ` Andrea Arcangeli
2007-04-04 15:35 ` Linus Torvalds
2007-04-04 15:48 ` Andrea Arcangeli
2007-04-04 16:09 ` Linus Torvalds
2007-04-04 16:23 ` Andrea Arcangeli
2007-04-04 16:10 ` Hugh Dickins
2007-04-04 16:31 ` Andrea Arcangeli
2007-04-04 22:07 ` Valdis.Kletnieks
2007-04-04 16:32 ` Eric Dumazet
2007-04-04 17:02 ` Linus Torvalds
2007-04-04 19:15 ` Andrew Morton
2007-04-04 20:11 ` David Miller, Linus Torvalds
2007-04-04 20:50 ` Andrew Morton
2007-04-05 2:03 ` Nick Piggin
2007-04-05 5:23 ` Andrea Arcangeli
2007-04-04 22:05 ` Valdis.Kletnieks
2007-04-05 0:27 ` Linus Torvalds
2007-04-05 1:25 ` Valdis.Kletnieks
2007-04-05 2:30 ` Nick Piggin
2007-04-05 5:37 ` William Lee Irwin III
2007-04-05 17:23 ` Valdis.Kletnieks
2007-04-05 4:47 ` Nick Piggin
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=20070404033726.GE18507@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=andrea@suse.de \
--cc=holt@sgi.com \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tee@sgi.com \
--cc=torvalds@linux-foundation.org \
/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