linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	npiggin@suse.de,
	"hugh.dickins@tiscali.co.uk" <hugh.dickins@tiscali.co.uk>,
	avi@redhat.com,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	torvalds@linux-foundation.org
Subject: [RFC][PATCH 1/4] introduce pte_zero()
Date: Tue, 7 Jul 2009 16:52:49 +0900	[thread overview]
Message-ID: <20090707165249.785298cf.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090707165101.8c14b5ac.kamezawa.hiroyu@jp.fujitsu.com>

initializng zero_page_pfn is not clean yet...

==
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

Add some helper functions for supporing zero-page again.
This patch itself adss some tiny functions but no behavior change.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
 include/linux/mm.h |   20 ++++++++++++++++++++
 mm/memory.c        |    8 ++++++++
 2 files changed, 28 insertions(+)

Index: zeropage-trial/include/linux/mm.h
===================================================================
--- zeropage-trial.orig/include/linux/mm.h
+++ zeropage-trial/include/linux/mm.h
@@ -822,6 +822,26 @@ static inline int handle_mm_fault(struct
 }
 #endif
 
+/*
+ * ZERO page is used for read-only(never write) private page mapping. It's not
+ * usually used but sometimes useful at maping /dev/zero or at scanning
+ * sparsely used big private memory or at calculation.with sparse matrix where
+ * most of entries are zero. ZERO page is not refcounted and exists as
+ * PG_reserved page. zero_page_pfn is pfn of ZERO_PAGE(0).
+ */
+
+extern unsigned long zero_page_pfn;
+static inline int pte_zero(pte_t pte)
+{
+	return (pte_pfn(pte) == zero_page_pfn);
+}
+
+static inline int page_is_zero(struct page *page)
+{
+	return page == ZERO_PAGE(0);
+}
+
+
 extern int make_pages_present(unsigned long addr, unsigned long end);
 extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
 
Index: zeropage-trial/mm/memory.c
===================================================================
--- zeropage-trial.orig/mm/memory.c
+++ zeropage-trial/mm/memory.c
@@ -106,6 +106,14 @@ static int __init disable_randmaps(char 
 }
 __setup("norandmaps", disable_randmaps);
 
+unsigned long zero_page_pfn __read_mostly;
+static int __init zeropage_init(void)
+{
+	zero_page_pfn = page_to_pfn(ZERO_PAGE(0));
+	return 0;
+}
+__initcall(zeropage_init);
+
 
 /*
  * If a p?d_bad entry is found while walking page tables, report

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

  reply	other threads:[~2009-07-07  7:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  7:51 [RFC][PATCH 0/4] ZERO PAGE again v2 KAMEZAWA Hiroyuki
2009-07-07  7:52 ` KAMEZAWA Hiroyuki [this message]
2009-07-07  7:54 ` [RFC][PATCH 2/4] use ZERO_PAGE for READ fault in regular anonymous mapping KAMEZAWA Hiroyuki
2009-07-07  7:59 ` [RFC][PATCH 3/4] get_user_pages READ fault handling special cases KAMEZAWA Hiroyuki
2009-07-07 16:50   ` Linus Torvalds
2009-07-08  0:03     ` KAMEZAWA Hiroyuki
2009-07-08  1:38       ` KAMEZAWA Hiroyuki
2009-07-08  2:27         ` Linus Torvalds
2009-07-07  8:01 ` [RFC][PATCH 4/4] add get user pages nozero KAMEZAWA Hiroyuki
2009-07-07  8:47 ` [RFC][PATCH 0/4] ZERO PAGE again v2 Nick Piggin
2009-07-07  9:05   ` Avi Kivity
2009-07-07  9:18     ` KAMEZAWA Hiroyuki
2009-07-07  9:26       ` Avi Kivity
2009-07-07  9:06   ` KAMEZAWA Hiroyuki
2009-07-07 14:00     ` Nick Piggin
2009-07-07 16:59       ` Linus Torvalds
2009-07-08  6:21         ` Nick Piggin
2009-07-08 16:07           ` Linus Torvalds
2009-07-09  7:47             ` Nick Piggin
2009-07-09 17:54               ` Linus Torvalds
2009-07-10  2:09                 ` Nick Piggin
2009-07-10  3:38                   ` Linus Torvalds
2009-07-10  3:51                     ` Nick Piggin
2009-07-08 17:32     ` Andrea Arcangeli
2009-07-09  1:12       ` KAMEZAWA Hiroyuki
2009-07-10 11:18       ` Hugh Dickins
2009-07-10 13:42         ` Andrea Arcangeli
2009-07-10 14:12           ` KAMEZAWA Hiroyuki
2009-07-10 15:16             ` Andrea Arcangeli
2009-07-10 15:32               ` KAMEZAWA Hiroyuki
2009-07-10 17:09           ` Hugh Dickins
2009-07-13  6:46         ` Nick Piggin
2009-07-13  7:24           ` 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=20090707165249.785298cf.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=avi@redhat.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --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