From: Real Name <enjoymindful@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Richard Weinberger <richard@nod.at>,
uml-devel <user-mode-linux-devel@lists.sourceforge.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] delete unnecessary bootmem struct page array
Date: Mon, 16 Jun 2014 18:30:36 +0800 [thread overview]
Message-ID: <20140616103036.GA3999@name> (raw)
In-Reply-To: <CAMuHMdV9SA0zZz0u=VKWWXNRL186hunrMYuZ=RUcAjqRes8r8A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
On Mon, Jun 16, 2014 at 11:15:23AM +0200, Geert Uytterhoeven wrote:
> On Mon, Jun 16, 2014 at 10:28 AM, Real Name <enjoymindful@gmail.com> wrote:
> >> > >> Can you please include in the changelog the commit sha1 which made the old init_maps() obsolete?
hi,
The commit sha1 had been included as required. Please review the attached patch.
I only update the changlog of the patch.
thanks
> >
> > I think we need find out which commit deleted the line "mem_map = map;" in init_maps function.
>
>
> v2.6.12-rc1
>
> commit 5678d7fc97ac75f7401ce77897773cc0bb3afee5
Geert, thank you.
> Author: Dave Hansen <haveblue@us.ibm.com>
> Date: Sun Mar 13 00:22:56 2005 -0800
>
> [PATCH] no arch-specific mem_map init
>
[-- Attachment #2: 0001-UML-delete-unnecessary-bootmem-struct-page-array.patch --]
[-- Type: text/x-diff, Size: 3817 bytes --]
>From 29e5e83f8f3988ea1396d61b4d5764e7904f82c5 Mon Sep 17 00:00:00 2001
From: Honggang Li <enjoymindful@gmail.com>
Date: Mon, 16 Jun 2014 18:05:47 +0800
Subject: [PATCH] UML delete unnecessary bootmem struct page array
1) uml kernel bootmem managed through bootmem_data->node_bootmem_map,
not the struct page array, so the array is unnecessary.
2) the bootmem struct page array has been pointed by a *local* pointer,
struct page *map, in init_maps function. The array can be accessed only
in init_maps's scope. As a result, uml kernel wastes about 1% of total
memory.
3) commit 5678d7fc97ac75f7401ce77897773cc0bb3afee5 obsoleted
the init_maps function.
Signed-off-by: Honggang Li <enjoymindful@gmail.com>
---
arch/um/include/shared/mem_user.h | 2 +-
arch/um/kernel/physmem.c | 32 ++++++--------------------------
arch/um/kernel/um_arch.c | 7 +------
3 files changed, 8 insertions(+), 33 deletions(-)
diff --git a/arch/um/include/shared/mem_user.h b/arch/um/include/shared/mem_user.h
index 46384ac..cb84414 100644
--- a/arch/um/include/shared/mem_user.h
+++ b/arch/um/include/shared/mem_user.h
@@ -49,7 +49,7 @@ extern int iomem_size;
extern int init_mem_user(void);
extern void setup_memory(void *entry);
extern unsigned long find_iomem(char *driver, unsigned long *len_out);
-extern int init_maps(unsigned long physmem, unsigned long iomem,
+extern void mem_total_pages(unsigned long physmem, unsigned long iomem,
unsigned long highmem);
extern unsigned long get_vm(unsigned long len);
extern void setup_physmem(unsigned long start, unsigned long usable,
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 30fdd5d..549ecf3 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -22,39 +22,19 @@ EXPORT_SYMBOL(high_physmem);
extern unsigned long long physmem_size;
-int __init init_maps(unsigned long physmem, unsigned long iomem,
+void __init mem_total_pages(unsigned long physmem, unsigned long iomem,
unsigned long highmem)
{
- struct page *p, *map;
- unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
- unsigned long iomem_len, iomem_pages, total_len, total_pages;
- int i;
-
- phys_pages = physmem >> PAGE_SHIFT;
- phys_len = phys_pages * sizeof(struct page);
-
- iomem_pages = iomem >> PAGE_SHIFT;
- iomem_len = iomem_pages * sizeof(struct page);
+ unsigned long phys_pages, highmem_pages;
+ unsigned long iomem_pages, total_pages;
+ phys_pages = physmem >> PAGE_SHIFT;
+ iomem_pages = iomem >> PAGE_SHIFT;
highmem_pages = highmem >> PAGE_SHIFT;
- highmem_len = highmem_pages * sizeof(struct page);
-
- total_pages = phys_pages + iomem_pages + highmem_pages;
- total_len = phys_len + iomem_len + highmem_len;
- map = alloc_bootmem_low_pages(total_len);
- if (map == NULL)
- return -ENOMEM;
-
- for (i = 0; i < total_pages; i++) {
- p = &map[i];
- memset(p, 0, sizeof(struct page));
- SetPageReserved(p);
- INIT_LIST_HEAD(&p->lru);
- }
+ total_pages = phys_pages + iomem_pages + highmem_pages;
max_mapnr = total_pages;
- return 0;
}
void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 6043c76..dbd5bda 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -338,12 +338,7 @@ int __init linux_main(int argc, char **argv)
start_vm = VMALLOC_START;
setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem);
- if (init_maps(physmem_size, iomem_size, highmem)) {
- printf("Failed to allocate mem_map for %Lu bytes of physical "
- "memory and %Lu bytes of highmem\n", physmem_size,
- highmem);
- exit(1);
- }
+ mem_total_pages(physmem_size, iomem_size, highmem);
virtmem_size = physmem_size;
stack = (unsigned long) argv;
--
1.8.3.1
next prev parent reply other threads:[~2014-06-16 10:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 5:30 [PATCH v2] delete unnecessary bootmem struct page array Real Name
2014-06-03 5:30 ` [PATCH] " Real Name
2014-06-09 5:49 ` [PATCH v2] " Real Name
2014-06-09 8:59 ` [uml-devel] " Toralf Förster
2014-06-14 9:44 ` Richard Weinberger
2014-06-16 3:28 ` Real Name
2014-06-16 6:50 ` Richard Weinberger
2014-06-16 8:12 ` Real Name
2014-06-16 8:28 ` Real Name
2014-06-16 9:15 ` Geert Uytterhoeven
2014-06-16 10:30 ` Real Name [this message]
2014-07-17 23:10 ` Real Name
2014-06-16 6:58 ` [uml-devel] " Geert Uytterhoeven
2014-06-16 7:21 ` Paul Bolle
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=20140616103036.GA3999@name \
--to=enjoymindful@gmail.com \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@nod.at \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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