From: Andy Whitcroft <apw@shadowen.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Nick Piggin <npiggin@suse.de>,
Christoph Lameter <clameter@sgi.com>, Mel Gorman <mel@csn.ul.ie>,
Andy Whitcroft <apw@shadowen.org>
Subject: [PATCH 4/4] vmemmap ppc64: convert VMM_* macros to a real function
Date: Thu, 02 Aug 2007 10:25:56 +0100 [thread overview]
Message-ID: <E1IGWwO-0002Yc-8h@hellhawk.shadowen.org> (raw)
In-Reply-To: exportbomb.1186045945@pinky
The code to convert an address within the vmemmap to the start of the
section is currently implemented using macros. Convert these over to
a new helper function, clarifying the code and gaining type checking.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
arch/powerpc/mm/init_64.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 49c9f7c..05c7e93 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -185,14 +185,19 @@ void pgtable_cache_init(void)
#ifdef CONFIG_ARCH_POPULATES_SPARSEMEM_VMEMMAP
/*
- * Convert an address within the vmemmap into a pfn. Note that we have
- * to do this by hand as the proffered address may not be correctly aligned.
+ * Given an address within the vmemmap, determine the pfn of the page that
+ * represents the start of the section it is within. Note that we have to
+ * do this by hand as the proffered address may not be correctly aligned.
* Subtraction of non-aligned pointers produces undefined results.
*/
-#define VMM_SECTION(addr) \
- (((((unsigned long)(addr)) - ((unsigned long)(vmemmap))) / \
- sizeof(struct page)) >> PFN_SECTION_SHIFT)
-#define VMM_SECTION_PAGE(addr) (VMM_SECTION(addr) << PFN_SECTION_SHIFT)
+unsigned long __meminit vmemmap_section_start(struct page *page)
+{
+ unsigned long offset = ((unsigned long)page) -
+ ((unsigned long)(vmemmap));
+
+ /* Return the pfn of the start of the section. */
+ return (offset / sizeof(struct page)) & PAGE_SECTION_MASK;
+}
/*
* Check if this vmemmap page is already initialised. If any section
@@ -204,7 +209,7 @@ int __meminit vmemmap_populated(unsigned long start, int page_size)
unsigned long end = start + page_size;
for (; start < end; start += (PAGES_PER_SECTION * sizeof(struct page)))
- if (pfn_valid(VMM_SECTION_PAGE(start)))
+ if (pfn_valid(vmemmap_section_start(start)))
return 1;
return 0;
WARNING: multiple messages have this Message-ID (diff)
From: Andy Whitcroft <apw@shadowen.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Nick Piggin <npiggin@suse.de>,
Christoph Lameter <clameter@sgi.com>, Mel Gorman <mel@csn.ul.ie>,
Andy Whitcroft <apw@shadowen.org>
Subject: [PATCH 4/4] vmemmap ppc64: convert VMM_* macros to a real function
Date: Thu, 02 Aug 2007 10:25:56 +0100 [thread overview]
Message-ID: <E1IGWwO-0002Yc-8h@hellhawk.shadowen.org> (raw)
In-Reply-To: exportbomb.1186045945@pinky
The code to convert an address within the vmemmap to the start of the
section is currently implemented using macros. Convert these over to
a new helper function, clarifying the code and gaining type checking.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
arch/powerpc/mm/init_64.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 49c9f7c..05c7e93 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -185,14 +185,19 @@ void pgtable_cache_init(void)
#ifdef CONFIG_ARCH_POPULATES_SPARSEMEM_VMEMMAP
/*
- * Convert an address within the vmemmap into a pfn. Note that we have
- * to do this by hand as the proffered address may not be correctly aligned.
+ * Given an address within the vmemmap, determine the pfn of the page that
+ * represents the start of the section it is within. Note that we have to
+ * do this by hand as the proffered address may not be correctly aligned.
* Subtraction of non-aligned pointers produces undefined results.
*/
-#define VMM_SECTION(addr) \
- (((((unsigned long)(addr)) - ((unsigned long)(vmemmap))) / \
- sizeof(struct page)) >> PFN_SECTION_SHIFT)
-#define VMM_SECTION_PAGE(addr) (VMM_SECTION(addr) << PFN_SECTION_SHIFT)
+unsigned long __meminit vmemmap_section_start(struct page *page)
+{
+ unsigned long offset = ((unsigned long)page) -
+ ((unsigned long)(vmemmap));
+
+ /* Return the pfn of the start of the section. */
+ return (offset / sizeof(struct page)) & PAGE_SECTION_MASK;
+}
/*
* Check if this vmemmap page is already initialised. If any section
@@ -204,7 +209,7 @@ int __meminit vmemmap_populated(unsigned long start, int page_size)
unsigned long end = start + page_size;
for (; start < end; start += (PAGES_PER_SECTION * sizeof(struct page)))
- if (pfn_valid(VMM_SECTION_PAGE(start)))
+ if (pfn_valid(vmemmap_section_start(start)))
return 1;
return 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:[~2007-08-02 9:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-02 9:24 [PATCH 0/4] vmemmap updates to V6 Andy Whitcroft
2007-08-02 9:24 ` Andy Whitcroft
2007-08-02 9:24 ` [PATCH 1/4] vmemmap: remove excess debugging Andy Whitcroft
2007-08-02 9:24 ` Andy Whitcroft
2007-08-02 19:18 ` Christoph Lameter
2007-08-02 19:18 ` Christoph Lameter
2007-08-02 9:25 ` [PATCH 2/4] vmemmap: simplify initialisation code and reduce duplication Andy Whitcroft
2007-08-02 9:25 ` Andy Whitcroft
2007-08-02 9:25 ` [PATCH 3/4] vmemmap: pull out the vmemmap code into its own file Andy Whitcroft
2007-08-02 9:25 ` Andy Whitcroft
2007-08-02 13:26 ` Christoph Hellwig
2007-08-02 13:26 ` Christoph Hellwig
2007-08-02 19:28 ` Christoph Lameter
2007-08-02 19:28 ` Christoph Lameter
2007-08-03 14:57 ` Andy Whitcroft
2007-08-03 14:57 ` Andy Whitcroft
2007-08-03 16:58 ` Christoph Lameter
2007-08-03 16:58 ` Christoph Lameter
2007-08-02 9:25 ` Andy Whitcroft [this message]
2007-08-02 9:25 ` [PATCH 4/4] vmemmap ppc64: convert VMM_* macros to a real function Andy Whitcroft
2007-08-02 16:31 ` Dave Hansen
2007-08-02 16:31 ` Dave Hansen
2007-08-02 17:39 ` Andy Whitcroft
2007-08-02 17:39 ` Andy Whitcroft
2007-08-02 18:00 ` Dave Hansen
2007-08-02 18:00 ` Dave Hansen
2007-08-02 19:30 ` Christoph Lameter
2007-08-02 19:30 ` Christoph Lameter
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=E1IGWwO-0002Yc-8h@hellhawk.shadowen.org \
--to=apw@shadowen.org \
--cc=akpm@linux-foundation.org \
--cc=clameter@sgi.com \
--cc=hch@infradead.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=npiggin@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.