[RFC PATCH v2, part4 00/39] Simplify mem_init() implementations and kill num_physpages

2013-03-24 Thread Jiang Liu
The original goal of this patchset is to fix the bug reported by
https://bugzilla.kernel.org/show_bug.cgi?id=53501
Now it has also been expanded to reduce common code used by memory
initializion.

This is the last part, previous three patch sets could be accessed at:
http://marc.info/?l=linux-mm&m=136289696323825&w=2
http://marc.info/?l=linux-mm&m=136290291524901&w=2
http://marc.info/?l=linux-mm&m=136345342831592&w=2

This patchset applies to
https://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git since-3.8

Patch 1-7: 
1) add comments for global variables exported by vmlinux.lds
2) normalize global variables exported by vmlinux.lds
Patch 8:
Introduce helper functions mem_init_print_info() and
get_num_physpages()
Patch 9:
Avoid using num_physpages at runtime
Patch 10-38:
1) Simplify mem_init() by using mem_init_print_info()
2) Prepare fore kill global variable num_physpages
Patch 39:
Kill global variable num_physpages

With all patches applied, mem_init(), free_initmem(), free_initrd_mem()
could be as simple as below. This patch series has reduced about 1.2K
lines of code in total.

#ifndef CONFIG_DISCONTIGMEM
void __init
mem_init(void)
{
max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);

mem_init_print_info(NULL);
}
#endif /* CONFIG_DISCONTIGMEM */

void
free_initmem(void)
{
free_initmem_default(-1);
}

#ifdef CONFIG_BLK_DEV_INITRD
void
free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area(start, end, -1, "initrd");
}
#endif

Due to hardware resource limitations, I have only tested this on x86_64.
And the messages reported are:
Previous log message:
Memory: 7745676k/8910848k available (6934k kernel code, 836024k absent, 329148k 
reserved, 6343k data, 1012k init)
Current log message:
Memory: 7744624K/8074824K available (6969K kernel code, 1011K data, 2828K 
rodata, 1016K init, 9640K bss, 330200K reserved)

Any help to review or test these patch series are welcomed!

Jiang Liu (39):
  vmlinux.lds: add comments for global variables and clean up useless
declarations
  avr32: normalize global variables exported by vmlinux.lds
  c6x: normalize global variables exported by vmlinux.lds
  h8300: normalize global variables exported by vmlinux.lds
  score: normalize global variables exported by vmlinux.lds
  tile: normalize global variables exported by vmlinux.lds
  UML: normalize global variables exported by vmlinux.lds
  mm: introduce helper function mem_init_print_info() to simplify
mem_init()
  mm: use totalram_pages instead of num_physpages at runtime
  mm/alpha: prepare for removing num_physpages and simplify mem_init()
  mm/ARM: prepare for removing num_physpages and simplify mem_init()
  mm/ARM64: prepare for removing num_physpages and simplify mem_init()
  mm/AVR32: prepare for removing num_physpages and simplify mem_init()
  mm/blackfin: prepare for removing num_physpages and simplify
mem_init()
  mm/c6x: prepare for removing num_physpages and simplify mem_init()
  mm/cris: prepare for removing num_physpages and simplify mem_init()
  mm/frv: prepare for removing num_physpages and simplify mem_init()
  mm/h8300: prepare for removing num_physpages and simplify mem_init()
  mm/hexagon: prepare for removing num_physpages and simplify
mem_init()
  mm/IA64: prepare for removing num_physpages and simplify mem_init()
  mm/m32r: prepare for removing num_physpages and simplify mem_init()
  mm/m68k: prepare for removing num_physpages and simplify mem_init()
  mm/microblaze: prepare for removing num_physpages and simplify
mem_init()
  mm/MIPS: prepare for removing num_physpages and simplify mem_init()
  mm/mn10300: prepare for removing num_physpages and simplify
mem_init()
  mm/openrisc: prepare for removing num_physpages and simplify
mem_init()
  mm/PARISC: prepare for removing num_physpages and simplify mem_init()
  mm/ppc: prepare for removing num_physpages and simplify mem_init()
  mm/s390: prepare for removing num_physpages and simplify mem_init()
  mm/score: prepare for removing num_physpages and simplify mem_init()
  mm/SH: prepare for removing num_physpages and simplify mem_init()
  mm/SPARC: prepare for removing num_physpages and simplify mem_init()
  mm/tile: prepare for removing num_physpages and simplify mem_init()
  mm/um: prepare for removing num_physpages and simplify mem_init()
  mm/unicore32: prepare for removing num_physpages and simplify
mem_init()
  mm/x86: prepare for removing num_physpages and simplify mem_init()
  mm/xtensa: prepare for removing num_physpages and simplify mem_init()
  mm/hotplug: prepare for removing num_physpages
  mm: kill global variable num_physpages

 arch/alpha/mm/init.c  |   32 ++---
 arch/alpha/mm/numa.c  |   34 --
 arch/arm/mm/init.c|   47 ++
 arch/a

[RFC PATCH v2, part4 03/39] c6x: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Normalize global variables exported by vmlinux.lds to conform usage
guidelines from include/asm-generic/sections.h.

Use _text to mark the start of the kernel image including the head text,
and _stext to mark the start of the .text section.

This patch also fixes possible bugs due to current address layout that
[__init_begin, __init_end] is a sub-range of [_stext, _etext] and pages
within range [__init_begin, __init_end] will be freed by free_initmem().

Signed-off-by: Jiang Liu 
Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Cc: linux-c6x-...@linux-c6x.org
Cc: linux-kernel@vger.kernel.org
---
 arch/c6x/kernel/vmlinux.lds.S |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/c6x/kernel/vmlinux.lds.S b/arch/c6x/kernel/vmlinux.lds.S
index 1d81c4c..279d807 100644
--- a/arch/c6x/kernel/vmlinux.lds.S
+++ b/arch/c6x/kernel/vmlinux.lds.S
@@ -54,16 +54,15 @@ SECTIONS
}
 
. = ALIGN(PAGE_SIZE);
+   __init_begin = .;
.init :
{
-   _stext = .;
_sinittext = .;
HEAD_TEXT
INIT_TEXT
_einittext = .;
}
 
-   __init_begin = _stext;
INIT_DATA_SECTION(16)
 
PERCPU_SECTION(128)
@@ -74,6 +73,7 @@ SECTIONS
.text :
{
_text = .;
+   _stext = .;
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 05/39] score: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Generate mandatory global variables _sdata in file vmlinux.lds.

Signed-off-by: Jiang Liu 
Cc: Chen Liqin 
Cc: Lennox Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/score/kernel/vmlinux.lds.S |1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/score/kernel/vmlinux.lds.S b/arch/score/kernel/vmlinux.lds.S
index eebcbaa..7274b5c 100644
--- a/arch/score/kernel/vmlinux.lds.S
+++ b/arch/score/kernel/vmlinux.lds.S
@@ -49,6 +49,7 @@ SECTIONS
}
 
. = ALIGN(16);
+   _sdata =  .;/* Start of data section */
RODATA
 
EXCEPTION_TABLE(16)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 06/39] tile: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Normalize global variables exported by vmlinux.lds to conform usage
guidelines from include/asm-generic/sections.h.

1) Use _text to mark the start of the kernel image including the head
text, and _stext to mark the start of the .text section.
2) Export mandatory global variables __init_begin and __init_end.

Signed-off-by: Jiang Liu 
Cc: Chris Metcalf 
Cc: Rusty Russell 
Cc: Bjorn Helgaas 
Cc: "David S. Miller" 
Cc: Wen Congyang 
Cc: David Howells 
Cc: linux-kernel@vger.kernel.org
---
 arch/tile/include/asm/sections.h |2 +-
 arch/tile/kernel/setup.c |4 ++--
 arch/tile/kernel/vmlinux.lds.S   |4 +++-
 arch/tile/mm/init.c  |2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/tile/include/asm/sections.h b/arch/tile/include/asm/sections.h
index d062d46..7d8a935 100644
--- a/arch/tile/include/asm/sections.h
+++ b/arch/tile/include/asm/sections.h
@@ -34,7 +34,7 @@ extern char __sys_cmpxchg_grab_lock[];
 extern char __start_atomic_asm_code[], __end_atomic_asm_code[];
 #endif
 
-/* Handle the discontiguity between _sdata and _stext. */
+/* Handle the discontiguity between _sdata and _text. */
 static inline int arch_is_kernel_data(unsigned long addr)
 {
return addr >= (unsigned long)_sdata &&
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index d1e15f7..a986b71 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -307,8 +307,8 @@ static void __cpuinit store_permanent_mappings(void)
hv_store_mapping(addr, pages << PAGE_SHIFT, pa);
}
 
-   hv_store_mapping((HV_VirtAddr)_stext,
-(uint32_t)(_einittext - _stext), 0);
+   hv_store_mapping((HV_VirtAddr)_text,
+(uint32_t)(_einittext - _text), 0);
 }
 
 /*
diff --git a/arch/tile/kernel/vmlinux.lds.S b/arch/tile/kernel/vmlinux.lds.S
index 631f10d..a13ed90 100644
--- a/arch/tile/kernel/vmlinux.lds.S
+++ b/arch/tile/kernel/vmlinux.lds.S
@@ -27,7 +27,6 @@ SECTIONS
   .intrpt1 (LOAD_OFFSET) : AT ( 0 )   /* put at the start of physical memory */
   {
 _text = .;
-_stext = .;
 *(.intrpt1)
   } :intrpt1 =0
 
@@ -36,6 +35,7 @@ SECTIONS
 
   /* Now the real code */
   . = ALIGN(0x2);
+  _stext = .;
   .text : AT (ADDR(.text) - LOAD_OFFSET) {
 HEAD_TEXT
 SCHED_TEXT
@@ -58,11 +58,13 @@ SECTIONS
   #define LOAD_OFFSET PAGE_OFFSET
 
   . = ALIGN(PAGE_SIZE);
+  __init_begin = .;
   VMLINUX_SYMBOL(_sinitdata) = .;
   INIT_DATA_SECTION(16) :data =0
   PERCPU_SECTION(L2_CACHE_BYTES)
   . = ALIGN(PAGE_SIZE);
   VMLINUX_SYMBOL(_einitdata) = .;
+  __init_end = .;
 
   _sdata = .;   /* Start of data section */
 
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 45ce26d..f2ac2f4 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -562,7 +562,7 @@ static void __init kernel_physical_mapping_init(pgd_t 
*pgd_base)
prot = ktext_set_nocache(prot);
}
 
-   BUG_ON(address != (unsigned long)_stext);
+   BUG_ON(address != (unsigned long)_text);
pte = NULL;
for (; address < (unsigned long)_einittext;
 pfn++, address += PAGE_SIZE) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 07/39] UML: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Normalize global variables exported by vmlinux.lds to conform usage
guidelines from include/asm-generic/sections.h.

1) Use _text to mark the start of the kernel image including the head
text, and _stext to mark the start of the .text section.
2) Export mandatory global variables __bss_stop.
3) Adjust __init_begin and __init_end to avoid acrossing .text and
   .data sections.

Signed-off-by: Jiang Liu 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: Al Viro 
Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
---
 arch/um/include/asm/common.lds.S |1 -
 arch/um/kernel/dyn.lds.S |6 --
 arch/um/kernel/uml.lds.S |7 +--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
index 4938de5..1dd5bd8 100644
--- a/arch/um/include/asm/common.lds.S
+++ b/arch/um/include/asm/common.lds.S
@@ -57,7 +57,6 @@
*(.uml.initcall.init)
__uml_initcall_end = .;
   }
-  __init_end = .;
 
   SECURITY_INIT
 
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index fb8fd6f..adde088 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -14,8 +14,6 @@ SECTIONS
   __binary_start = .;
   . = ALIGN(4096); /* Init code and data */
   _text = .;
-  _stext = .;
-  __init_begin = .;
   INIT_TEXT_SECTION(PAGE_SIZE)
 
   . = ALIGN(PAGE_SIZE);
@@ -67,6 +65,7 @@ SECTIONS
   } =0x90909090
   .plt: { *(.plt) }
   .text   : {
+_stext = .;
 TEXT_TEXT
 SCHED_TEXT
 LOCK_TEXT
@@ -91,7 +90,9 @@ SECTIONS
 
   #include 
 
+  __init_begin = .;
   init.data : { INIT_DATA }
+  __init_end = .;
 
   /* Ensure the __preinit_array_start label is properly aligned.  We
  could instead move the label definition inside the section, but
@@ -155,6 +156,7 @@ SECTIONS
. = ALIGN(32 / 8);
   . = ALIGN(32 / 8);
   }
+   __bss_stop = .;
   _end = .;
   PROVIDE (end = .);
 
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index ff65fb4..6899195 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -20,13 +20,12 @@ SECTIONS
   . = START + SIZEOF_HEADERS;
 
   _text = .;
-  _stext = .;
-  __init_begin = .;
   INIT_TEXT_SECTION(0)
   . = ALIGN(PAGE_SIZE);
 
   .text  :
   {
+_stext = .;
 TEXT_TEXT
 SCHED_TEXT
 LOCK_TEXT
@@ -62,7 +61,10 @@ SECTIONS
 
   #include 
 
+  __init_begin = .;
   init.data : { INIT_DATA }
+  __init_end = .;
+
   .data:
   {
 INIT_TASK_DATA(KERNEL_STACK_SIZE)
@@ -97,6 +99,7 @@ SECTIONS
   PROVIDE(_bss_start = .);
   SBSS(0)
   BSS(0)
+   __bss_stop = .;
   _end = .;
   PROVIDE (end = .);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 08/39] mm: introduce helper function mem_init_print_info() to simplify mem_init()

2013-03-24 Thread Jiang Liu
Introduce helper function mem_init_print_info() to simplify mem_init()
across different architectures, which also unifies the format and
information printed.

Function mem_init_print_info() calculates memory statistics information
without walking each page, so it should be a little faster on some
architectures.

Also introduce another helper get_num_physpages() to kill the global
variable num_physpages.

Signed-off-by: Jiang Liu 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: Michel Lespinasse 
Cc: Rik van Riel 
Cc: Minchan Kim 
Cc: Marek Szyprowski 
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 include/linux/mm.h |   12 
 mm/page_alloc.c|   52 
 2 files changed, 64 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c03d029..c225a4f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1312,6 +1312,7 @@ extern void free_highmem_page(struct page *page);
 #endif
 
 extern void adjust_managed_page_count(struct page *page, long count);
+extern void mem_init_print_info(const char *str);
 
 /* Free the reserved page into the buddy system, so it gets managed. */
 static inline void __free_reserved_page(struct page *page)
@@ -1348,6 +1349,17 @@ static inline unsigned long free_initmem_default(int 
poison)
  poison, "unused kernel");
 }
 
+static inline unsigned long get_num_physpages(void)
+{
+   int nid;
+   unsigned long phys_pages = 0;
+
+   for_each_online_node(nid)
+   phys_pages += node_present_pages(nid);
+
+   return phys_pages;
+}
+
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /*
  * With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ebfb042..577acec 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -59,6 +59,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include "internal.h"
@@ -5168,6 +5169,57 @@ void free_highmem_page(struct page *page)
 }
 #endif
 
+
+void __init mem_init_print_info(const char *str)
+{
+   unsigned long physpages, codesize, datasize, rosize;
+   unsigned long init_code_size, init_data_size;
+
+   physpages = get_num_physpages();
+   codesize = _etext - _stext;
+   datasize = _edata - _sdata;
+   rosize = __end_rodata - __start_rodata;
+   init_data_size = __init_end - __init_begin;
+   init_code_size = _einittext - _sinittext;
+
+   /*
+* Detect special cases and adjust section sizes accordingly:
+* 1) .init.* may be embedded into .data sections
+* 2) .init.text.* may be out of [__init_begin, __init_end],
+*please refer to arch/tile/kernel/vmlinux.lds.S.
+* 3) .rodata.* may be embedded into .text or .data sections.
+*/
+#define adj_init_size(start, end, size, pos, adj) \
+   if (start <= pos && pos < end && size > adj) \
+   size -= adj;
+
+   adj_init_size(__init_begin, __init_end, init_data_size,
+_sinittext, init_code_size);
+   adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size);
+   adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size);
+   adj_init_size(_stext, _etext, codesize, __start_rodata, rosize);
+   adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize);
+
+#undef adj_init_size
+
+   printk("Memory: %luK/%luK available "
+  "(%luK kernel code, %luK data, %luK rodata, "
+  "%luK init, %luK bss, %luK reserved"
+#ifdef CONFIG_HIGHMEM
+  ", %luK highmem"
+#endif
+  "%s%s)\n",
+  nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
+  codesize >> 10, datasize >> 10, rosize >> 10,
+  (init_data_size + init_code_size) >> 10,
+  (__bss_stop - __bss_start) >> 10,
+  (physpages - totalram_pages) << (PAGE_SHIFT-10),
+#ifdef CONFIG_HIGHMEM
+  totalhigh_pages << (PAGE_SHIFT-10),
+#endif
+  str ? ", " : "", str ? str : "");
+}
+
 /**
  * set_dma_reserve - set the specified number of pages reserved in the first 
zone
  * @new_dma_reserve: The number of pages to mark reserved
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 09/39] mm/alpha: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Matt Turner 
Cc: David Howells 
Cc: linux-al...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/alpha/mm/init.c |   32 ++--
 arch/alpha/mm/numa.c |   34 +-
 2 files changed, 7 insertions(+), 59 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index ca07a97..04c933c 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -277,42 +277,14 @@ srm_paging_stop (void)
 #endif
 
 #ifndef CONFIG_DISCONTIGMEM
-static void __init
-printk_memory_info(void)
-{
-   unsigned long codesize, reservedpages, datasize, initsize, tmp;
-   extern int page_is_ram(unsigned long) __init;
-
-   /* printk all informations */
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages
-*/
-   if (page_is_ram(tmp) && PageReserved(mem_map+tmp))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_data;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk("Memory: %luk/%luk available (%luk kernel code, %luk reserved, 
%luk data, %luk init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  max_mapnr << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10);
-}
-
 void __init
 mem_init(void)
 {
-   max_mapnr = num_physpages = max_low_pfn;
+   max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
-   printk_memory_info();
+   mem_init_print_info(NULL);
 }
 #endif /* CONFIG_DISCONTIGMEM */
 
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 857452c..e5086fc 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -129,8 +129,6 @@ setup_memory_node(int nid, void *kernel_end)
if (node_max_pfn > max_low_pfn)
max_pfn = max_low_pfn = node_max_pfn;
 
-   num_physpages += node_max_pfn - node_min_pfn;
-
 #if 0 /* we'll try this one again in a little while */
/* Cute trick to make sure our local node data is on local memory */
node_data[nid] = (pg_data_t *)(__va(node_min_pfn << PAGE_SHIFT));
@@ -324,37 +322,15 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize, pfn;
-   extern int page_is_ram(unsigned long) __init;
-   unsigned long nid, i;
+   unsigned long nid;
+
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
-   reservedpages = 0;
-   for_each_online_node(nid) {
-   /*
-* This will free up the bootmem, ie, slot 0 memory
-*/
+   /* This will free up the bootmem, ie, slot 0 memory */
+   for_each_online_node(nid)
free_all_bootmem_node(NODE_DATA(nid));
 
-   pfn = NODE_DATA(nid)->node_start_pfn;
-   for (i = 0; i < node_spanned_pages(nid); i++, pfn++)
-   if (page_is_ram(pfn) &&
-   PageReserved(nid_page_nr(nid, i)))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_data;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk("Memory: %luk/%luk available (%luk kernel code, %luk reserved, "
-  "%luk data, %luk init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  num_physpages << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10);
+   mem_init_print_info(NULL);
 #if 0
mem_stress();
 #endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 09/39] mm: use totalram_pages instead of num_physpages at runtime

2013-03-24 Thread Jiang Liu
The global variable num_physpages is scheduled to be removed, so use
totalram_pages instead of num_physpages at runtime.

Signed-off-by: Jiang Liu 
Cc: Miklos Szeredi 
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: James Morris 
Cc: Hideaki YOSHIFUJI 
Cc: Patrick McHardy 
Cc: fuse-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Cc: net...@vger.kernel.org
---
 fs/fuse/inode.c  |2 +-
 kernel/power/snapshot.c  |4 ++--
 net/ipv4/inet_fragment.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index b730fda..4c2a420 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -781,7 +781,7 @@ static const struct super_operations fuse_super_operations 
= {
 static void sanitize_global_limit(unsigned *limit)
 {
if (*limit == 0)
-   *limit = ((num_physpages << PAGE_SHIFT) >> 13) /
+   *limit = ((totalram_pages << PAGE_SHIFT) >> 13) /
 sizeof(struct fuse_req);
 
if (*limit >= 1 << 16)
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 0de2857..8b5d1cd 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1651,7 +1651,7 @@ unsigned long snapshot_get_image_size(void)
 static int init_header(struct swsusp_info *info)
 {
memset(info, 0, sizeof(struct swsusp_info));
-   info->num_physpages = num_physpages;
+   info->num_physpages = get_num_physpages();
info->image_pages = nr_copy_pages;
info->pages = snapshot_get_image_size();
info->size = info->pages;
@@ -1795,7 +1795,7 @@ static int check_header(struct swsusp_info *info)
char *reason;
 
reason = check_image_kernel(info);
-   if (!reason && info->num_physpages != num_physpages)
+   if (!reason && info->num_physpages != get_num_physpages())
reason = "memory size";
if (reason) {
printk(KERN_ERR "PM: Image mismatch: %s\n", reason);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 4750d2b..94a99a1 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -60,7 +60,7 @@ void inet_frags_init(struct inet_frags *f)
 
rwlock_init(&f->lock);
 
-   f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^
+   f->rnd = (u32) ((totalram_pages ^ (totalram_pages>>7)) ^
   (jiffies ^ (jiffies >> 6)));
 
setup_timer(&f->secret_timer, inet_frag_secret_rebuild,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 10/39] mm/alpha: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Matt Turner 
Cc: David Howells 
Cc: linux-al...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/alpha/mm/init.c |   32 ++--
 arch/alpha/mm/numa.c |   34 +-
 2 files changed, 7 insertions(+), 59 deletions(-)

diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index ca07a97..04c933c 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -277,42 +277,14 @@ srm_paging_stop (void)
 #endif
 
 #ifndef CONFIG_DISCONTIGMEM
-static void __init
-printk_memory_info(void)
-{
-   unsigned long codesize, reservedpages, datasize, initsize, tmp;
-   extern int page_is_ram(unsigned long) __init;
-
-   /* printk all informations */
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages
-*/
-   if (page_is_ram(tmp) && PageReserved(mem_map+tmp))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_data;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk("Memory: %luk/%luk available (%luk kernel code, %luk reserved, 
%luk data, %luk init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  max_mapnr << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10);
-}
-
 void __init
 mem_init(void)
 {
-   max_mapnr = num_physpages = max_low_pfn;
+   max_mapnr = max_low_pfn;
free_all_bootmem();
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
-   printk_memory_info();
+   mem_init_print_info(NULL);
 }
 #endif /* CONFIG_DISCONTIGMEM */
 
diff --git a/arch/alpha/mm/numa.c b/arch/alpha/mm/numa.c
index 857452c..e5086fc 100644
--- a/arch/alpha/mm/numa.c
+++ b/arch/alpha/mm/numa.c
@@ -129,8 +129,6 @@ setup_memory_node(int nid, void *kernel_end)
if (node_max_pfn > max_low_pfn)
max_pfn = max_low_pfn = node_max_pfn;
 
-   num_physpages += node_max_pfn - node_min_pfn;
-
 #if 0 /* we'll try this one again in a little while */
/* Cute trick to make sure our local node data is on local memory */
node_data[nid] = (pg_data_t *)(__va(node_min_pfn << PAGE_SHIFT));
@@ -324,37 +322,15 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize, pfn;
-   extern int page_is_ram(unsigned long) __init;
-   unsigned long nid, i;
+   unsigned long nid;
+
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
 
-   reservedpages = 0;
-   for_each_online_node(nid) {
-   /*
-* This will free up the bootmem, ie, slot 0 memory
-*/
+   /* This will free up the bootmem, ie, slot 0 memory */
+   for_each_online_node(nid)
free_all_bootmem_node(NODE_DATA(nid));
 
-   pfn = NODE_DATA(nid)->node_start_pfn;
-   for (i = 0; i < node_spanned_pages(nid); i++, pfn++)
-   if (page_is_ram(pfn) &&
-   PageReserved(nid_page_nr(nid, i)))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_data;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk("Memory: %luk/%luk available (%luk kernel code, %luk reserved, "
-  "%luk data, %luk init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  num_physpages << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10);
+   mem_init_print_info(NULL);
 #if 0
mem_stress();
 #endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 10/39] mm/ARM: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mm/init.c |   47 ++-
 1 file changed, 2 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 5925861..8f69924 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -582,9 +582,6 @@ static void __init free_highpages(void)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-   int i;
 #ifdef CONFIG_HAVE_TCM
/* These pointers are filled in on TCM detection */
extern u32 dtcm_end;
@@ -604,47 +601,7 @@ void __init mem_init(void)
 
free_highpages();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_bank(i, &meminfo) {
-   struct membank *bank = &meminfo.bank[i];
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = bank_pfn_start(bank);
-   pfn2 = bank_pfn_end(bank);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the
-* real number of pages we have in this system
-*/
-   printk(KERN_INFO "Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK 
highmem\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   free_pages << (PAGE_SHIFT-10),
-   reserved_pages << (PAGE_SHIFT-10),
-   totalhigh_pages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
 
 #define MLK(b, t) b, t, ((t) - (b)) >> 10
 #define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -710,7 +667,7 @@ void __init mem_init(void)
BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE  > PAGE_OFFSET);
 #endif
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
 * On a machine this small we won't get
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 11/39] mm/ARM64: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm64/mm/init.c |   48 +++-
 1 file changed, 3 insertions(+), 45 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 0f2cf5d..821e788 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -272,59 +272,17 @@ static void __init free_unused_memmap(void)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-
arm64_swiotlb_init();
 
max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
 #ifndef CONFIG_SPARSEMEM_VMEMMAP
-   /* this will put all unused low memory onto the freelists */
free_unused_memmap();
 #endif
-
+   /* this will put all unused low memory onto the freelists */
free_all_bootmem();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_memblock(memory, reg) {
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = __phys_to_pfn(reg->base);
-   pfn2 = pfn1 + __phys_to_pfn(reg->size);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the real number
-* of pages we have in this system.
-*/
-   pr_info("Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   pr_notice("Memory: %luk/%luk available, %luk reserved\n",
- nr_free_pages() << (PAGE_SHIFT-10),
- free_pages << (PAGE_SHIFT-10),
- reserved_pages << (PAGE_SHIFT-10));
+   mem_init_print_info();
 
 #define MLK(b, t) b, t, ((t) - (b)) >> 10
 #define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -366,7 +324,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE_64   > MODULES_VADDR);
BUG_ON(TASK_SIZE_64 > MODULES_VADDR);
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
 * On a machine this small we won't get anywhere without
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 11/39] mm/ARM: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm/mm/init.c |   47 ++-
 1 file changed, 2 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 5925861..8f69924 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -582,9 +582,6 @@ static void __init free_highpages(void)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-   int i;
 #ifdef CONFIG_HAVE_TCM
/* These pointers are filled in on TCM detection */
extern u32 dtcm_end;
@@ -604,47 +601,7 @@ void __init mem_init(void)
 
free_highpages();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_bank(i, &meminfo) {
-   struct membank *bank = &meminfo.bank[i];
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = bank_pfn_start(bank);
-   pfn2 = bank_pfn_end(bank);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the
-* real number of pages we have in this system
-*/
-   printk(KERN_INFO "Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK 
highmem\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   free_pages << (PAGE_SHIFT-10),
-   reserved_pages << (PAGE_SHIFT-10),
-   totalhigh_pages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
 
 #define MLK(b, t) b, t, ((t) - (b)) >> 10
 #define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -710,7 +667,7 @@ void __init mem_init(void)
BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE  > PAGE_OFFSET);
 #endif
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
 * On a machine this small we won't get
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 12/39] mm/ARM64: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Russell King 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 arch/arm64/mm/init.c |   48 +++-
 1 file changed, 3 insertions(+), 45 deletions(-)

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 0f2cf5d..821e788 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -272,59 +272,17 @@ static void __init free_unused_memmap(void)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-
arm64_swiotlb_init();
 
max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
 #ifndef CONFIG_SPARSEMEM_VMEMMAP
-   /* this will put all unused low memory onto the freelists */
free_unused_memmap();
 #endif
-
+   /* this will put all unused low memory onto the freelists */
free_all_bootmem();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_memblock(memory, reg) {
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = __phys_to_pfn(reg->base);
-   pfn2 = pfn1 + __phys_to_pfn(reg->size);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the real number
-* of pages we have in this system.
-*/
-   pr_info("Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   pr_notice("Memory: %luk/%luk available, %luk reserved\n",
- nr_free_pages() << (PAGE_SHIFT-10),
- free_pages << (PAGE_SHIFT-10),
- reserved_pages << (PAGE_SHIFT-10));
+   mem_init_print_info();
 
 #define MLK(b, t) b, t, ((t) - (b)) >> 10
 #define MLM(b, t) b, t, ((t) - (b)) >> 20
@@ -366,7 +324,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE_64   > MODULES_VADDR);
BUG_ON(TASK_SIZE_64 > MODULES_VADDR);
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
extern int sysctl_overcommit_memory;
/*
 * On a machine this small we won't get anywhere without
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 12/39] mm/AVR32: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Haavard Skinnemoen 
Cc: Hans-Christian Egtvedt 
Cc: linux-kernel@vger.kernel.org (open list)
---
 arch/avr32/mm/init.c |   29 -
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 7e8d55a..c1706a0 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -100,26 +100,16 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int nid, i;
+   pg_data_t *pgdat;
 
-   reservedpages = 0;
high_memory = NULL;
 
/* this will put all low memory onto the freelists */
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
-   unsigned long node_pages = 0;
+   for_each_online_pgdat(pgdat) {
void *node_high_memory;
 
-   num_physpages += pgdat->node_present_pages;
-
if (pgdat->node_spanned_pages != 0)
-   node_pages = free_all_bootmem_node(pgdat);
-
-   for (i = 0; i < node_pages; i++)
-   if (PageReserved(pgdat->node_mem_map + i))
-   reservedpages++;
+   free_all_bootmem_node(pgdat);
 
node_high_memory = (void *)((pgdat->node_start_pfn
 + pgdat->node_spanned_pages)
@@ -130,18 +120,7 @@ void __init mem_init(void)
 
max_mapnr = MAP_NR(high_memory);
 
-   codesize = (unsigned long)_etext - (unsigned long)_text;
-   datasize = (unsigned long)_edata - (unsigned long)_data;
-   initsize = (unsigned long)__init_end - (unsigned long)__init_begin;
-
-   printk ("Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT - 10),
-   totalram_pages << (PAGE_SHIFT - 10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT - 10),
-   datasize >> 10,
-   initsize >> 10);
+   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 13/39] mm/AVR32: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Haavard Skinnemoen 
Cc: Hans-Christian Egtvedt 
Cc: linux-kernel@vger.kernel.org (open list)
---
 arch/avr32/mm/init.c |   29 -
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/arch/avr32/mm/init.c b/arch/avr32/mm/init.c
index 7e8d55a..c1706a0 100644
--- a/arch/avr32/mm/init.c
+++ b/arch/avr32/mm/init.c
@@ -100,26 +100,16 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int nid, i;
+   pg_data_t *pgdat;
 
-   reservedpages = 0;
high_memory = NULL;
 
/* this will put all low memory onto the freelists */
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
-   unsigned long node_pages = 0;
+   for_each_online_pgdat(pgdat) {
void *node_high_memory;
 
-   num_physpages += pgdat->node_present_pages;
-
if (pgdat->node_spanned_pages != 0)
-   node_pages = free_all_bootmem_node(pgdat);
-
-   for (i = 0; i < node_pages; i++)
-   if (PageReserved(pgdat->node_mem_map + i))
-   reservedpages++;
+   free_all_bootmem_node(pgdat);
 
node_high_memory = (void *)((pgdat->node_start_pfn
 + pgdat->node_spanned_pages)
@@ -130,18 +120,7 @@ void __init mem_init(void)
 
max_mapnr = MAP_NR(high_memory);
 
-   codesize = (unsigned long)_etext - (unsigned long)_text;
-   datasize = (unsigned long)_edata - (unsigned long)_data;
-   initsize = (unsigned long)__init_end - (unsigned long)__init_begin;
-
-   printk ("Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT - 10),
-   totalram_pages << (PAGE_SHIFT - 10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT - 10),
-   datasize >> 10,
-   initsize >> 10);
+   mem_init_print_info(NULL);
 }
 
 void free_initmem(void)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 13/39] mm/blackfin: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mike Frysinger 
Cc: Bob Liu 
Cc: uclinux-dist-de...@blackfin.uclinux.org
Cc: linux-kernel@vger.kernel.org
---
 arch/blackfin/mm/init.c |   38 ++
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index 1cc8607..e4b6e11 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -90,43 +90,17 @@ asmlinkage void __init init_pda(void)
 
 void __init mem_init(void)
 {
-   unsigned int codek = 0, datak = 0, initk = 0;
-   unsigned int reservedpages = 0, freepages = 0;
-   unsigned long tmp;
-   unsigned long start_mem = memory_start;
-   unsigned long end_mem = memory_end;
+   char buf[64];
 
-   end_mem &= PAGE_MASK;
-   high_memory = (void *)end_mem;
-
-   start_mem = PAGE_ALIGN(start_mem);
-   max_mapnr = num_physpages = MAP_NR(high_memory);
-   printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", 
num_physpages);
+   high_memory = (void *)(memory_end & PAGE_MASK);
+   max_mapnr = MAP_NR(high_memory);
+   printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", max_mapnr);
 
/* This will put all low memory onto the freelists. */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = ARCH_PFN_OFFSET; tmp < max_mapnr; tmp++)
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   freepages =  max_mapnr - ARCH_PFN_OFFSET - reservedpages;
-
-   /* do not count in kernel image between _rambase and _ramstart */
-   reservedpages -= (_ramstart - _rambase) >> PAGE_SHIFT;
-#if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263)
-   reservedpages += (_ramend - memory_end - DMA_UNCACHED_REGION) >> 
PAGE_SHIFT;
-#endif
-
-   codek = (_etext - _stext) >> 10;
-   initk = (__init_end - __init_begin) >> 10;
-   datak = ((_ramstart - _rambase) >> 10) - codek - initk;
-
-   printk(KERN_INFO
-"Memory available: %luk/%luk RAM, "
-   "(%uk init code, %uk kernel code, %uk data, %uk dma, %uk 
reserved)\n",
-   (unsigned long) freepages << (PAGE_SHIFT-10), (_ramend - 
CONFIG_PHY_RAM_BASE_ADDRESS) >> 10,
-   initk, codek, datak, DMA_UNCACHED_REGION >> 10, (reservedpages 
<< (PAGE_SHIFT-10)));
+   snprintf(buf, sizeof(buf) - 1, "%uK DMA", DMA_UNCACHED_REGION >> 10);
+   mem_init_print_info(buf);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 14/39] mm/blackfin: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mike Frysinger 
Cc: Bob Liu 
Cc: uclinux-dist-de...@blackfin.uclinux.org
Cc: linux-kernel@vger.kernel.org
---
 arch/blackfin/mm/init.c |   38 ++
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/arch/blackfin/mm/init.c b/arch/blackfin/mm/init.c
index 1cc8607..e4b6e11 100644
--- a/arch/blackfin/mm/init.c
+++ b/arch/blackfin/mm/init.c
@@ -90,43 +90,17 @@ asmlinkage void __init init_pda(void)
 
 void __init mem_init(void)
 {
-   unsigned int codek = 0, datak = 0, initk = 0;
-   unsigned int reservedpages = 0, freepages = 0;
-   unsigned long tmp;
-   unsigned long start_mem = memory_start;
-   unsigned long end_mem = memory_end;
+   char buf[64];
 
-   end_mem &= PAGE_MASK;
-   high_memory = (void *)end_mem;
-
-   start_mem = PAGE_ALIGN(start_mem);
-   max_mapnr = num_physpages = MAP_NR(high_memory);
-   printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", 
num_physpages);
+   high_memory = (void *)(memory_end & PAGE_MASK);
+   max_mapnr = MAP_NR(high_memory);
+   printk(KERN_DEBUG "Kernel managed physical pages: %lu\n", max_mapnr);
 
/* This will put all low memory onto the freelists. */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = ARCH_PFN_OFFSET; tmp < max_mapnr; tmp++)
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   freepages =  max_mapnr - ARCH_PFN_OFFSET - reservedpages;
-
-   /* do not count in kernel image between _rambase and _ramstart */
-   reservedpages -= (_ramstart - _rambase) >> PAGE_SHIFT;
-#if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263)
-   reservedpages += (_ramend - memory_end - DMA_UNCACHED_REGION) >> 
PAGE_SHIFT;
-#endif
-
-   codek = (_etext - _stext) >> 10;
-   initk = (__init_end - __init_begin) >> 10;
-   datak = ((_ramstart - _rambase) >> 10) - codek - initk;
-
-   printk(KERN_INFO
-"Memory available: %luk/%luk RAM, "
-   "(%uk init code, %uk kernel code, %uk data, %uk dma, %uk 
reserved)\n",
-   (unsigned long) freepages << (PAGE_SHIFT-10), (_ramend - 
CONFIG_PHY_RAM_BASE_ADDRESS) >> 10,
-   initk, codek, datak, DMA_UNCACHED_REGION >> 10, (reservedpages 
<< (PAGE_SHIFT-10)));
+   snprintf(buf, sizeof(buf) - 1, "%uK DMA", DMA_UNCACHED_REGION >> 10);
+   mem_init_print_info(buf);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 14/39] mm/c6x: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Cc: linux-c6x-...@linux-c6x.org
Cc: linux-kernel@vger.kernel.org
---
 arch/c6x/mm/init.c |   11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c
index 2c51474..066f75c 100644
--- a/arch/c6x/mm/init.c
+++ b/arch/c6x/mm/init.c
@@ -57,21 +57,12 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codek, datak;
-   unsigned long tmp;
-   unsigned long len = memory_end - memory_start;
-
high_memory = (void *)(memory_end & PAGE_MASK);
 
/* this will put all memory onto the freelists */
free_all_bootmem();
 
-   codek = (_etext - _stext) >> 10;
-   datak = (_end - _sdata) >> 10;
-
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk(KERN_INFO "Memory: %luk/%luk RAM (%dk kernel code, %dk data)\n",
-  tmp >> 10, len >> 10, codek, datak);
+   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 15/39] mm/c6x: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mark Salter 
Cc: Aurelien Jacquiot 
Cc: linux-c6x-...@linux-c6x.org
Cc: linux-kernel@vger.kernel.org
---
 arch/c6x/mm/init.c |   11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/c6x/mm/init.c b/arch/c6x/mm/init.c
index 2c51474..066f75c 100644
--- a/arch/c6x/mm/init.c
+++ b/arch/c6x/mm/init.c
@@ -57,21 +57,12 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codek, datak;
-   unsigned long tmp;
-   unsigned long len = memory_end - memory_start;
-
high_memory = (void *)(memory_end & PAGE_MASK);
 
/* this will put all memory onto the freelists */
free_all_bootmem();
 
-   codek = (_etext - _stext) >> 10;
-   datak = (_end - _sdata) >> 10;
-
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk(KERN_INFO "Memory: %luk/%luk RAM (%dk kernel code, %dk data)\n",
-  tmp >> 10, len >> 10, codek, datak);
+   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 15/39] mm/cris: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mikael Starvik 
Cc: Jesper Nilsson 
Cc: linux-cris-ker...@axis.com
Cc: linux-kernel@vger.kernel.org
---
 arch/cris/mm/init.c |   33 ++---
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/arch/cris/mm/init.c b/arch/cris/mm/init.c
index 52b8b56..c81af5b 100644
--- a/arch/cris/mm/init.c
+++ b/arch/cris/mm/init.c
@@ -19,9 +19,6 @@ unsigned long empty_zero_page;
 void __init
 mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   unsigned long tmp;
-
BUG_ON(!mem_map);
 
/* max/min_low_pfn was set by setup.c
@@ -29,35 +26,9 @@ mem_init(void)
 *
 * high_memory was also set in setup.c
 */
-
-   max_mapnr = num_physpages = max_low_pfn - min_low_pfn;
- 
-   /* this will put all memory onto the freelists */
+   max_mapnr = max_low_pfn - min_low_pfn;
 free_all_bootmem();
-
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_mapnr; tmp++) {
-   /*
- * Only count reserved RAM pages
- */
-   if (PageReserved(mem_map + tmp))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_stext;
-datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-initsize =  (unsigned long) &__init_end - (unsigned long) 
&__init_begin;
-   
-printk(KERN_INFO
-   "Memory: %luk/%luk available (%dk kernel code, %dk reserved, 
%dk data, "
-  "%dk init)\n" ,
-  nr_free_pages() << (PAGE_SHIFT-10),
-  max_mapnr << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10
-   );
+   mem_init_print_info(NULL);
 }
 
 /* free the pages occupied by initialization code */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 16/39] mm/cris: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Mikael Starvik 
Cc: Jesper Nilsson 
Cc: linux-cris-ker...@axis.com
Cc: linux-kernel@vger.kernel.org
---
 arch/cris/mm/init.c |   33 ++---
 1 file changed, 2 insertions(+), 31 deletions(-)

diff --git a/arch/cris/mm/init.c b/arch/cris/mm/init.c
index 52b8b56..c81af5b 100644
--- a/arch/cris/mm/init.c
+++ b/arch/cris/mm/init.c
@@ -19,9 +19,6 @@ unsigned long empty_zero_page;
 void __init
 mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   unsigned long tmp;
-
BUG_ON(!mem_map);
 
/* max/min_low_pfn was set by setup.c
@@ -29,35 +26,9 @@ mem_init(void)
 *
 * high_memory was also set in setup.c
 */
-
-   max_mapnr = num_physpages = max_low_pfn - min_low_pfn;
- 
-   /* this will put all memory onto the freelists */
+   max_mapnr = max_low_pfn - min_low_pfn;
 free_all_bootmem();
-
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_mapnr; tmp++) {
-   /*
- * Only count reserved RAM pages
- */
-   if (PageReserved(mem_map + tmp))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_stext;
-datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-initsize =  (unsigned long) &__init_end - (unsigned long) 
&__init_begin;
-   
-printk(KERN_INFO
-   "Memory: %luk/%luk available (%dk kernel code, %dk reserved, 
%dk data, "
-  "%dk init)\n" ,
-  nr_free_pages() << (PAGE_SHIFT-10),
-  max_mapnr << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10
-   );
+   mem_init_print_info(NULL);
 }
 
 /* free the pages occupied by initialization code */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 16/39] mm/frv: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: David Howells 
Cc: Andi Kleen 
Cc: Geert Uytterhoeven 
Cc: Greg Kroah-Hartman 
Cc: linux-kernel@vger.kernel.org
---
 arch/frv/kernel/setup.c |   14 +++---
 arch/frv/mm/init.c  |   49 ++-
 2 files changed, 21 insertions(+), 42 deletions(-)

diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index a513647..beee5d7 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -875,7 +875,7 @@ late_initcall(setup_arch_serial);
 #ifdef CONFIG_MMU
 static void __init setup_linux_memory(void)
 {
-   unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem;
+   unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem, 
physpages;
 
kstart  = (unsigned long) &__kernel_image_start - PAGE_OFFSET;
kend= (unsigned long) &__kernel_image_end - PAGE_OFFSET;
@@ -893,19 +893,19 @@ static void __init setup_linux_memory(void)
 );
 
/* pass the memory that the kernel can immediately use over to the 
bootmem allocator */
-   max_mapnr = num_physpages = (memory_end - memory_start) >> PAGE_SHIFT;
+   max_mapnr = physpages = (memory_end - memory_start) >> PAGE_SHIFT;
low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT;
high_mem = 0;
 
-   if (num_physpages > low_top_pfn) {
+   if (physpages > low_top_pfn) {
 #ifdef CONFIG_HIGHMEM
-   high_mem = num_physpages - low_top_pfn;
+   high_mem = physpages - low_top_pfn;
 #else
-   max_mapnr = num_physpages = low_top_pfn;
+   max_mapnr = physpages = low_top_pfn;
 #endif
}
else {
-   low_top_pfn = num_physpages;
+   low_top_pfn = physpages;
}
 
min_low_pfn = memory_start >> PAGE_SHIFT;
@@ -979,7 +979,7 @@ static void __init setup_uclinux_memory(void)
free_bootmem(memory_start, memory_end - memory_start);
 
high_memory = (void *) (memory_end & PAGE_MASK);
-   max_mapnr = num_physpages = ((unsigned long) high_memory - PAGE_OFFSET) 
>> PAGE_SHIFT;
+   max_mapnr = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
 
min_low_pfn = memory_start >> PAGE_SHIFT;
max_low_pfn = memory_end >> PAGE_SHIFT;
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 4215822..e9e2b6f 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -78,7 +78,7 @@ void __init paging_init(void)
memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
 #ifdef CONFIG_HIGHMEM
-   if (num_physpages - num_mappedpages) {
+   if (get_num_physpages() - num_mappedpages) {
pgd_t *pge;
pud_t *pue;
pmd_t *pme;
@@ -96,7 +96,7 @@ void __init paging_init(void)
 */
zones_size[ZONE_NORMAL]  = max_low_pfn - min_low_pfn;
 #ifdef CONFIG_HIGHMEM
-   zones_size[ZONE_HIGHMEM] = num_physpages - num_mappedpages;
+   zones_size[ZONE_HIGHMEM] = get_num_physpages() - num_mappedpages;
 #endif
 
free_area_init(zones_size);
@@ -114,45 +114,24 @@ void __init paging_init(void)
  */
 void __init mem_init(void)
 {
-   unsigned long npages = (memory_end - memory_start) >> PAGE_SHIFT;
-   unsigned long tmp;
-#ifdef CONFIG_MMU
-   unsigned long loop, pfn;
-   int datapages = 0;
-#endif
-   int codek = 0, datak = 0;
+   unsigned long code_size = _etext - _stext;
 
/* this will put all low memory onto the freelists */
free_all_bootmem();
+#if defined(CONFIG_MMU) && defined(CONFIG_HIGHMEM)
+   {
+   unsigned long pfn;
 
-#ifdef CONFIG_MMU
-   for (loop = 0 ; loop < npages ; loop++)
-   if (PageReserved(&mem_map[loop]))
-   datapages++;
-
-#ifdef CONFIG_HIGHMEM
-   for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--)
-   free_highmem_page(&mem_map[pfn]);
-#endif
-
-   codek = ((unsigned long) &_etext - (unsigned long) &_stext) >> 10;
-   datak = datapages << (PAGE_SHIFT - 10);
-
-#else
-   codek = (_etext - _stext) >> 10;
-   datak = 0; //(__bss_stop - _sdata) >> 10;
+   for (pfn = get_num_physpages() - 1;
+pfn >= num_mappedpages; pfn--)
+   free_highmem_page(&mem_map[pfn]);
+   }
 #endif
 
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk("Memory available: %luKiB/%luKiB RAM, %luKiB/%luKiB ROM (%dKiB 
kernel code, %dKiB data)\n",
-  tmp >> 10,
-  npages << (PAGE_SHIFT - 10),
-  (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
-  rom_length >> 10,
-  codek,
-  datak
-  );
-
+   mem_init_print_info(NULL);
+   if (rom_length > 0 && rom_length >= code_size)
+   printk("Memory available:  %luKiB/%luKiB ROM\n",
+   

[RFC PATCH v2, part4 17/39] mm/frv: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: David Howells 
Cc: Andi Kleen 
Cc: Geert Uytterhoeven 
Cc: Greg Kroah-Hartman 
Cc: linux-kernel@vger.kernel.org
---
 arch/frv/kernel/setup.c |   14 +++---
 arch/frv/mm/init.c  |   49 ++-
 2 files changed, 21 insertions(+), 42 deletions(-)

diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index a513647..beee5d7 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -875,7 +875,7 @@ late_initcall(setup_arch_serial);
 #ifdef CONFIG_MMU
 static void __init setup_linux_memory(void)
 {
-   unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem;
+   unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem, 
physpages;
 
kstart  = (unsigned long) &__kernel_image_start - PAGE_OFFSET;
kend= (unsigned long) &__kernel_image_end - PAGE_OFFSET;
@@ -893,19 +893,19 @@ static void __init setup_linux_memory(void)
 );
 
/* pass the memory that the kernel can immediately use over to the 
bootmem allocator */
-   max_mapnr = num_physpages = (memory_end - memory_start) >> PAGE_SHIFT;
+   max_mapnr = physpages = (memory_end - memory_start) >> PAGE_SHIFT;
low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT;
high_mem = 0;
 
-   if (num_physpages > low_top_pfn) {
+   if (physpages > low_top_pfn) {
 #ifdef CONFIG_HIGHMEM
-   high_mem = num_physpages - low_top_pfn;
+   high_mem = physpages - low_top_pfn;
 #else
-   max_mapnr = num_physpages = low_top_pfn;
+   max_mapnr = physpages = low_top_pfn;
 #endif
}
else {
-   low_top_pfn = num_physpages;
+   low_top_pfn = physpages;
}
 
min_low_pfn = memory_start >> PAGE_SHIFT;
@@ -979,7 +979,7 @@ static void __init setup_uclinux_memory(void)
free_bootmem(memory_start, memory_end - memory_start);
 
high_memory = (void *) (memory_end & PAGE_MASK);
-   max_mapnr = num_physpages = ((unsigned long) high_memory - PAGE_OFFSET) 
>> PAGE_SHIFT;
+   max_mapnr = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
 
min_low_pfn = memory_start >> PAGE_SHIFT;
max_low_pfn = memory_end >> PAGE_SHIFT;
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 4215822..e9e2b6f 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -78,7 +78,7 @@ void __init paging_init(void)
memset((void *) empty_zero_page, 0, PAGE_SIZE);
 
 #ifdef CONFIG_HIGHMEM
-   if (num_physpages - num_mappedpages) {
+   if (get_num_physpages() - num_mappedpages) {
pgd_t *pge;
pud_t *pue;
pmd_t *pme;
@@ -96,7 +96,7 @@ void __init paging_init(void)
 */
zones_size[ZONE_NORMAL]  = max_low_pfn - min_low_pfn;
 #ifdef CONFIG_HIGHMEM
-   zones_size[ZONE_HIGHMEM] = num_physpages - num_mappedpages;
+   zones_size[ZONE_HIGHMEM] = get_num_physpages() - num_mappedpages;
 #endif
 
free_area_init(zones_size);
@@ -114,45 +114,24 @@ void __init paging_init(void)
  */
 void __init mem_init(void)
 {
-   unsigned long npages = (memory_end - memory_start) >> PAGE_SHIFT;
-   unsigned long tmp;
-#ifdef CONFIG_MMU
-   unsigned long loop, pfn;
-   int datapages = 0;
-#endif
-   int codek = 0, datak = 0;
+   unsigned long code_size = _etext - _stext;
 
/* this will put all low memory onto the freelists */
free_all_bootmem();
+#if defined(CONFIG_MMU) && defined(CONFIG_HIGHMEM)
+   {
+   unsigned long pfn;
 
-#ifdef CONFIG_MMU
-   for (loop = 0 ; loop < npages ; loop++)
-   if (PageReserved(&mem_map[loop]))
-   datapages++;
-
-#ifdef CONFIG_HIGHMEM
-   for (pfn = num_physpages - 1; pfn >= num_mappedpages; pfn--)
-   free_highmem_page(&mem_map[pfn]);
-#endif
-
-   codek = ((unsigned long) &_etext - (unsigned long) &_stext) >> 10;
-   datak = datapages << (PAGE_SHIFT - 10);
-
-#else
-   codek = (_etext - _stext) >> 10;
-   datak = 0; //(__bss_stop - _sdata) >> 10;
+   for (pfn = get_num_physpages() - 1;
+pfn >= num_mappedpages; pfn--)
+   free_highmem_page(&mem_map[pfn]);
+   }
 #endif
 
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk("Memory available: %luKiB/%luKiB RAM, %luKiB/%luKiB ROM (%dKiB 
kernel code, %dKiB data)\n",
-  tmp >> 10,
-  npages << (PAGE_SHIFT - 10),
-  (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
-  rom_length >> 10,
-  codek,
-  datak
-  );
-
+   mem_init_print_info(NULL);
+   if (rom_length > 0 && rom_length >= code_size)
+   printk("Memory available:  %luKiB/%luKiB ROM\n",
+   

[RFC PATCH v2, part4 17/39] mm/h8300: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Yoshinori Sato 
Cc: Geert Uytterhoeven 
Cc: linux-kernel@vger.kernel.org
---
 arch/h8300/mm/init.c |   34 --
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 22fd869..0088f3a 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -121,40 +121,22 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codek = 0, datak = 0, initk = 0;
-   /* DAVIDM look at setup memory map generically with reserved area */
-   unsigned long tmp;
-   extern unsigned long  _ramend, _ramstart;
-   unsigned long len = &_ramend - &_ramstart;
-   unsigned long start_mem = memory_start; /* DAVIDM - these must start at 
end of kernel */
-   unsigned long end_mem   = memory_end; /* DAVIDM - this must not include 
kernel stack at top */
+   unsigned long codesize = _etext - _stext;
 
 #ifdef DEBUG
-   printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
+   pr_debug("Mem_init: start=%lx, end=%lx\n", memory_start, memory_end);
 #endif
 
-   end_mem &= PAGE_MASK;
-   high_memory = (void *) end_mem;
-
-   start_mem = PAGE_ALIGN(start_mem);
-   max_mapnr = num_physpages = MAP_NR(high_memory);
+   high_memory = (void *) (memory_end & PAGE_MASK);
+   max_mapnr = MAP_NR(high_memory);
 
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   codek = (_etext - _stext) >> 10;
-   datak = (__bss_stop - _sdata) >> 10;
-   initk = (__init_begin - __init_end) >> 10;
-
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk 
kernel code, %dk data)\n",
-  tmp >> 10,
-  len >> 10,
-  (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
-  rom_length >> 10,
-  codek,
-  datak
-  );
+   mem_init_print_info(NULL);
+   if (rom_length > 0 && rom_length > codesize)
+   pr_info("Memory available: %luK/%luK ROM\n",
+   (rom_length - codesize) >> 10, rom_length >> 10);
 }
 
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 18/39] mm/h8300: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Yoshinori Sato 
Cc: Geert Uytterhoeven 
Cc: linux-kernel@vger.kernel.org
---
 arch/h8300/mm/init.c |   34 --
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/h8300/mm/init.c b/arch/h8300/mm/init.c
index 22fd869..0088f3a 100644
--- a/arch/h8300/mm/init.c
+++ b/arch/h8300/mm/init.c
@@ -121,40 +121,22 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   int codek = 0, datak = 0, initk = 0;
-   /* DAVIDM look at setup memory map generically with reserved area */
-   unsigned long tmp;
-   extern unsigned long  _ramend, _ramstart;
-   unsigned long len = &_ramend - &_ramstart;
-   unsigned long start_mem = memory_start; /* DAVIDM - these must start at 
end of kernel */
-   unsigned long end_mem   = memory_end; /* DAVIDM - this must not include 
kernel stack at top */
+   unsigned long codesize = _etext - _stext;
 
 #ifdef DEBUG
-   printk(KERN_DEBUG "Mem_init: start=%lx, end=%lx\n", start_mem, end_mem);
+   pr_debug("Mem_init: start=%lx, end=%lx\n", memory_start, memory_end);
 #endif
 
-   end_mem &= PAGE_MASK;
-   high_memory = (void *) end_mem;
-
-   start_mem = PAGE_ALIGN(start_mem);
-   max_mapnr = num_physpages = MAP_NR(high_memory);
+   high_memory = (void *) (memory_end & PAGE_MASK);
+   max_mapnr = MAP_NR(high_memory);
 
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   codek = (_etext - _stext) >> 10;
-   datak = (__bss_stop - _sdata) >> 10;
-   initk = (__init_begin - __init_end) >> 10;
-
-   tmp = nr_free_pages() << PAGE_SHIFT;
-   printk(KERN_INFO "Memory available: %luk/%luk RAM, %luk/%luk ROM (%dk 
kernel code, %dk data)\n",
-  tmp >> 10,
-  len >> 10,
-  (rom_length > 0) ? ((rom_length >> 10) - codek) : 0,
-  rom_length >> 10,
-  codek,
-  datak
-  );
+   mem_init_print_info(NULL);
+   if (rom_length > 0 && rom_length > codesize)
+   pr_info("Memory available: %luK/%luK ROM\n",
+   (rom_length - codesize) >> 10, rom_length >> 10);
 }
 
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 19/39] mm/hexagon: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Richard Kuo 
Cc: linux-hexa...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/hexagon/mm/init.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index c048d06e..c0f0781 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -70,9 +70,8 @@ unsigned long long kmap_generation;
 void __init mem_init(void)
 {
free_all_bootmem();
-   num_physpages = bootmem_lastpg; /*  seriously, what?  */
 
-   printk(KERN_INFO "totalram_pages = %ld\n", totalram_pages);
+   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 19/39] mm/IA64: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Andrew Morton 
Cc: Zhang Yanfei 
Cc: linux-i...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/ia64/mm/contig.c|   11 ---
 arch/ia64/mm/discontig.c |3 ---
 arch/ia64/mm/init.c  |   27 +--
 3 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 67c59eb..e4a6a536 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -295,14 +295,6 @@ find_memory (void)
alloc_per_cpu_data();
 }
 
-static int count_pages(u64 start, u64 end, void *arg)
-{
-   unsigned long *count = arg;
-
-   *count += (end - start) >> PAGE_SHIFT;
-   return 0;
-}
-
 /*
  * Set up the page tables.
  */
@@ -313,9 +305,6 @@ paging_init (void)
unsigned long max_dma;
unsigned long max_zone_pfns[MAX_NR_ZONES];
 
-   num_physpages = 0;
-   efi_memmap_walk(count_pages, &num_physpages);
-
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_ZONE_DMA
max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index a57436e..8febadc 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -37,7 +37,6 @@ struct early_node_data {
struct ia64_node_data *node_data;
unsigned long pernode_addr;
unsigned long pernode_size;
-   unsigned long num_physpages;
 #ifdef CONFIG_ZONE_DMA
unsigned long num_dma_physpages;
 #endif
@@ -732,7 +731,6 @@ static __init int count_node_pages(unsigned long start, 
unsigned long len, int n
 {
unsigned long end = start + len;
 
-   mem_data[node].num_physpages += len >> PAGE_SHIFT;
 #ifdef CONFIG_ZONE_DMA
if (start <= __pa(MAX_DMA_ADDRESS))
mem_data[node].num_dma_physpages +=
@@ -778,7 +776,6 @@ void __init paging_init(void)
 #endif
 
for_each_online_node(node) {
-   num_physpages += mem_data[node].num_physpages;
pfn_offset = mem_data[node].min_pfn;
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index b5b71e8..d4382dc 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -546,19 +546,6 @@ int __init register_active_ranges(u64 start, u64 len, int 
nid)
return 0;
 }
 
-static int __init
-count_reserved_pages(u64 start, u64 end, void *arg)
-{
-   unsigned long num_reserved = 0;
-   unsigned long *count = arg;
-
-   for (; start < end; start += PAGE_SIZE)
-   if (PageReserved(virt_to_page(start)))
-   ++num_reserved;
-   *count += num_reserved;
-   return 0;
-}
-
 int
 find_max_min_low_pfn (u64 start, u64 end, void *arg)
 {
@@ -597,7 +584,6 @@ __setup("nolwsys", nolwsys_setup);
 void __init
 mem_init (void)
 {
-   long reserved_pages, codesize, datasize, initsize;
pg_data_t *pgdat;
int i;
 
@@ -625,18 +611,7 @@ mem_init (void)
if (pgdat->bdata->node_bootmem_map)
free_all_bootmem_node(pgdat);
 
-   reserved_pages = 0;
-   efi_memmap_walk(count_reserved_pages, &reserved_pages);
-
-   codesize =  (unsigned long) _etext - (unsigned long) _stext;
-   datasize =  (unsigned long) _edata - (unsigned long) _etext;
-   initsize =  (unsigned long) __init_end - (unsigned long) __init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%luk code, %luk 
reserved, "
-  "%luk data, %luk init)\n", nr_free_pages() << (PAGE_SHIFT - 10),
-  num_physpages << (PAGE_SHIFT - 10), codesize >> 10,
-  reserved_pages << (PAGE_SHIFT - 10), datasize >> 10, initsize >> 
10);
-
+   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 20/39] mm/IA64: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Tony Luck 
Cc: Fenghua Yu 
Cc: Andrew Morton 
Cc: Zhang Yanfei 
Cc: linux-i...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/ia64/mm/contig.c|   11 ---
 arch/ia64/mm/discontig.c |3 ---
 arch/ia64/mm/init.c  |   27 +--
 3 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 67c59eb..e4a6a536 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -295,14 +295,6 @@ find_memory (void)
alloc_per_cpu_data();
 }
 
-static int count_pages(u64 start, u64 end, void *arg)
-{
-   unsigned long *count = arg;
-
-   *count += (end - start) >> PAGE_SHIFT;
-   return 0;
-}
-
 /*
  * Set up the page tables.
  */
@@ -313,9 +305,6 @@ paging_init (void)
unsigned long max_dma;
unsigned long max_zone_pfns[MAX_NR_ZONES];
 
-   num_physpages = 0;
-   efi_memmap_walk(count_pages, &num_physpages);
-
memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
 #ifdef CONFIG_ZONE_DMA
max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index a57436e..8febadc 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -37,7 +37,6 @@ struct early_node_data {
struct ia64_node_data *node_data;
unsigned long pernode_addr;
unsigned long pernode_size;
-   unsigned long num_physpages;
 #ifdef CONFIG_ZONE_DMA
unsigned long num_dma_physpages;
 #endif
@@ -732,7 +731,6 @@ static __init int count_node_pages(unsigned long start, 
unsigned long len, int n
 {
unsigned long end = start + len;
 
-   mem_data[node].num_physpages += len >> PAGE_SHIFT;
 #ifdef CONFIG_ZONE_DMA
if (start <= __pa(MAX_DMA_ADDRESS))
mem_data[node].num_dma_physpages +=
@@ -778,7 +776,6 @@ void __init paging_init(void)
 #endif
 
for_each_online_node(node) {
-   num_physpages += mem_data[node].num_physpages;
pfn_offset = mem_data[node].min_pfn;
 
 #ifdef CONFIG_VIRTUAL_MEM_MAP
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index b5b71e8..d4382dc 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -546,19 +546,6 @@ int __init register_active_ranges(u64 start, u64 len, int 
nid)
return 0;
 }
 
-static int __init
-count_reserved_pages(u64 start, u64 end, void *arg)
-{
-   unsigned long num_reserved = 0;
-   unsigned long *count = arg;
-
-   for (; start < end; start += PAGE_SIZE)
-   if (PageReserved(virt_to_page(start)))
-   ++num_reserved;
-   *count += num_reserved;
-   return 0;
-}
-
 int
 find_max_min_low_pfn (u64 start, u64 end, void *arg)
 {
@@ -597,7 +584,6 @@ __setup("nolwsys", nolwsys_setup);
 void __init
 mem_init (void)
 {
-   long reserved_pages, codesize, datasize, initsize;
pg_data_t *pgdat;
int i;
 
@@ -625,18 +611,7 @@ mem_init (void)
if (pgdat->bdata->node_bootmem_map)
free_all_bootmem_node(pgdat);
 
-   reserved_pages = 0;
-   efi_memmap_walk(count_reserved_pages, &reserved_pages);
-
-   codesize =  (unsigned long) _etext - (unsigned long) _stext;
-   datasize =  (unsigned long) _edata - (unsigned long) _etext;
-   initsize =  (unsigned long) __init_end - (unsigned long) __init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%luk code, %luk 
reserved, "
-  "%luk data, %luk init)\n", nr_free_pages() << (PAGE_SHIFT - 10),
-  num_physpages << (PAGE_SHIFT - 10), codesize >> 10,
-  reserved_pages << (PAGE_SHIFT - 10), datasize >> 10, initsize >> 
10);
-
+   mem_init_print_info(NULL);
 
/*
 * For fsyscall entrpoints with no light-weight handler, use the 
ordinary
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 20/39] mm/m32r: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Hirokazu Takata 
Cc: linux-m...@ml.linux-m32r.org
Cc: linux-m32r...@ml.linux-m32r.org
Cc: linux-kernel@vger.kernel.org
---
 arch/m32r/mm/discontig.c |6 +-
 arch/m32r/mm/init.c  |   49 +-
 2 files changed, 6 insertions(+), 49 deletions(-)

diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index 2c468e8..2719630 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -129,11 +129,10 @@ unsigned long __init setup_memory(void)
 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
 #define MAX_LOW_PFN(nid)   (NODE_DATA(nid)->bdata->node_low_pfn)
 
-unsigned long __init zone_sizes_init(void)
+void __init zone_sizes_init(void)
 {
unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES];
unsigned long low, start_pfn;
-   unsigned long holes = 0;
int nid, i;
mem_prof_t *mp;
 
@@ -147,7 +146,6 @@ unsigned long __init zone_sizes_init(void)
low = MAX_LOW_PFN(nid);
zones_size[ZONE_DMA] = low - start_pfn;
zholes_size[ZONE_DMA] = mp->holes;
-   holes += zholes_size[ZONE_DMA];
 
node_set_state(nid, N_NORMAL_MEMORY);
free_area_init_node(nid, zones_size, start_pfn, zholes_size);
@@ -161,6 +159,4 @@ unsigned long __init zone_sizes_init(void)
NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0;
-
-   return holes;
 }
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index c421c31..9c94839 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -40,7 +40,6 @@ unsigned long mmu_context_cache_dat;
 #else
 unsigned long mmu_context_cache_dat[NR_CPUS];
 #endif
-static unsigned long hole_pages;
 
 /*
  * function prototype
@@ -57,7 +56,7 @@ void free_initrd_mem(unsigned long, unsigned long);
 #define MAX_LOW_PFN(nid)   (NODE_DATA(nid)->bdata->node_low_pfn)
 
 #ifndef CONFIG_DISCONTIGMEM
-unsigned long __init zone_sizes_init(void)
+void __init zone_sizes_init(void)
 {
unsigned long  zones_size[MAX_NR_ZONES] = {0, };
unsigned long  max_dma;
@@ -83,11 +82,9 @@ unsigned long __init zone_sizes_init(void)
 #endif /* CONFIG_MMU */
 
free_area_init_node(0, zones_size, start_pfn, 0);
-
-   return 0;
 }
 #else  /* CONFIG_DISCONTIGMEM */
-extern unsigned long zone_sizes_init(void);
+extern void zone_sizes_init(void);
 #endif /* CONFIG_DISCONTIGMEM */
 
 /*==*
@@ -105,24 +102,7 @@ void __init paging_init(void)
for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++)
pgd_val(pg_dir[i]) = 0;
 #endif /* CONFIG_MMU */
-   hole_pages = zone_sizes_init();
-}
-
-int __init reservedpages_count(void)
-{
-   int reservedpages, nid, i;
-
-   reservedpages = 0;
-   for_each_online_node(nid) {
-   unsigned long flags;
-   pgdat_resize_lock(NODE_DATA(nid), &flags);
-   for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
-   if (PageReserved(nid_page_nr(nid, i)))
-   reservedpages++;
-   pgdat_resize_unlock(NODE_DATA(nid), &flags);
-   }
-
-   return reservedpages;
+   zone_sizes_init();
 }
 
 /*==*
@@ -131,20 +111,13 @@ int __init reservedpages_count(void)
  *==*/
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
int nid;
 #ifndef CONFIG_MMU
extern unsigned long memory_end;
 #endif
 
-   num_physpages = 0;
-   for_each_online_node(nid)
-   num_physpages += MAX_LOW_PFN(nid) - START_PFN(nid) + 1;
-
-   num_physpages -= hole_pages;
-
 #ifndef CONFIG_DISCONTIGMEM
-   max_mapnr = num_physpages;
+   max_mapnr = get_num_physpages();
 #endif /* CONFIG_DISCONTIGMEM */
 
 #ifdef CONFIG_MMU
@@ -160,19 +133,7 @@ void __init mem_init(void)
for_each_online_node(nid)
free_all_bootmem_node(NODE_DATA(nid));
 
-   reservedpages = reservedpages_count() - hole_pages;
-   codesize = (unsigned long) &_etext - (unsigned long)&_text;
-   datasize = (unsigned long) &_edata - (unsigned long)&_etext;
-   initsize = (unsigned long) &__init_end - (unsigned long)&__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-

[RFC PATCH v2, part4 21/39] mm/m32r: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Hirokazu Takata 
Cc: linux-m...@ml.linux-m32r.org
Cc: linux-m32r...@ml.linux-m32r.org
Cc: linux-kernel@vger.kernel.org
---
 arch/m32r/mm/discontig.c |6 +-
 arch/m32r/mm/init.c  |   49 +-
 2 files changed, 6 insertions(+), 49 deletions(-)

diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index 2c468e8..2719630 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -129,11 +129,10 @@ unsigned long __init setup_memory(void)
 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
 #define MAX_LOW_PFN(nid)   (NODE_DATA(nid)->bdata->node_low_pfn)
 
-unsigned long __init zone_sizes_init(void)
+void __init zone_sizes_init(void)
 {
unsigned long zones_size[MAX_NR_ZONES], zholes_size[MAX_NR_ZONES];
unsigned long low, start_pfn;
-   unsigned long holes = 0;
int nid, i;
mem_prof_t *mp;
 
@@ -147,7 +146,6 @@ unsigned long __init zone_sizes_init(void)
low = MAX_LOW_PFN(nid);
zones_size[ZONE_DMA] = low - start_pfn;
zholes_size[ZONE_DMA] = mp->holes;
-   holes += zholes_size[ZONE_DMA];
 
node_set_state(nid, N_NORMAL_MEMORY);
free_area_init_node(nid, zones_size, start_pfn, zholes_size);
@@ -161,6 +159,4 @@ unsigned long __init zone_sizes_init(void)
NODE_DATA(1)->node_zones->watermark[WMARK_MIN] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_LOW] = 0;
NODE_DATA(1)->node_zones->watermark[WMARK_HIGH] = 0;
-
-   return holes;
 }
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c
index c421c31..9c94839 100644
--- a/arch/m32r/mm/init.c
+++ b/arch/m32r/mm/init.c
@@ -40,7 +40,6 @@ unsigned long mmu_context_cache_dat;
 #else
 unsigned long mmu_context_cache_dat[NR_CPUS];
 #endif
-static unsigned long hole_pages;
 
 /*
  * function prototype
@@ -57,7 +56,7 @@ void free_initrd_mem(unsigned long, unsigned long);
 #define MAX_LOW_PFN(nid)   (NODE_DATA(nid)->bdata->node_low_pfn)
 
 #ifndef CONFIG_DISCONTIGMEM
-unsigned long __init zone_sizes_init(void)
+void __init zone_sizes_init(void)
 {
unsigned long  zones_size[MAX_NR_ZONES] = {0, };
unsigned long  max_dma;
@@ -83,11 +82,9 @@ unsigned long __init zone_sizes_init(void)
 #endif /* CONFIG_MMU */
 
free_area_init_node(0, zones_size, start_pfn, 0);
-
-   return 0;
 }
 #else  /* CONFIG_DISCONTIGMEM */
-extern unsigned long zone_sizes_init(void);
+extern void zone_sizes_init(void);
 #endif /* CONFIG_DISCONTIGMEM */
 
 /*==*
@@ -105,24 +102,7 @@ void __init paging_init(void)
for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++)
pgd_val(pg_dir[i]) = 0;
 #endif /* CONFIG_MMU */
-   hole_pages = zone_sizes_init();
-}
-
-int __init reservedpages_count(void)
-{
-   int reservedpages, nid, i;
-
-   reservedpages = 0;
-   for_each_online_node(nid) {
-   unsigned long flags;
-   pgdat_resize_lock(NODE_DATA(nid), &flags);
-   for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++)
-   if (PageReserved(nid_page_nr(nid, i)))
-   reservedpages++;
-   pgdat_resize_unlock(NODE_DATA(nid), &flags);
-   }
-
-   return reservedpages;
+   zone_sizes_init();
 }
 
 /*==*
@@ -131,20 +111,13 @@ int __init reservedpages_count(void)
  *==*/
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
int nid;
 #ifndef CONFIG_MMU
extern unsigned long memory_end;
 #endif
 
-   num_physpages = 0;
-   for_each_online_node(nid)
-   num_physpages += MAX_LOW_PFN(nid) - START_PFN(nid) + 1;
-
-   num_physpages -= hole_pages;
-
 #ifndef CONFIG_DISCONTIGMEM
-   max_mapnr = num_physpages;
+   max_mapnr = get_num_physpages();
 #endif /* CONFIG_DISCONTIGMEM */
 
 #ifdef CONFIG_MMU
@@ -160,19 +133,7 @@ void __init mem_init(void)
for_each_online_node(nid)
free_all_bootmem_node(NODE_DATA(nid));
 
-   reservedpages = reservedpages_count() - hole_pages;
-   codesize = (unsigned long) &_etext - (unsigned long)&_text;
-   datasize = (unsigned long) &_edata - (unsigned long)&_etext;
-   initsize = (unsigned long) &__init_end - (unsigned long)&__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-

[RFC PATCH v2, part4 22/39] mm/m68k: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Geert Uytterhoeven 
Cc: Greg Ungerer 
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-kernel@vger.kernel.org
---
 arch/m68k/mm/init.c |   31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 0450989..f58fa43 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -149,33 +149,11 @@ void __init print_memmap(void)
 void __init mem_init(void)
 {
pg_data_t *pgdat;
-   int codepages = 0;
-   int datapages = 0;
-   int initpages = 0;
int i;
 
/* this will put all memory onto the freelists */
-   num_physpages = 0;
-   for_each_online_pgdat(pgdat) {
-   num_physpages += pgdat->node_present_pages;
-
+   for_each_online_pgdat(pgdat)
free_all_bootmem_node(pgdat);
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   struct page *page = pgdat->node_mem_map + i;
-   char *addr = page_to_virt(page);
-
-   if (!PageReserved(page))
-   continue;
-   if (addr >= _text &&
-   addr < _etext)
-   codepages++;
-   else if (addr >= __init_begin &&
-addr < __init_end)
-   initpages++;
-   else
-   datapages++;
-   }
-   }
 
 #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
/* insert pointer tables allocated so far into the tablelist */
@@ -190,12 +168,7 @@ void __init mem_init(void)
init_pointer_table((unsigned long)zero_pgtable);
 #endif
 
-   pr_info("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk 
init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  totalram_pages << (PAGE_SHIFT-10),
-  codepages << (PAGE_SHIFT-10),
-  datapages << (PAGE_SHIFT-10),
-  initpages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
print_memmap();
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 22/39] mm/microblaze: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Michal Simek 
Cc: microblaze-ucli...@itee.uq.edu.au
Cc: linux-kernel@vger.kernel.org
---
 arch/microblaze/mm/init.c |   51 ++---
 1 file changed, 6 insertions(+), 45 deletions(-)

diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 3a434fd..0545ecd 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -71,24 +71,17 @@ static void __init highmem_init(void)
kmap_prot = PAGE_KERNEL;
 }
 
-static unsigned long highmem_setup(void)
+static void highmem_setup(void)
 {
unsigned long pfn;
-   unsigned long reservedpages = 0;
 
for (pfn = max_low_pfn; pfn < max_pfn; ++pfn) {
struct page *page = pfn_to_page(pfn);
 
/* FIXME not sure about */
-   if (memblock_is_reserved(pfn << PAGE_SHIFT))
-   continue;
-   free_highmem_page(page);
-   reservedpages++;
+   if (!memblock_is_reserved(pfn << PAGE_SHIFT))
+   free_highmem_page(page);
}
-   printk(KERN_INFO "High memory: %luk\n",
-   totalhigh_pages << (PAGE_SHIFT-10));
-
-   return reservedpages;
 }
 #endif /* CONFIG_HIGHMEM */
 
@@ -167,13 +160,12 @@ void __init setup_memory(void)
 * min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
 * max_low_pfn
 * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)
-* num_physpages - number of all pages
 */
 
/* memory start is from the kernel end (aligned) to higher addr */
min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */
/* RAM is assumed contiguous */
-   num_physpages = max_mapnr = memory_size >> PAGE_SHIFT;
+   max_mapnr = memory_size >> PAGE_SHIFT;
max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT;
max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT;
 
@@ -246,46 +238,15 @@ void free_initmem(void)
 
 void __init mem_init(void)
 {
-   pg_data_t *pgdat;
-   unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
-
high_memory = (void *)__va(memory_start + lowmem_size - 1);
 
/* this will put all memory onto the freelists */
free_all_bootmem();
-
-   for_each_online_pgdat(pgdat) {
-   unsigned long i;
-   struct page *page;
-
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   if (!pfn_valid(pgdat->node_start_pfn + i))
-   continue;
-   page = pgdat_page_nr(pgdat, i);
-   if (PageReserved(page))
-   reservedpages++;
-   }
-   }
-
 #ifdef CONFIG_HIGHMEM
-   reservedpages -= highmem_setup();
+   highmem_setup();
 #endif
 
-   codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
-   bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
-
-   pr_info("Memory: %luk/%luk available (%luk kernel code, "
-   "%luk reserved, %luk data, %luk bss, %luk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   bsssize >> 10,
-   initsize >> 10);
-
+   mem_init_print_info(str);
 #ifdef CONFIG_MMU
pr_info("Kernel virtual memory layout:\n");
pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 23/39] mm/microblaze: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Michal Simek 
Cc: microblaze-ucli...@itee.uq.edu.au
Cc: linux-kernel@vger.kernel.org
---
 arch/microblaze/mm/init.c |   51 ++---
 1 file changed, 6 insertions(+), 45 deletions(-)

diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 3a434fd..0545ecd 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -71,24 +71,17 @@ static void __init highmem_init(void)
kmap_prot = PAGE_KERNEL;
 }
 
-static unsigned long highmem_setup(void)
+static void highmem_setup(void)
 {
unsigned long pfn;
-   unsigned long reservedpages = 0;
 
for (pfn = max_low_pfn; pfn < max_pfn; ++pfn) {
struct page *page = pfn_to_page(pfn);
 
/* FIXME not sure about */
-   if (memblock_is_reserved(pfn << PAGE_SHIFT))
-   continue;
-   free_highmem_page(page);
-   reservedpages++;
+   if (!memblock_is_reserved(pfn << PAGE_SHIFT))
+   free_highmem_page(page);
}
-   printk(KERN_INFO "High memory: %luk\n",
-   totalhigh_pages << (PAGE_SHIFT-10));
-
-   return reservedpages;
 }
 #endif /* CONFIG_HIGHMEM */
 
@@ -167,13 +160,12 @@ void __init setup_memory(void)
 * min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
 * max_low_pfn
 * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)
-* num_physpages - number of all pages
 */
 
/* memory start is from the kernel end (aligned) to higher addr */
min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */
/* RAM is assumed contiguous */
-   num_physpages = max_mapnr = memory_size >> PAGE_SHIFT;
+   max_mapnr = memory_size >> PAGE_SHIFT;
max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT;
max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT;
 
@@ -246,46 +238,15 @@ void free_initmem(void)
 
 void __init mem_init(void)
 {
-   pg_data_t *pgdat;
-   unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
-
high_memory = (void *)__va(memory_start + lowmem_size - 1);
 
/* this will put all memory onto the freelists */
free_all_bootmem();
-
-   for_each_online_pgdat(pgdat) {
-   unsigned long i;
-   struct page *page;
-
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   if (!pfn_valid(pgdat->node_start_pfn + i))
-   continue;
-   page = pgdat_page_nr(pgdat, i);
-   if (PageReserved(page))
-   reservedpages++;
-   }
-   }
-
 #ifdef CONFIG_HIGHMEM
-   reservedpages -= highmem_setup();
+   highmem_setup();
 #endif
 
-   codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
-   bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
-
-   pr_info("Memory: %luk/%luk available (%luk kernel code, "
-   "%luk reserved, %luk data, %luk bss, %luk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   bsssize >> 10,
-   initsize >> 10);
-
+   mem_init_print_info(str);
 #ifdef CONFIG_MMU
pr_info("Kernel virtual memory layout:\n");
pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 23/39] mm/MIPS: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Ralf Baechle 
Cc: David Daney 
Cc: Arnd Bergmann 
Cc: Jiri Kosina 
Cc: John Crispin 
Cc: Greg Kroah-Hartman 
Cc: Minchan Kim 
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 arch/mips/mm/init.c  |   57 --
 arch/mips/pci/pci-lantiq.c   |2 +-
 arch/mips/sgi-ip27/ip27-memory.c |   21 ++
 3 files changed, 21 insertions(+), 59 deletions(-)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index c1d7b9f..8149946 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -358,11 +358,24 @@ void __init paging_init(void)
 static struct kcore_list kcore_kseg0;
 #endif
 
-void __init mem_init(void)
+static inline void mem_init_free_highmem(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long tmp, ram;
+#ifdef CONFIG_HIGHMEM
+   unsigned long tmp;
 
+   for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
+   struct page *page = pfn_to_page(tmp);
+
+   if (!page_is_ram(tmp))
+   SetPageReserved(page);
+   else
+   free_highmem_page(page);
+   }
+#endif
+}
+
+void __init mem_init(void)
+{
 #ifdef CONFIG_HIGHMEM
 #ifdef CONFIG_DISCONTIGMEM
 #error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet"
@@ -375,32 +388,8 @@ void __init mem_init(void)
 
free_all_bootmem();
setup_zero_pages(); /* Setup zeroed pages.  */
-
-   reservedpages = ram = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   if (page_is_ram(tmp) && pfn_valid(tmp)) {
-   ram++;
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   }
-   num_physpages = ram;
-
-#ifdef CONFIG_HIGHMEM
-   for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
-   struct page *page = pfn_to_page(tmp);
-
-   if (!page_is_ram(tmp)) {
-   SetPageReserved(page);
-   continue;
-   }
-   free_highmem_page(page);
-   }
-   num_physpages += totalhigh_pages;
-#endif
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
+   mem_init_free_highmem();
+   mem_init_print_info(NULL);
 
 #ifdef CONFIG_64BIT
if ((unsigned long) &_text > (unsigned long) CKSEG0)
@@ -409,16 +398,6 @@ void __init mem_init(void)
kclist_add(&kcore_kseg0, (void *) CKSEG0,
0x8000 - 4, KCORE_TEXT);
 #endif
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
-  "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  ram << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10,
-  totalhigh_pages << (PAGE_SHIFT-10));
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index 9568178..8cc3250 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -89,7 +89,7 @@ static inline u32 ltq_calc_bar11mask(void)
u32 mem, bar11mask;
 
/* BAR11MASK value depends on available memory on system. */
-   mem = num_physpages * PAGE_SIZE;
+   mem = get_num_physpages() * PAGE_SIZE;
bar11mask = (0x0ff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8;
 
return bar11mask;
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 4042e06..41646d7 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -357,8 +357,6 @@ static void __init szmem(void)
int slot;
cnodeid_t node;
 
-   num_physpages = 0;
-
for_each_online_node(node) {
nodebytes = 0;
for (slot = 0; slot < MAX_MEM_SLOTS; slot++) {
@@ -381,7 +379,6 @@ static void __init szmem(void)
slot = MAX_MEM_SLOTS;
continue;
}
-   num_physpages += slot_psize;
memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)),
  PFN_PHYS(slot_psize), node);
}
@@ -480,10 +477,9 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, datasize, initsize, tmp;
unsigned node;
 
-   high_memory = (void *) __va(num_physpages << PAGE_SHIFT);
+   high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
 
for_each_online_node

[RFC PATCH v2, part4 24/39] mm/MIPS: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Ralf Baechle 
Cc: David Daney 
Cc: Arnd Bergmann 
Cc: Jiri Kosina 
Cc: John Crispin 
Cc: Greg Kroah-Hartman 
Cc: Minchan Kim 
Cc: linux-m...@linux-mips.org
Cc: linux-kernel@vger.kernel.org
---
 arch/mips/mm/init.c  |   57 --
 arch/mips/pci/pci-lantiq.c   |2 +-
 arch/mips/sgi-ip27/ip27-memory.c |   21 ++
 3 files changed, 21 insertions(+), 59 deletions(-)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index c1d7b9f..8149946 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -358,11 +358,24 @@ void __init paging_init(void)
 static struct kcore_list kcore_kseg0;
 #endif
 
-void __init mem_init(void)
+static inline void mem_init_free_highmem(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long tmp, ram;
+#ifdef CONFIG_HIGHMEM
+   unsigned long tmp;
 
+   for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
+   struct page *page = pfn_to_page(tmp);
+
+   if (!page_is_ram(tmp))
+   SetPageReserved(page);
+   else
+   free_highmem_page(page);
+   }
+#endif
+}
+
+void __init mem_init(void)
+{
 #ifdef CONFIG_HIGHMEM
 #ifdef CONFIG_DISCONTIGMEM
 #error "CONFIG_HIGHMEM and CONFIG_DISCONTIGMEM dont work together yet"
@@ -375,32 +388,8 @@ void __init mem_init(void)
 
free_all_bootmem();
setup_zero_pages(); /* Setup zeroed pages.  */
-
-   reservedpages = ram = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   if (page_is_ram(tmp) && pfn_valid(tmp)) {
-   ram++;
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   }
-   num_physpages = ram;
-
-#ifdef CONFIG_HIGHMEM
-   for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
-   struct page *page = pfn_to_page(tmp);
-
-   if (!page_is_ram(tmp)) {
-   SetPageReserved(page);
-   continue;
-   }
-   free_highmem_page(page);
-   }
-   num_physpages += totalhigh_pages;
-#endif
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
+   mem_init_free_highmem();
+   mem_init_print_info(NULL);
 
 #ifdef CONFIG_64BIT
if ((unsigned long) &_text > (unsigned long) CKSEG0)
@@ -409,16 +398,6 @@ void __init mem_init(void)
kclist_add(&kcore_kseg0, (void *) CKSEG0,
0x8000 - 4, KCORE_TEXT);
 #endif
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
-  "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  ram << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10,
-  totalhigh_pages << (PAGE_SHIFT-10));
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index 9568178..8cc3250 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -89,7 +89,7 @@ static inline u32 ltq_calc_bar11mask(void)
u32 mem, bar11mask;
 
/* BAR11MASK value depends on available memory on system. */
-   mem = num_physpages * PAGE_SIZE;
+   mem = get_num_physpages() * PAGE_SIZE;
bar11mask = (0x0ff0 & ~((1 << (fls(mem) - 1)) - 1)) | 8;
 
return bar11mask;
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index 4042e06..41646d7 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -357,8 +357,6 @@ static void __init szmem(void)
int slot;
cnodeid_t node;
 
-   num_physpages = 0;
-
for_each_online_node(node) {
nodebytes = 0;
for (slot = 0; slot < MAX_MEM_SLOTS; slot++) {
@@ -381,7 +379,6 @@ static void __init szmem(void)
slot = MAX_MEM_SLOTS;
continue;
}
-   num_physpages += slot_psize;
memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)),
  PFN_PHYS(slot_psize), node);
}
@@ -480,10 +477,9 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, datasize, initsize, tmp;
unsigned node;
 
-   high_memory = (void *) __va(num_physpages << PAGE_SHIFT);
+   high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
 
for_each_online_node

[RFC PATCH v2, part4 24/39] mm/mn10300: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: David Howells 
Cc: Koichi Yasutake 
Cc: linux-am33-l...@redhat.com
Cc: linux-kernel@vger.kernel.org
---
 arch/mn10300/mm/init.c |   26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index d7312aa..f43d993 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -99,15 +99,12 @@ void __init paging_init(void)
  */
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int tmp;
-
BUG_ON(!mem_map);
 
 #define START_PFN  (contig_page_data.bdata->node_min_pfn)
 #define MAX_LOW_PFN(contig_page_data.bdata->node_low_pfn)
 
-   max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
+   max_mapnr = MAX_LOW_PFN - START_PFN;
high_memory = (void *) __va(MAX_LOW_PFN * PAGE_SIZE);
 
/* clear the zero-page */
@@ -116,26 +113,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = 0; tmp < num_physpages; tmp++)
-   if (PageReserved(&mem_map[tmp]))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_stext;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO
-  "Memory: %luk/%luk available"
-  " (%dk kernel code, %dk reserved, %dk data, %dk init,"
-  " %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT - 10),
-  max_mapnr << (PAGE_SHIFT - 10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT - 10),
-  datasize >> 10,
-  initsize >> 10,
-  totalhigh_pages << (PAGE_SHIFT - 10));
+   mem_init_print_info(NULL);
 }
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 25/39] mm/mn10300: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: David Howells 
Cc: Koichi Yasutake 
Cc: linux-am33-l...@redhat.com
Cc: linux-kernel@vger.kernel.org
---
 arch/mn10300/mm/init.c |   26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/mn10300/mm/init.c b/arch/mn10300/mm/init.c
index d7312aa..f43d993 100644
--- a/arch/mn10300/mm/init.c
+++ b/arch/mn10300/mm/init.c
@@ -99,15 +99,12 @@ void __init paging_init(void)
  */
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int tmp;
-
BUG_ON(!mem_map);
 
 #define START_PFN  (contig_page_data.bdata->node_min_pfn)
 #define MAX_LOW_PFN(contig_page_data.bdata->node_low_pfn)
 
-   max_mapnr = num_physpages = MAX_LOW_PFN - START_PFN;
+   max_mapnr = MAX_LOW_PFN - START_PFN;
high_memory = (void *) __va(MAX_LOW_PFN * PAGE_SIZE);
 
/* clear the zero-page */
@@ -116,26 +113,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = 0; tmp < num_physpages; tmp++)
-   if (PageReserved(&mem_map[tmp]))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_stext;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO
-  "Memory: %luk/%luk available"
-  " (%dk kernel code, %dk reserved, %dk data, %dk init,"
-  " %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT - 10),
-  max_mapnr << (PAGE_SHIFT - 10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT - 10),
-  datasize >> 10,
-  initsize >> 10,
-  totalhigh_pages << (PAGE_SHIFT - 10));
+   mem_init_print_info(NULL);
 }
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 25/39] mm/openrisc: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Jonas Bonn 
Cc: David Howells 
Cc: Arnd Bergmann 
Cc: li...@lists.openrisc.net
Cc: linux-kernel@vger.kernel.org
---
 arch/openrisc/mm/init.c |   44 
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
index 71d6b40..f3c8f47 100644
--- a/arch/openrisc/mm/init.c
+++ b/arch/openrisc/mm/init.c
@@ -191,56 +191,20 @@ void __init paging_init(void)
 
 /* References to section boundaries */
 
-static int __init free_pages_init(void)
-{
-   int reservedpages, pfn;
-
-   /* this will put all low memory onto the freelists */
-   free_all_bootmem();
-
-   reservedpages = 0;
-   for (pfn = 0; pfn < max_low_pfn; pfn++) {
-   /*
-* Only count reserved RAM pages
-*/
-   if (PageReserved(mem_map + pfn))
-   reservedpages++;
-   }
-
-   return reservedpages;
-}
-
-static void __init set_max_mapnr_init(void)
-{
-   max_mapnr = num_physpages = max_low_pfn;
-}
-
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-
BUG_ON(!mem_map);
 
-   set_max_mapnr_init();
-
+   max_mapnr = max_low_pfn;
high_memory = (void *)__va(max_low_pfn * PAGE_SIZE);
 
/* clear the zero-page */
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
-   reservedpages = free_pages_init();
-
-   codesize = (unsigned long)&_etext - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_etext;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
+   /* this will put all low memory onto the freelists */
+   free_all_bootmem();
 
-   printk(KERN_INFO
-  "Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk 
data, %dk init, %ldk highmem)\n",
-  (unsigned long)nr_free_pages() << (PAGE_SHIFT - 10),
-  max_mapnr << (PAGE_SHIFT - 10), codesize >> 10,
-  reservedpages << (PAGE_SHIFT - 10), datasize >> 10,
-  initsize >> 10, (unsigned long)(0 << (PAGE_SHIFT - 10))
-   );
+   mem_init_print_info(NULL);
 
printk("mem_init_done ...\n");
mem_init_done = 1;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 26/39] mm/openrisc: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Jonas Bonn 
Cc: David Howells 
Cc: Arnd Bergmann 
Cc: li...@lists.openrisc.net
Cc: linux-kernel@vger.kernel.org
---
 arch/openrisc/mm/init.c |   44 
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
index 71d6b40..f3c8f47 100644
--- a/arch/openrisc/mm/init.c
+++ b/arch/openrisc/mm/init.c
@@ -191,56 +191,20 @@ void __init paging_init(void)
 
 /* References to section boundaries */
 
-static int __init free_pages_init(void)
-{
-   int reservedpages, pfn;
-
-   /* this will put all low memory onto the freelists */
-   free_all_bootmem();
-
-   reservedpages = 0;
-   for (pfn = 0; pfn < max_low_pfn; pfn++) {
-   /*
-* Only count reserved RAM pages
-*/
-   if (PageReserved(mem_map + pfn))
-   reservedpages++;
-   }
-
-   return reservedpages;
-}
-
-static void __init set_max_mapnr_init(void)
-{
-   max_mapnr = num_physpages = max_low_pfn;
-}
-
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-
BUG_ON(!mem_map);
 
-   set_max_mapnr_init();
-
+   max_mapnr = max_low_pfn;
high_memory = (void *)__va(max_low_pfn * PAGE_SIZE);
 
/* clear the zero-page */
memset((void *)empty_zero_page, 0, PAGE_SIZE);
 
-   reservedpages = free_pages_init();
-
-   codesize = (unsigned long)&_etext - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_etext;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
+   /* this will put all low memory onto the freelists */
+   free_all_bootmem();
 
-   printk(KERN_INFO
-  "Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk 
data, %dk init, %ldk highmem)\n",
-  (unsigned long)nr_free_pages() << (PAGE_SHIFT - 10),
-  max_mapnr << (PAGE_SHIFT - 10), codesize >> 10,
-  reservedpages << (PAGE_SHIFT - 10), datasize >> 10,
-  initsize >> 10, (unsigned long)(0 << (PAGE_SHIFT - 10))
-   );
+   mem_init_print_info(NULL);
 
printk("mem_init_done ...\n");
mem_init_done = 1;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 26/39] mm/PARISC: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Thomas Gleixner 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: linux-par...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/parisc/mm/init.c |   46 +++---
 1 file changed, 3 insertions(+), 43 deletions(-)

diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 1fe9d841..f80c175 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -214,7 +214,6 @@ static void __init setup_bootmem(void)
mem_limit_func();   /* check for "mem=" argument */
 
mem_max = 0;
-   num_physpages = 0;
for (i = 0; i < npmem_ranges; i++) {
unsigned long rsize;
 
@@ -229,10 +228,8 @@ static void __init setup_bootmem(void)
npmem_ranges = i + 1;
mem_max = mem_limit;
}
-   num_physpages += pmem_ranges[i].pages;
break;
}
-   num_physpages += pmem_ranges[i].pages;
mem_max += rsize;
}
 
@@ -532,7 +529,7 @@ void free_initmem(void)
 * pages are no-longer executable */
flush_icache_range(init_begin, init_end);

-   num_physpages += free_initmem_default(-1);
+   free_initmem_default(-1);
 
/* set up a new led state on systems shipped LED State panel */
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
@@ -580,8 +577,6 @@ unsigned long pcxl_dma_start __read_mostly;
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-
/* Do sanity checks on page table constants */
BUILD_BUG_ON(PTE_ENTRY_SIZE != sizeof(pte_t));
BUILD_BUG_ON(PMD_ENTRY_SIZE != sizeof(pmd_t));
@@ -603,33 +598,6 @@ void __init mem_init(void)
}
 #endif
 
-   codesize = (unsigned long)_etext - (unsigned long)_text;
-   datasize = (unsigned long)_edata - (unsigned long)_etext;
-   initsize = (unsigned long)__init_end - (unsigned long)__init_begin;
-
-   reservedpages = 0;
-{
-   unsigned long pfn;
-#ifdef CONFIG_DISCONTIGMEM
-   int i;
-
-   for (i = 0; i < npmem_ranges; i++) {
-   for (pfn = node_start_pfn(i); pfn < node_end_pfn(i); pfn++) {
-   if (PageReserved(pfn_to_page(pfn)))
-   reservedpages++;
-   }
-   }
-#else /* !CONFIG_DISCONTIGMEM */
-   for (pfn = 0; pfn < max_pfn; pfn++) {
-   /*
-* Only count reserved RAM pages
-*/
-   if (PageReserved(pfn_to_page(pfn)))
-   reservedpages++;
-   }
-#endif
-}
-
 #ifdef CONFIG_PA11
if (hppa_dma_ops == &pcxl_dma_ops) {
pcxl_dma_start = (unsigned long)SET_MAP_OFFSET(MAP_START);
@@ -643,15 +611,7 @@ void __init mem_init(void)
parisc_vmalloc_start = SET_MAP_OFFSET(MAP_START);
 #endif
 
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, %dk 
reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   initsize >> 10
-   );
-
+   mem_init_print_info(NULL);
 #ifdef CONFIG_DEBUG_KERNEL /* double-sanity-check paranoia */
printk("virtual kernel memory layout:\n"
   "vmalloc : 0x%p - 0x%p   (%4ld MB)\n"
@@ -1099,6 +1059,6 @@ void flush_tlb_all(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-   num_physpages += free_reserved_area(start, end, -1, "initrd");
+   free_reserved_area(start, end, -1, "initrd");
 }
 #endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 27/39] mm/PARISC: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Thomas Gleixner 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: linux-par...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/parisc/mm/init.c |   46 +++---
 1 file changed, 3 insertions(+), 43 deletions(-)

diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 1fe9d841..f80c175 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -214,7 +214,6 @@ static void __init setup_bootmem(void)
mem_limit_func();   /* check for "mem=" argument */
 
mem_max = 0;
-   num_physpages = 0;
for (i = 0; i < npmem_ranges; i++) {
unsigned long rsize;
 
@@ -229,10 +228,8 @@ static void __init setup_bootmem(void)
npmem_ranges = i + 1;
mem_max = mem_limit;
}
-   num_physpages += pmem_ranges[i].pages;
break;
}
-   num_physpages += pmem_ranges[i].pages;
mem_max += rsize;
}
 
@@ -532,7 +529,7 @@ void free_initmem(void)
 * pages are no-longer executable */
flush_icache_range(init_begin, init_end);

-   num_physpages += free_initmem_default(-1);
+   free_initmem_default(-1);
 
/* set up a new led state on systems shipped LED State panel */
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
@@ -580,8 +577,6 @@ unsigned long pcxl_dma_start __read_mostly;
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-
/* Do sanity checks on page table constants */
BUILD_BUG_ON(PTE_ENTRY_SIZE != sizeof(pte_t));
BUILD_BUG_ON(PMD_ENTRY_SIZE != sizeof(pmd_t));
@@ -603,33 +598,6 @@ void __init mem_init(void)
}
 #endif
 
-   codesize = (unsigned long)_etext - (unsigned long)_text;
-   datasize = (unsigned long)_edata - (unsigned long)_etext;
-   initsize = (unsigned long)__init_end - (unsigned long)__init_begin;
-
-   reservedpages = 0;
-{
-   unsigned long pfn;
-#ifdef CONFIG_DISCONTIGMEM
-   int i;
-
-   for (i = 0; i < npmem_ranges; i++) {
-   for (pfn = node_start_pfn(i); pfn < node_end_pfn(i); pfn++) {
-   if (PageReserved(pfn_to_page(pfn)))
-   reservedpages++;
-   }
-   }
-#else /* !CONFIG_DISCONTIGMEM */
-   for (pfn = 0; pfn < max_pfn; pfn++) {
-   /*
-* Only count reserved RAM pages
-*/
-   if (PageReserved(pfn_to_page(pfn)))
-   reservedpages++;
-   }
-#endif
-}
-
 #ifdef CONFIG_PA11
if (hppa_dma_ops == &pcxl_dma_ops) {
pcxl_dma_start = (unsigned long)SET_MAP_OFFSET(MAP_START);
@@ -643,15 +611,7 @@ void __init mem_init(void)
parisc_vmalloc_start = SET_MAP_OFFSET(MAP_START);
 #endif
 
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, %dk 
reserved, %dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   initsize >> 10
-   );
-
+   mem_init_print_info(NULL);
 #ifdef CONFIG_DEBUG_KERNEL /* double-sanity-check paranoia */
printk("virtual kernel memory layout:\n"
   "vmalloc : 0x%p - 0x%p   (%4ld MB)\n"
@@ -1099,6 +1059,6 @@ void flush_tlb_all(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-   num_physpages += free_reserved_area(start, end, -1, "initrd");
+   free_reserved_area(start, end, -1, "initrd");
 }
 #endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 27/39] mm/ppc: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 arch/powerpc/mm/mem.c |   56 +++--
 1 file changed, 12 insertions(+), 44 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 0e154a9..8aba687 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -303,46 +303,27 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-#ifdef CONFIG_NEED_MULTIPLE_NODES
-   int nid;
-#endif
-   pg_data_t *pgdat;
-   unsigned long i;
-   struct page *page;
-   unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
-
 #ifdef CONFIG_SWIOTLB
swiotlb_init(0);
 #endif
 
-   num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
 #ifdef CONFIG_NEED_MULTIPLE_NODES
-for_each_online_node(nid) {
-   if (NODE_DATA(nid)->node_spanned_pages != 0) {
-   printk("freeing bootmem node %d\n", nid);
-   free_all_bootmem_node(NODE_DATA(nid));
-   }
+   {
+   pg_data_t *pgdat;
+
+   for_each_online_pgdat(pgdat)
+   if (pgdat->node_spanned_pages != 0) {
+   printk("freeing bootmem node %d\n",
+   pgdat->node_id);
+   free_all_bootmem_node(pgdat);
+   }
}
 #else
max_mapnr = max_pfn;
free_all_bootmem();
 #endif
-   for_each_online_pgdat(pgdat) {
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   if (!pfn_valid(pgdat->node_start_pfn + i))
-   continue;
-   page = pgdat_page_nr(pgdat, i);
-   if (PageReserved(page))
-   reservedpages++;
-   }
-   }
-
-   codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
-   bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
 
 #ifdef CONFIG_HIGHMEM
{
@@ -352,13 +333,9 @@ void __init mem_init(void)
for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
struct page *page = pfn_to_page(pfn);
-   if (memblock_is_reserved(paddr))
-   continue;
-   free_highmem_page(page);
-   reservedpages--;
+   if (!memblock_is_reserved(paddr))
+   free_highmem_page(page);
}
-   printk(KERN_DEBUG "High memory: %luk\n",
-  totalhigh_pages << (PAGE_SHIFT-10));
}
 #endif /* CONFIG_HIGHMEM */
 
@@ -371,16 +348,7 @@ void __init mem_init(void)
(mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1;
 #endif
 
-   printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, "
-  "%luk reserved, %luk data, %luk bss, %luk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   bsssize >> 10,
-   initsize >> 10);
-
+   mem_init_print_info(NULL);
 #ifdef CONFIG_PPC32
pr_info("Kernel virtual memory layout:\n");
pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 28/39] mm/ppc: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 arch/powerpc/mm/mem.c |   56 +++--
 1 file changed, 12 insertions(+), 44 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 0e154a9..8aba687 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -303,46 +303,27 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-#ifdef CONFIG_NEED_MULTIPLE_NODES
-   int nid;
-#endif
-   pg_data_t *pgdat;
-   unsigned long i;
-   struct page *page;
-   unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
-
 #ifdef CONFIG_SWIOTLB
swiotlb_init(0);
 #endif
 
-   num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
 #ifdef CONFIG_NEED_MULTIPLE_NODES
-for_each_online_node(nid) {
-   if (NODE_DATA(nid)->node_spanned_pages != 0) {
-   printk("freeing bootmem node %d\n", nid);
-   free_all_bootmem_node(NODE_DATA(nid));
-   }
+   {
+   pg_data_t *pgdat;
+
+   for_each_online_pgdat(pgdat)
+   if (pgdat->node_spanned_pages != 0) {
+   printk("freeing bootmem node %d\n",
+   pgdat->node_id);
+   free_all_bootmem_node(pgdat);
+   }
}
 #else
max_mapnr = max_pfn;
free_all_bootmem();
 #endif
-   for_each_online_pgdat(pgdat) {
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   if (!pfn_valid(pgdat->node_start_pfn + i))
-   continue;
-   page = pgdat_page_nr(pgdat, i);
-   if (PageReserved(page))
-   reservedpages++;
-   }
-   }
-
-   codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
-   datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
-   initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
-   bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
 
 #ifdef CONFIG_HIGHMEM
{
@@ -352,13 +333,9 @@ void __init mem_init(void)
for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
struct page *page = pfn_to_page(pfn);
-   if (memblock_is_reserved(paddr))
-   continue;
-   free_highmem_page(page);
-   reservedpages--;
+   if (!memblock_is_reserved(paddr))
+   free_highmem_page(page);
}
-   printk(KERN_DEBUG "High memory: %luk\n",
-  totalhigh_pages << (PAGE_SHIFT-10));
}
 #endif /* CONFIG_HIGHMEM */
 
@@ -371,16 +348,7 @@ void __init mem_init(void)
(mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1;
 #endif
 
-   printk(KERN_INFO "Memory: %luk/%luk available (%luk kernel code, "
-  "%luk reserved, %luk data, %luk bss, %luk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   bsssize >> 10,
-   initsize >> 10);
-
+   mem_init_print_info(NULL);
 #ifdef CONFIG_PPC32
pr_info("Kernel virtual memory layout:\n");
pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 28/39] mm/s390: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: linux...@de.ibm.com
Cc: linux-s...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/s390/mm/init.c |   17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 4a72888..07e6df6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -125,9 +125,7 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-
-max_mapnr = num_physpages = max_low_pfn;
+max_mapnr = max_low_pfn;
 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
/* Setup guest page hinting */
@@ -137,18 +135,7 @@ void __init mem_init(void)
free_all_bootmem();
setup_zero_pages(); /* Setup zeroed pages. */
 
-   reservedpages = 0;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, 
%ldk data, %ldk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-max_mapnr << (PAGE_SHIFT-10),
-codesize >> 10,
-reservedpages << (PAGE_SHIFT-10),
-datasize >>10,
-initsize >> 10);
+   mem_init_print_info(NULL);
printk("Write protected kernel read-only data: %#lx - %#lx\n",
   (unsigned long)&_stext,
   PFN_ALIGN((unsigned long)&_eshared) - 1);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 29/39] mm/s390: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: linux...@de.ibm.com
Cc: linux-s...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/s390/mm/init.c |   17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 4a72888..07e6df6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -125,9 +125,7 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-
-max_mapnr = num_physpages = max_low_pfn;
+max_mapnr = max_low_pfn;
 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 
/* Setup guest page hinting */
@@ -137,18 +135,7 @@ void __init mem_init(void)
free_all_bootmem();
setup_zero_pages(); /* Setup zeroed pages. */
 
-   reservedpages = 0;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, 
%ldk data, %ldk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-max_mapnr << (PAGE_SHIFT-10),
-codesize >> 10,
-reservedpages << (PAGE_SHIFT-10),
-datasize >>10,
-initsize >> 10);
+   mem_init_print_info(NULL);
printk("Write protected kernel read-only data: %#lx - %#lx\n",
   (unsigned long)&_stext,
   PFN_ALIGN((unsigned long)&_eshared) - 1);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 29/39] mm/score: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chen Liqin 
Cc: Lennox Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/score/mm/init.c |   26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c
index 579fc4e..2a223d8 100644
--- a/arch/score/mm/init.c
+++ b/arch/score/mm/init.c
@@ -77,33 +77,11 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long tmp, ram = 0;
-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
free_all_bootmem();
setup_zero_page();  /* Setup zeroed pages. */
-   reservedpages = 0;
-
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   if (page_is_ram(tmp)) {
-   ram++;
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   }
-
-   num_physpages = ram;
-   codesize = (unsigned long) &_etext - (unsigned long) &_text;
-   datasize = (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
-   "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
-   (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
-   ram << (PAGE_SHIFT-10), codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10), datasize >> 10,
-   initsize >> 10,
-   totalhigh_pages << (PAGE_SHIFT-10));
+
+   mem_init_print_info(NULL);
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] memcg: fix memcg_cache_name() to use cgroup_name()

2013-03-24 Thread Li Zefan
>> Thanks for identifying and fixing this.
>>
>> Li is right. The cache name will live long, but this is because the
>> slab/slub caches will strdup it internally. So the actual memcg
>> allocation is short lived.
> 
> OK, I have totally missed that. Sorry about the confusion. Then all the
> churn around the allocation is pointless, no?
> What about:
> ---
>>From 7ed7f53bb597e8cb40d9ac91ce16142fb60f1e93 Mon Sep 17 00:00:00 2001
> From: Michal Hocko 
> Date: Fri, 22 Mar 2013 10:22:54 +0100
> Subject: [PATCH] memcg: fix memcg_cache_name() to use cgroup_name()
> 
> As cgroup supports rename, it's unsafe to dereference dentry->d_name
> without proper vfs locks. Fix this by using cgroup_name() rather than
> dentry directly.
> 
> Also open code memcg_cache_name because it is called only from
> kmem_cache_dup which frees the returned name right after
> kmem_cache_create_memcg makes a copy of it. Such a short-lived
> allocation doesn't make too much sense. So replace it by a static
> buffer as kmem_cache_dup is called with memcg_cache_mutex.
> 

I doubt it's a win to add 4K to kernel text size instead of adding
a few extra lines of code... but it's up to you.

> Signed-off-by: Li Zefan 
> Signed-off-by: Michal Hocko 
> ---
>  mm/memcontrol.c |   33 +++--
>  1 file changed, 11 insertions(+), 22 deletions(-)
...
>  static struct kmem_cache *kmem_cache_dup(struct mem_cgroup *memcg,
>struct kmem_cache *s)
>  {
>   char *name;
>   struct kmem_cache *new;
> + static char tmp_name[PAGE_SIZE];
>  
> - name = memcg_cache_name(memcg, s);
> - if (!name)
> - return NULL;
> + lockdep_assert_held(&memcg_cache_mutex);
> +
> + rcu_read_lock();
> + tmp_name = snprintf(tmp_name, sizeof(tmp_name), "%s(%d:%s)", s->name,
> +  memcg_cache_id(memcg), cgroup_name(memcg->css.cgroup));

I guess you didn't turn on CONFIG_MEMCG_KMEM?

snprintf() returns a int value.

> + rcu_read_unlock();
>  
> - new = kmem_cache_create_memcg(memcg, name, s->object_size, s->align,
> + new = kmem_cache_create_memcg(memcg, tmp_name, s->object_size, s->align,
> (s->flags & ~SLAB_PANIC), s->ctor, s);
>  
>   if (new)
>   new->allocflags |= __GFP_KMEMCG;
>  
> - kfree(name);
>   return new;
>  }
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 30/39] mm/SH: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Paul Mundt 
Cc: Wen Congyang 
Cc: Tang Chen 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/sh/mm/init.c |   25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index aecd913..3826596 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -407,24 +407,18 @@ unsigned int mem_init_done = 0;
 
 void __init mem_init(void)
 {
-   int codesize, datasize, initsize;
-   int nid;
+   pg_data_t *pgdat;
 
iommu_init();
 
-   num_physpages = 0;
high_memory = NULL;
 
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
+   for_each_online_pgdat(pgdat) {
void *node_high_memory;
 
-   num_physpages += pgdat->node_present_pages;
-
if (pgdat->node_spanned_pages)
free_all_bootmem_node(pgdat);
 
-
node_high_memory = (void *)__va((pgdat->node_start_pfn +
 pgdat->node_spanned_pages) <<
 PAGE_SHIFT);
@@ -441,19 +435,8 @@ void __init mem_init(void)
 
vsyscall_init();
 
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-  "%dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   datasize >> 10,
-   initsize >> 10);
-
-   printk(KERN_INFO "virtual kernel memory layout:\n"
+   mem_init_print_info(NULL);
+   pr_info("virtual kernel memory layout:\n"
"fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 #ifdef CONFIG_HIGHMEM
"pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 31/39] mm/SH: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Paul Mundt 
Cc: Wen Congyang 
Cc: Tang Chen 
Cc: linux...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/sh/mm/init.c |   25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index aecd913..3826596 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -407,24 +407,18 @@ unsigned int mem_init_done = 0;
 
 void __init mem_init(void)
 {
-   int codesize, datasize, initsize;
-   int nid;
+   pg_data_t *pgdat;
 
iommu_init();
 
-   num_physpages = 0;
high_memory = NULL;
 
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
+   for_each_online_pgdat(pgdat) {
void *node_high_memory;
 
-   num_physpages += pgdat->node_present_pages;
-
if (pgdat->node_spanned_pages)
free_all_bootmem_node(pgdat);
 
-
node_high_memory = (void *)__va((pgdat->node_start_pfn +
 pgdat->node_spanned_pages) <<
 PAGE_SHIFT);
@@ -441,19 +435,8 @@ void __init mem_init(void)
 
vsyscall_init();
 
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-  "%dk data, %dk init)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   datasize >> 10,
-   initsize >> 10);
-
-   printk(KERN_INFO "virtual kernel memory layout:\n"
+   mem_init_print_info(NULL);
+   pr_info("virtual kernel memory layout:\n"
"fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 #ifdef CONFIG_HIGHMEM
"pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 31/39] mm/SPARC: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: "David S. Miller" 
Cc: Sam Ravnborg 
Cc: Yasuaki Ishimatsu 
Cc: Tang Chen 
Cc: sparcli...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/sparc/kernel/leon_smp.c |3 ---
 arch/sparc/mm/init_32.c  |   33 +++--
 arch/sparc/mm/init_64.c  |   27 +++
 3 files changed, 6 insertions(+), 57 deletions(-)

diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 143b1a5..5a9ab8d 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -269,15 +269,12 @@ void __init leon_smp_done(void)
/* Free unneeded trap tables */
if (!cpu_present(1)) {
free_reserved_page(virt_to_page(&trapbase_cpu1));
-   num_physpages++;
}
if (!cpu_present(2)) {
free_reserved_page(virt_to_page(&trapbase_cpu2));
-   num_physpages++;
}
if (!cpu_present(3)) {
free_reserved_page(virt_to_page(&trapbase_cpu3));
-   num_physpages++;
}
/* Ok, they are spinning and ready to go. */
smp_processors_ready = 1;
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index e96afed..25d10cf 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -288,10 +288,6 @@ static void map_high_region(unsigned long start_pfn, 
unsigned long end_pfn)
 
 void __init mem_init(void)
 {
-   int codepages = 0;
-   int datapages = 0;
-   int initpages = 0; 
-   int reservedpages = 0;
int i;
 
if (PKMAP_BASE+LAST_PKMAP*PAGE_SIZE >= FIXADDR_START) {
@@ -329,8 +325,6 @@ void __init mem_init(void)
unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT;
unsigned long end_pfn = (sp_banks[i].base_addr + 
sp_banks[i].num_bytes) >> PAGE_SHIFT;
 
-   num_physpages += sp_banks[i].num_bytes >> PAGE_SHIFT;
-
if (end_pfn <= highstart_pfn)
continue;
 
@@ -340,39 +334,18 @@ void __init mem_init(void)
map_high_region(start_pfn, end_pfn);
}

-   codepages = (((unsigned long) &_etext) - ((unsigned long)&_start));
-   codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
-   datapages = (((unsigned long) &_edata) - ((unsigned long)&_etext));
-   datapages = PAGE_ALIGN(datapages) >> PAGE_SHIFT;
-   initpages = (((unsigned long) &__init_end) - ((unsigned long) 
&__init_begin));
-   initpages = PAGE_ALIGN(initpages) >> PAGE_SHIFT;
-
-   /* Ignore memory holes for the purpose of counting reserved pages */
-   for (i=0; i < max_low_pfn; i++)
-   if (test_bit(i >> (20 - PAGE_SHIFT), sparc_valid_addr_bitmap)
-   && PageReserved(pfn_to_page(i)))
-   reservedpages++;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, %dk 
reserved, %dk data, %dk init, %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  num_physpages << (PAGE_SHIFT - 10),
-  codepages << (PAGE_SHIFT-10),
-  reservedpages << (PAGE_SHIFT - 10),
-  datapages << (PAGE_SHIFT-10), 
-  initpages << (PAGE_SHIFT-10),
-  totalhigh_pages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
 }
 
 void free_initmem (void)
 {
-   num_physpages += free_initmem_default(POISON_FREE_INITMEM);
+   free_initmem_default(POISON_FREE_INITMEM);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-   num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
-   "initrd");
+   free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
 }
 #endif
 
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index fde310e..6768e47 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2023,7 +2023,6 @@ static void __init patch_tlb_miss_handler_bitmap(void)
 
 void __init mem_init(void)
 {
-   unsigned long codepages, datapages, initpages;
unsigned long addr, last;
 
addr = PAGE_OFFSET + kern_base;
@@ -2051,11 +2050,6 @@ void __init mem_init(void)
free_all_bootmem();
 #endif
 
-   /* We subtract one to account for the mem_map_zero page
-* allocated below.
-*/
-   num_physpages = totalram_pages - 1;
-
/*
 * Set up the zero page, mark it reserved, so that page count
 * is not manipulated when freeing the page from user ptes.
@@ -2067,19 +2061,7 @@ void __init mem_init(void)
}
mark_page_reserved(mem_map_zero);
 
-   codepages = (((unsigned long) _etext) - ((unsigned long) _start));
-   codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
-   datapages = (((unsigned long) _edata) - ((unsigned long) _etext));
-   dat

[RFC PATCH v2, part4 32/39] mm/SPARC: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: "David S. Miller" 
Cc: Sam Ravnborg 
Cc: Yasuaki Ishimatsu 
Cc: Tang Chen 
Cc: sparcli...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/sparc/kernel/leon_smp.c |3 ---
 arch/sparc/mm/init_32.c  |   33 +++--
 arch/sparc/mm/init_64.c  |   27 +++
 3 files changed, 6 insertions(+), 57 deletions(-)

diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 143b1a5..5a9ab8d 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -269,15 +269,12 @@ void __init leon_smp_done(void)
/* Free unneeded trap tables */
if (!cpu_present(1)) {
free_reserved_page(virt_to_page(&trapbase_cpu1));
-   num_physpages++;
}
if (!cpu_present(2)) {
free_reserved_page(virt_to_page(&trapbase_cpu2));
-   num_physpages++;
}
if (!cpu_present(3)) {
free_reserved_page(virt_to_page(&trapbase_cpu3));
-   num_physpages++;
}
/* Ok, they are spinning and ready to go. */
smp_processors_ready = 1;
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index e96afed..25d10cf 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -288,10 +288,6 @@ static void map_high_region(unsigned long start_pfn, 
unsigned long end_pfn)
 
 void __init mem_init(void)
 {
-   int codepages = 0;
-   int datapages = 0;
-   int initpages = 0; 
-   int reservedpages = 0;
int i;
 
if (PKMAP_BASE+LAST_PKMAP*PAGE_SIZE >= FIXADDR_START) {
@@ -329,8 +325,6 @@ void __init mem_init(void)
unsigned long start_pfn = sp_banks[i].base_addr >> PAGE_SHIFT;
unsigned long end_pfn = (sp_banks[i].base_addr + 
sp_banks[i].num_bytes) >> PAGE_SHIFT;
 
-   num_physpages += sp_banks[i].num_bytes >> PAGE_SHIFT;
-
if (end_pfn <= highstart_pfn)
continue;
 
@@ -340,39 +334,18 @@ void __init mem_init(void)
map_high_region(start_pfn, end_pfn);
}

-   codepages = (((unsigned long) &_etext) - ((unsigned long)&_start));
-   codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
-   datapages = (((unsigned long) &_edata) - ((unsigned long)&_etext));
-   datapages = PAGE_ALIGN(datapages) >> PAGE_SHIFT;
-   initpages = (((unsigned long) &__init_end) - ((unsigned long) 
&__init_begin));
-   initpages = PAGE_ALIGN(initpages) >> PAGE_SHIFT;
-
-   /* Ignore memory holes for the purpose of counting reserved pages */
-   for (i=0; i < max_low_pfn; i++)
-   if (test_bit(i >> (20 - PAGE_SHIFT), sparc_valid_addr_bitmap)
-   && PageReserved(pfn_to_page(i)))
-   reservedpages++;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, %dk 
reserved, %dk data, %dk init, %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  num_physpages << (PAGE_SHIFT - 10),
-  codepages << (PAGE_SHIFT-10),
-  reservedpages << (PAGE_SHIFT - 10),
-  datapages << (PAGE_SHIFT-10), 
-  initpages << (PAGE_SHIFT-10),
-  totalhigh_pages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
 }
 
 void free_initmem (void)
 {
-   num_physpages += free_initmem_default(POISON_FREE_INITMEM);
+   free_initmem_default(POISON_FREE_INITMEM);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-   num_physpages += free_reserved_area(start, end, POISON_FREE_INITMEM,
-   "initrd");
+   free_reserved_area(start, end, POISON_FREE_INITMEM, "initrd");
 }
 #endif
 
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index fde310e..6768e47 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2023,7 +2023,6 @@ static void __init patch_tlb_miss_handler_bitmap(void)
 
 void __init mem_init(void)
 {
-   unsigned long codepages, datapages, initpages;
unsigned long addr, last;
 
addr = PAGE_OFFSET + kern_base;
@@ -2051,11 +2050,6 @@ void __init mem_init(void)
free_all_bootmem();
 #endif
 
-   /* We subtract one to account for the mem_map_zero page
-* allocated below.
-*/
-   num_physpages = totalram_pages - 1;
-
/*
 * Set up the zero page, mark it reserved, so that page count
 * is not manipulated when freeing the page from user ptes.
@@ -2067,19 +2061,7 @@ void __init mem_init(void)
}
mark_page_reserved(mem_map_zero);
 
-   codepages = (((unsigned long) _etext) - ((unsigned long) _start));
-   codepages = PAGE_ALIGN(codepages) >> PAGE_SHIFT;
-   datapages = (((unsigned long) _edata) - ((unsigned long) _etext));
-   dat

[RFC PATCH v2, part4 32/39] mm/tile: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chris Metcalf 
Cc: Bjorn Helgaas 
Cc: "David S. Miller" 
Cc: Wen Congyang 
Cc: linux-kernel@vger.kernel.org
---
 arch/tile/kernel/setup.c |   16 
 arch/tile/mm/init.c  |   15 +--
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index a986b71..54469a5 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -329,6 +329,7 @@ static void __init setup_memory(void)
 #if defined(CONFIG_HIGHMEM) || defined(__tilegx__)
long lowmem_pages;
 #endif
+   unsigned long physpages = 0;
 
/* We are using a char to hold the cpu_2_node[] mapping */
BUILD_BUG_ON(MAX_NUMNODES > 127);
@@ -388,8 +389,8 @@ static void __init setup_memory(void)
continue;
}
}
-   if (num_physpages + PFN_DOWN(range.size) > maxmem_pfn) {
-   int max_size = maxmem_pfn - num_physpages;
+   if (physpages + PFN_DOWN(range.size) > maxmem_pfn) {
+   int max_size = maxmem_pfn - physpages;
if (max_size > 0) {
pr_err("Maxmem reduced node %d to %d pages\n",
   i, max_size);
@@ -446,7 +447,7 @@ static void __init setup_memory(void)
node_start_pfn[i] = start;
node_end_pfn[i] = end;
node_controller[i] = range.controller;
-   num_physpages += size;
+   physpages += size;
max_pfn = end;
 
/* Mark node as online */
@@ -465,7 +466,7 @@ static void __init setup_memory(void)
 * we're willing to use at 8 million pages (32GB of 4KB pages).
 */
cap = 8 * 1024 * 1024;  /* 8 million pages */
-   if (num_physpages > cap) {
+   if (physpages > cap) {
int num_nodes = num_online_nodes();
int cap_each = cap / num_nodes;
unsigned long dropped_pages = 0;
@@ -476,10 +477,10 @@ static void __init setup_memory(void)
node_end_pfn[i] = node_start_pfn[i] + cap_each;
}
}
-   num_physpages -= dropped_pages;
+   physpages -= dropped_pages;
pr_warning("Only using %ldMB memory;"
   " ignoring %ldMB.\n",
-  num_physpages >> (20 - PAGE_SHIFT),
+  physpages >> (20 - PAGE_SHIFT),
   dropped_pages >> (20 - PAGE_SHIFT));
pr_warning("Consider using a larger page size.\n");
}
@@ -497,7 +498,7 @@ static void __init setup_memory(void)
 
lowmem_pages = (mappable_physpages > MAXMEM_PFN) ?
MAXMEM_PFN : mappable_physpages;
-   highmem_pages = (long) (num_physpages - lowmem_pages);
+   highmem_pages = (long) (physpages - lowmem_pages);
 
pr_notice("%ldMB HIGHMEM available.\n",
   pages_to_mb(highmem_pages > 0 ? highmem_pages : 0));
@@ -514,7 +515,6 @@ static void __init setup_memory(void)
pr_warning("Use a HIGHMEM enabled kernel.\n");
max_low_pfn = MAXMEM_PFN;
max_pfn = MAXMEM_PFN;
-   num_physpages = MAXMEM_PFN;
node_end_pfn[0] = MAXMEM_PFN;
} else {
pr_notice("%ldMB memory available.\n",
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index f2ac2f4..e182958 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -821,7 +821,6 @@ static void __init set_max_mapnr_init(void)
 
 void __init mem_init(void)
 {
-   int codesize, datasize, initsize;
int i;
 #ifndef __tilegx__
void *last;
@@ -853,19 +852,7 @@ void __init mem_init(void)
set_non_bootmem_pages_init();
 #endif
 
-   codesize =  (unsigned long)&_etext - (unsigned long)&_text;
-   datasize =  (unsigned long)&_end - (unsigned long)&_sdata;
-   initsize =  (unsigned long)&_einittext - (unsigned long)&_sinittext;
-   initsize += (unsigned long)&_einitdata - (unsigned long)&_sinitdata;
-
-   pr_info("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk 
init, %ldk highmem)\n",
-   (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   datasize >> 10,
-   initsize >> 10,
-   (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
-  );
+   mem_init_print_info(NULL);
 
/*
 * In debug mode, dump some interesting memory mappings.
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please 

[RFC PATCH v2, part4 33/39] mm/tile: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chris Metcalf 
Cc: Bjorn Helgaas 
Cc: "David S. Miller" 
Cc: Wen Congyang 
Cc: linux-kernel@vger.kernel.org
---
 arch/tile/kernel/setup.c |   16 
 arch/tile/mm/init.c  |   15 +--
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
index a986b71..54469a5 100644
--- a/arch/tile/kernel/setup.c
+++ b/arch/tile/kernel/setup.c
@@ -329,6 +329,7 @@ static void __init setup_memory(void)
 #if defined(CONFIG_HIGHMEM) || defined(__tilegx__)
long lowmem_pages;
 #endif
+   unsigned long physpages = 0;
 
/* We are using a char to hold the cpu_2_node[] mapping */
BUILD_BUG_ON(MAX_NUMNODES > 127);
@@ -388,8 +389,8 @@ static void __init setup_memory(void)
continue;
}
}
-   if (num_physpages + PFN_DOWN(range.size) > maxmem_pfn) {
-   int max_size = maxmem_pfn - num_physpages;
+   if (physpages + PFN_DOWN(range.size) > maxmem_pfn) {
+   int max_size = maxmem_pfn - physpages;
if (max_size > 0) {
pr_err("Maxmem reduced node %d to %d pages\n",
   i, max_size);
@@ -446,7 +447,7 @@ static void __init setup_memory(void)
node_start_pfn[i] = start;
node_end_pfn[i] = end;
node_controller[i] = range.controller;
-   num_physpages += size;
+   physpages += size;
max_pfn = end;
 
/* Mark node as online */
@@ -465,7 +466,7 @@ static void __init setup_memory(void)
 * we're willing to use at 8 million pages (32GB of 4KB pages).
 */
cap = 8 * 1024 * 1024;  /* 8 million pages */
-   if (num_physpages > cap) {
+   if (physpages > cap) {
int num_nodes = num_online_nodes();
int cap_each = cap / num_nodes;
unsigned long dropped_pages = 0;
@@ -476,10 +477,10 @@ static void __init setup_memory(void)
node_end_pfn[i] = node_start_pfn[i] + cap_each;
}
}
-   num_physpages -= dropped_pages;
+   physpages -= dropped_pages;
pr_warning("Only using %ldMB memory;"
   " ignoring %ldMB.\n",
-  num_physpages >> (20 - PAGE_SHIFT),
+  physpages >> (20 - PAGE_SHIFT),
   dropped_pages >> (20 - PAGE_SHIFT));
pr_warning("Consider using a larger page size.\n");
}
@@ -497,7 +498,7 @@ static void __init setup_memory(void)
 
lowmem_pages = (mappable_physpages > MAXMEM_PFN) ?
MAXMEM_PFN : mappable_physpages;
-   highmem_pages = (long) (num_physpages - lowmem_pages);
+   highmem_pages = (long) (physpages - lowmem_pages);
 
pr_notice("%ldMB HIGHMEM available.\n",
   pages_to_mb(highmem_pages > 0 ? highmem_pages : 0));
@@ -514,7 +515,6 @@ static void __init setup_memory(void)
pr_warning("Use a HIGHMEM enabled kernel.\n");
max_low_pfn = MAXMEM_PFN;
max_pfn = MAXMEM_PFN;
-   num_physpages = MAXMEM_PFN;
node_end_pfn[0] = MAXMEM_PFN;
} else {
pr_notice("%ldMB memory available.\n",
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index f2ac2f4..e182958 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -821,7 +821,6 @@ static void __init set_max_mapnr_init(void)
 
 void __init mem_init(void)
 {
-   int codesize, datasize, initsize;
int i;
 #ifndef __tilegx__
void *last;
@@ -853,19 +852,7 @@ void __init mem_init(void)
set_non_bootmem_pages_init();
 #endif
 
-   codesize =  (unsigned long)&_etext - (unsigned long)&_text;
-   datasize =  (unsigned long)&_end - (unsigned long)&_sdata;
-   initsize =  (unsigned long)&_einittext - (unsigned long)&_sinittext;
-   initsize += (unsigned long)&_einitdata - (unsigned long)&_sinitdata;
-
-   pr_info("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk 
init, %ldk highmem)\n",
-   (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   datasize >> 10,
-   initsize >> 10,
-   (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
-  );
+   mem_init_print_info(NULL);
 
/*
 * In debug mode, dump some interesting memory mappings.
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please 

[RFC PATCH v2, part4 33/39] mm/um: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
---
 arch/um/kernel/mem.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index a7dc6c1..819008f 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -70,10 +70,8 @@ void __init mem_init(void)
 #ifdef CONFIG_HIGHMEM
setup_highmem(end_iomem, highmem);
 #endif
-   num_physpages = totalram_pages;
max_pfn = totalram_pages;
-   printk(KERN_INFO "Memory: %luk available\n",
-  nr_free_pages() << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
kmalloc_ok = 1;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 34/39] mm/um: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
---
 arch/um/kernel/mem.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index a7dc6c1..819008f 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -70,10 +70,8 @@ void __init mem_init(void)
 #ifdef CONFIG_HIGHMEM
setup_highmem(end_iomem, highmem);
 #endif
-   num_physpages = totalram_pages;
max_pfn = totalram_pages;
-   printk(KERN_INFO "Memory: %luk available\n",
-  nr_free_pages() << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
kmalloc_ok = 1;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 34/39] mm/unicore32: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Guan Xuetao 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: linux-kernel@vger.kernel.org
---
 arch/unicore32/mm/init.c |   49 ++
 1 file changed, 2 insertions(+), 47 deletions(-)

diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 119b9e8..39a967a 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -383,10 +383,6 @@ static void __init free_unused_memmap(struct meminfo *mi)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-   int i;
-
max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
free_unused_memmap(&meminfo);
@@ -394,48 +390,7 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
free_all_bootmem();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_bank(i, &meminfo) {
-   struct membank *bank = &meminfo.bank[i];
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = bank_pfn_start(bank);
-   pfn2 = bank_pfn_end(bank);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the
-* real number of pages we have in this system
-*/
-   printk(KERN_INFO "Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK 
highmem\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   free_pages << (PAGE_SHIFT-10),
-   reserved_pages << (PAGE_SHIFT-10),
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_NOTICE "Virtual kernel memory layout:\n"
"vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
"vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
@@ -464,7 +419,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE  > MODULES_VADDR);
BUG_ON(TASK_SIZE> MODULES_VADDR);
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
/*
 * On a machine this small we won't get
 * anywhere without overcommit, so turn
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] memcg: fix memcg_cache_name() to use cgroup_name()

2013-03-24 Thread Li Zefan
>> I read the code as lockdep_assert(memcg_cache_mutex), and then later on
>> mutex_lock(&memcg_mutex). But reading again, that was a just an
>> rcu_read_lock(). Good thing it is Friday
>>
>> You guys can add my Acked-by, and thanks again
> 
> Li, are you ok to take the page via your tree?
> 

I don't have a git tree in kernel.org. It's Tejun that picks up
cgroup patches.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 35/39] mm/unicore32: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Guan Xuetao 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: linux-kernel@vger.kernel.org
---
 arch/unicore32/mm/init.c |   49 ++
 1 file changed, 2 insertions(+), 47 deletions(-)

diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 119b9e8..39a967a 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -383,10 +383,6 @@ static void __init free_unused_memmap(struct meminfo *mi)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-   int i;
-
max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
free_unused_memmap(&meminfo);
@@ -394,48 +390,7 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
free_all_bootmem();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_bank(i, &meminfo) {
-   struct membank *bank = &meminfo.bank[i];
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = bank_pfn_start(bank);
-   pfn2 = bank_pfn_end(bank);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the
-* real number of pages we have in this system
-*/
-   printk(KERN_INFO "Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK 
highmem\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   free_pages << (PAGE_SHIFT-10),
-   reserved_pages << (PAGE_SHIFT-10),
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_NOTICE "Virtual kernel memory layout:\n"
"vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
"vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
@@ -464,7 +419,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE  > MODULES_VADDR);
BUG_ON(TASK_SIZE> MODULES_VADDR);
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
/*
 * On a machine this small we won't get
 * anywhere without overcommit, so turn
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 35/39] mm/x86: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Cc: x...@kernel.org
Cc: Andreas Herrmann 
Cc: Tang Chen 
Cc: Wen Congyang 
Cc: Jianguo Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/cpu/amd.c |2 +-
 arch/x86/kernel/setup.c   |2 --
 arch/x86/mm/init_32.c |   30 ++
 arch/x86/mm/init_64.c |   20 +---
 arch/x86/mm/numa_32.c |2 --
 5 files changed, 4 insertions(+), 52 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 15239ff..3465db2 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -91,7 +91,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
 static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
 {
u32 l, h;
-   int mbytes = num_physpages >> (20-PAGE_SHIFT);
+   int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
 
if (c->x86_model < 6) {
/* Based on AMD doc 20734R - June 2000 */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 342b1a7..5e5e26e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -934,8 +934,6 @@ void __init setup_arch(char **cmdline_p)
/* max_low_pfn get updated here */
find_low_pfn_range();
 #else
-   num_physpages = max_pfn;
-
check_x2apic();
 
/* How many end-of-memory variables you have, grandma! */
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 857032c..62e8920 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -634,10 +634,8 @@ void __init initmem_init(void)
highstart_pfn = max_low_pfn;
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
pages_to_mb(highend_pfn - highstart_pfn));
-   num_physpages = highend_pfn;
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
-   num_physpages = max_low_pfn;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
 
@@ -645,7 +643,7 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(0);
 
 #ifdef CONFIG_FLATMEM
-   max_mapnr = num_physpages;
+   max_mapnr = IS_ENABLED(CONFIG_HIGHMEM) ? highend_pfn : max_low_pfn;
 #endif
__vmalloc_start_set = true;
 
@@ -715,9 +713,6 @@ static void __init test_wp_bit(void)
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int tmp;
-
pci_iommu_alloc();
 
 #ifdef CONFIG_FLATMEM
@@ -737,28 +732,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages:
-*/
-   if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   initsize >> 10,
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_INFO "virtual kernel memory layout:\n"
"fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index f524138..a1c1db1 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1029,9 +1029,6 @@ static void __init register_page_bootmem_info(void)
 
 void __init mem_init(void)
 {
-   long codesize, reservedpages, datasize, initsize;
-   unsigned long absent_pages;
-
pci_iommu_alloc();
 
/* clear_bss() already clear the empty_zero_page */
@@ -1040,28 +1037,13 @@ void __init mem_init(void)
 
/* this will put all memory onto the freelists */
free_all_bootmem();
-
-   absent_pages = absent_pages_in_range(0, max_pfn);
-   reservedpages = max_pfn - totalram_pages - absent_pages;
after_bootmem = 1;
 
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
/* Register memory areas for /proc/kcore */
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
 VSYSCALL_END - VSYSCALL_START, K

[RFC PATCH v2, part4 36/39] mm/x86: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Cc: x...@kernel.org
Cc: Andreas Herrmann 
Cc: Tang Chen 
Cc: Wen Congyang 
Cc: Jianguo Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/cpu/amd.c |2 +-
 arch/x86/kernel/setup.c   |2 --
 arch/x86/mm/init_32.c |   30 ++
 arch/x86/mm/init_64.c |   20 +---
 arch/x86/mm/numa_32.c |2 --
 5 files changed, 4 insertions(+), 52 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 15239ff..3465db2 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -91,7 +91,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
 static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
 {
u32 l, h;
-   int mbytes = num_physpages >> (20-PAGE_SHIFT);
+   int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
 
if (c->x86_model < 6) {
/* Based on AMD doc 20734R - June 2000 */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 342b1a7..5e5e26e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -934,8 +934,6 @@ void __init setup_arch(char **cmdline_p)
/* max_low_pfn get updated here */
find_low_pfn_range();
 #else
-   num_physpages = max_pfn;
-
check_x2apic();
 
/* How many end-of-memory variables you have, grandma! */
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 857032c..62e8920 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -634,10 +634,8 @@ void __init initmem_init(void)
highstart_pfn = max_low_pfn;
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
pages_to_mb(highend_pfn - highstart_pfn));
-   num_physpages = highend_pfn;
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
-   num_physpages = max_low_pfn;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
 
@@ -645,7 +643,7 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(0);
 
 #ifdef CONFIG_FLATMEM
-   max_mapnr = num_physpages;
+   max_mapnr = IS_ENABLED(CONFIG_HIGHMEM) ? highend_pfn : max_low_pfn;
 #endif
__vmalloc_start_set = true;
 
@@ -715,9 +713,6 @@ static void __init test_wp_bit(void)
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int tmp;
-
pci_iommu_alloc();
 
 #ifdef CONFIG_FLATMEM
@@ -737,28 +732,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages:
-*/
-   if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   initsize >> 10,
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_INFO "virtual kernel memory layout:\n"
"fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index f524138..a1c1db1 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1029,9 +1029,6 @@ static void __init register_page_bootmem_info(void)
 
 void __init mem_init(void)
 {
-   long codesize, reservedpages, datasize, initsize;
-   unsigned long absent_pages;
-
pci_iommu_alloc();
 
/* clear_bss() already clear the empty_zero_page */
@@ -1040,28 +1037,13 @@ void __init mem_init(void)
 
/* this will put all memory onto the freelists */
free_all_bootmem();
-
-   absent_pages = absent_pages_in_range(0, max_pfn);
-   reservedpages = max_pfn - totalram_pages - absent_pages;
after_bootmem = 1;
 
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
/* Register memory areas for /proc/kcore */
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
 VSYSCALL_END - VSYSCALL_START, K

[RFC PATCH v2, part4 36/39] mm/xtensa: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chris Zankel 
Cc: Max Filippov 
Cc: Geert Uytterhoeven 
Cc: linux-xte...@linux-xtensa.org
Cc: linux-kernel@vger.kernel.org
---
 arch/xtensa/mm/init.c |   27 ++-
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index dc6e009..267428e 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -173,12 +173,8 @@ void __init zones_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long highmemsize, tmp, ram;
-
-   max_mapnr = num_physpages = max_low_pfn - ARCH_PFN_OFFSET;
+   max_mapnr = max_low_pfn - ARCH_PFN_OFFSET;
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
-   highmemsize = 0;
 
 #ifdef CONFIG_HIGHMEM
 #error HIGHGMEM not implemented in init.c
@@ -186,26 +182,7 @@ void __init mem_init(void)
 
free_all_bootmem();
 
-   reservedpages = ram = 0;
-   for (tmp = 0; tmp < max_mapnr; tmp++) {
-   ram++;
-   if (PageReserved(mem_map+tmp))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) _etext - (unsigned long) _stext;
-   datasize =  (unsigned long) _edata - (unsigned long) _sdata;
-   initsize =  (unsigned long) __init_end - (unsigned long) __init_begin;
-
-   printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, "
-  "%ldk data, %ldk init %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  ram << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10,
-  highmemsize >> 10);
+   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 37/39] mm: use totalram_pages instead of num_physpages at runtime

2013-03-24 Thread Jiang Liu
The global variable num_physpages is scheduled to be removed, so use
totalram_pages instead of num_physpages at runtime.

Signed-off-by: Jiang Liu 
Cc: Miklos Szeredi 
Cc: "David S. Miller" 
Cc: Alexey Kuznetsov 
Cc: James Morris 
Cc: Hideaki YOSHIFUJI 
Cc: Patrick McHardy 
Cc: fuse-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Cc: net...@vger.kernel.org
---
 fs/fuse/inode.c  |2 +-
 kernel/power/snapshot.c  |4 ++--
 net/ipv4/inet_fragment.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index b730fda..4c2a420 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -781,7 +781,7 @@ static const struct super_operations fuse_super_operations 
= {
 static void sanitize_global_limit(unsigned *limit)
 {
if (*limit == 0)
-   *limit = ((num_physpages << PAGE_SHIFT) >> 13) /
+   *limit = ((totalram_pages << PAGE_SHIFT) >> 13) /
 sizeof(struct fuse_req);
 
if (*limit >= 1 << 16)
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 0de2857..8b5d1cd 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1651,7 +1651,7 @@ unsigned long snapshot_get_image_size(void)
 static int init_header(struct swsusp_info *info)
 {
memset(info, 0, sizeof(struct swsusp_info));
-   info->num_physpages = num_physpages;
+   info->num_physpages = get_num_physpages();
info->image_pages = nr_copy_pages;
info->pages = snapshot_get_image_size();
info->size = info->pages;
@@ -1795,7 +1795,7 @@ static int check_header(struct swsusp_info *info)
char *reason;
 
reason = check_image_kernel(info);
-   if (!reason && info->num_physpages != num_physpages)
+   if (!reason && info->num_physpages != get_num_physpages())
reason = "memory size";
if (reason) {
printk(KERN_ERR "PM: Image mismatch: %s\n", reason);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 4750d2b..94a99a1 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -60,7 +60,7 @@ void inet_frags_init(struct inet_frags *f)
 
rwlock_init(&f->lock);
 
-   f->rnd = (u32) ((num_physpages ^ (num_physpages>>7)) ^
+   f->rnd = (u32) ((totalram_pages ^ (totalram_pages>>7)) ^
   (jiffies ^ (jiffies >> 6)));
 
setup_timer(&f->secret_timer, inet_frag_secret_rebuild,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 37/39] mm/xtensa: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chris Zankel 
Cc: Max Filippov 
Cc: Geert Uytterhoeven 
Cc: linux-xte...@linux-xtensa.org
Cc: linux-kernel@vger.kernel.org
---
 arch/xtensa/mm/init.c |   27 ++-
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index dc6e009..267428e 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -173,12 +173,8 @@ void __init zones_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long highmemsize, tmp, ram;
-
-   max_mapnr = num_physpages = max_low_pfn - ARCH_PFN_OFFSET;
+   max_mapnr = max_low_pfn - ARCH_PFN_OFFSET;
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
-   highmemsize = 0;
 
 #ifdef CONFIG_HIGHMEM
 #error HIGHGMEM not implemented in init.c
@@ -186,26 +182,7 @@ void __init mem_init(void)
 
free_all_bootmem();
 
-   reservedpages = ram = 0;
-   for (tmp = 0; tmp < max_mapnr; tmp++) {
-   ram++;
-   if (PageReserved(mem_map+tmp))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) _etext - (unsigned long) _stext;
-   datasize =  (unsigned long) _edata - (unsigned long) _sdata;
-   initsize =  (unsigned long) __init_end - (unsigned long) __init_begin;
-
-   printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, "
-  "%ldk data, %ldk init %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  ram << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10,
-  highmemsize >> 10);
+   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 38/39] mm/hotplug: prepare for removing num_physpages

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages.

Signed-off-by: Jiang Liu 
Cc: Wen Congyang 
Cc: Tang Chen 
Cc: Yasuaki Ishimatsu 
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 mm/memory_hotplug.c |4 
 1 file changed, 4 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 97454b3..9b1b494 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -751,10 +751,6 @@ EXPORT_SYMBOL_GPL(restore_online_page_callback);
 
 void __online_page_set_limits(struct page *page)
 {
-   unsigned long pfn = page_to_pfn(page);
-
-   if (pfn >= num_physpages)
-   num_physpages = pfn + 1;
 }
 EXPORT_SYMBOL_GPL(__online_page_set_limits);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 39/39] mm: kill global variable num_physpages

2013-03-24 Thread Jiang Liu
Now all references to num_physpages have been removed, so kill it.

Signed-off-by: Jiang Liu 
Cc: Mel Gorman 
Cc: Michel Lespinasse 
Cc: Rik van Riel 
Cc: Jiang Liu 
Cc: Hugh Dickins 
Cc: David Rientjes 
Cc: Al Viro 
Cc: Konstantin Khlebnikov 
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 include/linux/mm.h |1 -
 mm/memory.c|2 --
 mm/nommu.c |2 --
 3 files changed, 5 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c225a4f..a49afbf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -29,7 +29,6 @@ struct writeback_control;
 extern unsigned long max_mapnr;
 #endif
 
-extern unsigned long num_physpages;
 extern unsigned long totalram_pages;
 extern void * high_memory;
 extern int page_cluster;
diff --git a/mm/memory.c b/mm/memory.c
index 705473a..ecc771d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -82,7 +82,6 @@ EXPORT_SYMBOL(max_mapnr);
 EXPORT_SYMBOL(mem_map);
 #endif
 
-unsigned long num_physpages;
 /*
  * A number of key systems in x86 including ioremap() rely on the assumption
  * that high_memory defines the upper bound on direct map memory, then end
@@ -92,7 +91,6 @@ unsigned long num_physpages;
  */
 void * high_memory;
 
-EXPORT_SYMBOL(num_physpages);
 EXPORT_SYMBOL(high_memory);
 
 /*
diff --git a/mm/nommu.c b/mm/nommu.c
index 4eb25a8..ac23388 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -55,7 +55,6 @@
 void *high_memory;
 struct page *mem_map;
 unsigned long max_mapnr;
-unsigned long num_physpages;
 unsigned long highest_memmap_pfn;
 struct percpu_counter vm_committed_as;
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
@@ -82,7 +81,6 @@ unsigned long vm_memory_committed(void)
 EXPORT_SYMBOL_GPL(vm_memory_committed);
 
 EXPORT_SYMBOL(mem_map);
-EXPORT_SYMBOL(num_physpages);
 
 /* list of mapped, potentially shareable regions */
 static struct kmem_cache *vm_region_jar;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 30/39] mm/score: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chen Liqin 
Cc: Lennox Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/score/mm/init.c |   26 ++
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/score/mm/init.c b/arch/score/mm/init.c
index 579fc4e..2a223d8 100644
--- a/arch/score/mm/init.c
+++ b/arch/score/mm/init.c
@@ -77,33 +77,11 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long tmp, ram = 0;
-
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
free_all_bootmem();
setup_zero_page();  /* Setup zeroed pages. */
-   reservedpages = 0;
-
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   if (page_is_ram(tmp)) {
-   ram++;
-   if (PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-   }
-
-   num_physpages = ram;
-   codesize = (unsigned long) &_etext - (unsigned long) &_text;
-   datasize = (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
-   "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
-   (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
-   ram << (PAGE_SHIFT-10), codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10), datasize >> 10,
-   initsize >> 10,
-   totalhigh_pages << (PAGE_SHIFT-10));
+
+   mem_init_print_info(NULL);
 }
 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 21/39] mm/m68k: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Geert Uytterhoeven 
Cc: Greg Ungerer 
Cc: linux-m...@lists.linux-m68k.org
Cc: linux-kernel@vger.kernel.org
---
 arch/m68k/mm/init.c |   31 ++-
 1 file changed, 2 insertions(+), 29 deletions(-)

diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 0450989..f58fa43 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -149,33 +149,11 @@ void __init print_memmap(void)
 void __init mem_init(void)
 {
pg_data_t *pgdat;
-   int codepages = 0;
-   int datapages = 0;
-   int initpages = 0;
int i;
 
/* this will put all memory onto the freelists */
-   num_physpages = 0;
-   for_each_online_pgdat(pgdat) {
-   num_physpages += pgdat->node_present_pages;
-
+   for_each_online_pgdat(pgdat)
free_all_bootmem_node(pgdat);
-   for (i = 0; i < pgdat->node_spanned_pages; i++) {
-   struct page *page = pgdat->node_mem_map + i;
-   char *addr = page_to_virt(page);
-
-   if (!PageReserved(page))
-   continue;
-   if (addr >= _text &&
-   addr < _etext)
-   codepages++;
-   else if (addr >= __init_begin &&
-addr < __init_end)
-   initpages++;
-   else
-   datapages++;
-   }
-   }
 
 #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
/* insert pointer tables allocated so far into the tablelist */
@@ -190,12 +168,7 @@ void __init mem_init(void)
init_pointer_table((unsigned long)zero_pgtable);
 #endif
 
-   pr_info("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk 
init)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  totalram_pages << (PAGE_SHIFT-10),
-  codepages << (PAGE_SHIFT-10),
-  datapages << (PAGE_SHIFT-10),
-  initpages << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
print_memmap();
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 18/39] mm/hexagon: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Richard Kuo 
Cc: linux-hexa...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 arch/hexagon/mm/init.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index c048d06e..c0f0781 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -70,9 +70,8 @@ unsigned long long kmap_generation;
 void __init mem_init(void)
 {
free_all_bootmem();
-   num_physpages = bootmem_lastpg; /*  seriously, what?  */
 
-   printk(KERN_INFO "totalram_pages = %ld\n", totalram_pages);
+   mem_init_print_info(NULL);
 
/*
 *  To-Do:  someone somewhere should wipe out the bootmem map
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 34/39] mm/um: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Jeff Dike 
Cc: Richard Weinberger 
Cc: user-mode-linux-de...@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
---
 arch/um/kernel/mem.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index a7dc6c1..819008f 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -70,10 +70,8 @@ void __init mem_init(void)
 #ifdef CONFIG_HIGHMEM
setup_highmem(end_iomem, highmem);
 #endif
-   num_physpages = totalram_pages;
max_pfn = totalram_pages;
-   printk(KERN_INFO "Memory: %luk available\n",
-  nr_free_pages() << (PAGE_SHIFT-10));
+   mem_init_print_info(NULL);
kmalloc_ok = 1;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 35/39] mm/unicore32: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Guan Xuetao 
Cc: Michal Hocko 
Cc: David Rientjes 
Cc: linux-kernel@vger.kernel.org
---
 arch/unicore32/mm/init.c |   49 ++
 1 file changed, 2 insertions(+), 47 deletions(-)

diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 119b9e8..39a967a 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -383,10 +383,6 @@ static void __init free_unused_memmap(struct meminfo *mi)
  */
 void __init mem_init(void)
 {
-   unsigned long reserved_pages, free_pages;
-   struct memblock_region *reg;
-   int i;
-
max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
 
free_unused_memmap(&meminfo);
@@ -394,48 +390,7 @@ void __init mem_init(void)
/* this will put all unused low memory onto the freelists */
free_all_bootmem();
 
-   reserved_pages = free_pages = 0;
-
-   for_each_bank(i, &meminfo) {
-   struct membank *bank = &meminfo.bank[i];
-   unsigned int pfn1, pfn2;
-   struct page *page, *end;
-
-   pfn1 = bank_pfn_start(bank);
-   pfn2 = bank_pfn_end(bank);
-
-   page = pfn_to_page(pfn1);
-   end  = pfn_to_page(pfn2 - 1) + 1;
-
-   do {
-   if (PageReserved(page))
-   reserved_pages++;
-   else if (!page_count(page))
-   free_pages++;
-   page++;
-   } while (page < end);
-   }
-
-   /*
-* Since our memory may not be contiguous, calculate the
-* real number of pages we have in this system
-*/
-   printk(KERN_INFO "Memory:");
-   num_physpages = 0;
-   for_each_memblock(memory, reg) {
-   unsigned long pages = memblock_region_memory_end_pfn(reg) -
-   memblock_region_memory_base_pfn(reg);
-   num_physpages += pages;
-   printk(" %ldMB", pages >> (20 - PAGE_SHIFT));
-   }
-   printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
-
-   printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK 
highmem\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   free_pages << (PAGE_SHIFT-10),
-   reserved_pages << (PAGE_SHIFT-10),
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_NOTICE "Virtual kernel memory layout:\n"
"vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
"vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
@@ -464,7 +419,7 @@ void __init mem_init(void)
BUILD_BUG_ON(TASK_SIZE  > MODULES_VADDR);
BUG_ON(TASK_SIZE> MODULES_VADDR);
 
-   if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
+   if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
/*
 * On a machine this small we won't get
 * anywhere without overcommit, so turn
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 36/39] mm/x86: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: "H. Peter Anvin" 
Cc: x...@kernel.org
Cc: Andreas Herrmann 
Cc: Tang Chen 
Cc: Wen Congyang 
Cc: Jianguo Wu 
Cc: linux-kernel@vger.kernel.org
---
 arch/x86/kernel/cpu/amd.c |2 +-
 arch/x86/kernel/setup.c   |2 --
 arch/x86/mm/init_32.c |   30 ++
 arch/x86/mm/init_64.c |   20 +---
 arch/x86/mm/numa_32.c |2 --
 5 files changed, 4 insertions(+), 52 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 15239ff..3465db2 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -91,7 +91,7 @@ static void __cpuinit init_amd_k5(struct cpuinfo_x86 *c)
 static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
 {
u32 l, h;
-   int mbytes = num_physpages >> (20-PAGE_SHIFT);
+   int mbytes = get_num_physpages() >> (20-PAGE_SHIFT);
 
if (c->x86_model < 6) {
/* Based on AMD doc 20734R - June 2000 */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 342b1a7..5e5e26e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -934,8 +934,6 @@ void __init setup_arch(char **cmdline_p)
/* max_low_pfn get updated here */
find_low_pfn_range();
 #else
-   num_physpages = max_pfn;
-
check_x2apic();
 
/* How many end-of-memory variables you have, grandma! */
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 857032c..62e8920 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -634,10 +634,8 @@ void __init initmem_init(void)
highstart_pfn = max_low_pfn;
printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
pages_to_mb(highend_pfn - highstart_pfn));
-   num_physpages = highend_pfn;
high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
-   num_physpages = max_low_pfn;
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
 
@@ -645,7 +643,7 @@ void __init initmem_init(void)
sparse_memory_present_with_active_regions(0);
 
 #ifdef CONFIG_FLATMEM
-   max_mapnr = num_physpages;
+   max_mapnr = IS_ENABLED(CONFIG_HIGHMEM) ? highend_pfn : max_low_pfn;
 #endif
__vmalloc_start_set = true;
 
@@ -715,9 +713,6 @@ static void __init test_wp_bit(void)
 
 void __init mem_init(void)
 {
-   int codesize, reservedpages, datasize, initsize;
-   int tmp;
-
pci_iommu_alloc();
 
 #ifdef CONFIG_FLATMEM
@@ -737,28 +732,7 @@ void __init mem_init(void)
/* this will put all low memory onto the freelists */
free_all_bootmem();
 
-   reservedpages = 0;
-   for (tmp = 0; tmp < max_low_pfn; tmp++)
-   /*
-* Only count reserved RAM pages:
-*/
-   if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
-   reservedpages++;
-
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
-   printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
-   "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
-   nr_free_pages() << (PAGE_SHIFT-10),
-   num_physpages << (PAGE_SHIFT-10),
-   codesize >> 10,
-   reservedpages << (PAGE_SHIFT-10),
-   datasize >> 10,
-   initsize >> 10,
-   totalhigh_pages << (PAGE_SHIFT-10));
-
+   mem_init_print_info(NULL);
printk(KERN_INFO "virtual kernel memory layout:\n"
"fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 #ifdef CONFIG_HIGHMEM
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index f524138..a1c1db1 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1029,9 +1029,6 @@ static void __init register_page_bootmem_info(void)
 
 void __init mem_init(void)
 {
-   long codesize, reservedpages, datasize, initsize;
-   unsigned long absent_pages;
-
pci_iommu_alloc();
 
/* clear_bss() already clear the empty_zero_page */
@@ -1040,28 +1037,13 @@ void __init mem_init(void)
 
/* this will put all memory onto the freelists */
free_all_bootmem();
-
-   absent_pages = absent_pages_in_range(0, max_pfn);
-   reservedpages = max_pfn - totalram_pages - absent_pages;
after_bootmem = 1;
 
-   codesize =  (unsigned long) &_etext - (unsigned long) &_text;
-   datasize =  (unsigned long) &_edata - (unsigned long) &_etext;
-   initsize =  (unsigned long) &__init_end - (unsigned long) &__init_begin;
-
/* Register memory areas for /proc/kcore */
kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
 VSYSCALL_END - VSYSCALL_START, K

[RFC PATCH v2, part4 37/39] mm/xtensa: prepare for removing num_physpages and simplify mem_init()

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages and simplify mem_init().

Signed-off-by: Jiang Liu 
Cc: Chris Zankel 
Cc: Max Filippov 
Cc: Geert Uytterhoeven 
Cc: linux-xte...@linux-xtensa.org
Cc: linux-kernel@vger.kernel.org
---
 arch/xtensa/mm/init.c |   27 ++-
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index dc6e009..267428e 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -173,12 +173,8 @@ void __init zones_init(void)
 
 void __init mem_init(void)
 {
-   unsigned long codesize, reservedpages, datasize, initsize;
-   unsigned long highmemsize, tmp, ram;
-
-   max_mapnr = num_physpages = max_low_pfn - ARCH_PFN_OFFSET;
+   max_mapnr = max_low_pfn - ARCH_PFN_OFFSET;
high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
-   highmemsize = 0;
 
 #ifdef CONFIG_HIGHMEM
 #error HIGHGMEM not implemented in init.c
@@ -186,26 +182,7 @@ void __init mem_init(void)
 
free_all_bootmem();
 
-   reservedpages = ram = 0;
-   for (tmp = 0; tmp < max_mapnr; tmp++) {
-   ram++;
-   if (PageReserved(mem_map+tmp))
-   reservedpages++;
-   }
-
-   codesize =  (unsigned long) _etext - (unsigned long) _stext;
-   datasize =  (unsigned long) _edata - (unsigned long) _sdata;
-   initsize =  (unsigned long) __init_end - (unsigned long) __init_begin;
-
-   printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, "
-  "%ldk data, %ldk init %ldk highmem)\n",
-  nr_free_pages() << (PAGE_SHIFT-10),
-  ram << (PAGE_SHIFT-10),
-  codesize >> 10,
-  reservedpages << (PAGE_SHIFT-10),
-  datasize >> 10,
-  initsize >> 10,
-  highmemsize >> 10);
+   mem_init_print_info(NULL);
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 38/39] mm/hotplug: prepare for removing num_physpages

2013-03-24 Thread Jiang Liu
Prepare for removing num_physpages.

Signed-off-by: Jiang Liu 
Cc: Wen Congyang 
Cc: Tang Chen 
Cc: Yasuaki Ishimatsu 
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 mm/memory_hotplug.c |4 
 1 file changed, 4 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 97454b3..9b1b494 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -751,10 +751,6 @@ EXPORT_SYMBOL_GPL(restore_online_page_callback);
 
 void __online_page_set_limits(struct page *page)
 {
-   unsigned long pfn = page_to_pfn(page);
-
-   if (pfn >= num_physpages)
-   num_physpages = pfn + 1;
 }
 EXPORT_SYMBOL_GPL(__online_page_set_limits);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 39/39] mm: kill global variable num_physpages

2013-03-24 Thread Jiang Liu
Now all references to num_physpages have been removed, so kill it.

Signed-off-by: Jiang Liu 
Cc: Mel Gorman 
Cc: Michel Lespinasse 
Cc: Rik van Riel 
Cc: Jiang Liu 
Cc: Hugh Dickins 
Cc: David Rientjes 
Cc: Al Viro 
Cc: Konstantin Khlebnikov 
Cc: linux...@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 include/linux/mm.h |1 -
 mm/memory.c|2 --
 mm/nommu.c |2 --
 3 files changed, 5 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index c225a4f..a49afbf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -29,7 +29,6 @@ struct writeback_control;
 extern unsigned long max_mapnr;
 #endif
 
-extern unsigned long num_physpages;
 extern unsigned long totalram_pages;
 extern void * high_memory;
 extern int page_cluster;
diff --git a/mm/memory.c b/mm/memory.c
index 705473a..ecc771d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -82,7 +82,6 @@ EXPORT_SYMBOL(max_mapnr);
 EXPORT_SYMBOL(mem_map);
 #endif
 
-unsigned long num_physpages;
 /*
  * A number of key systems in x86 including ioremap() rely on the assumption
  * that high_memory defines the upper bound on direct map memory, then end
@@ -92,7 +91,6 @@ unsigned long num_physpages;
  */
 void * high_memory;
 
-EXPORT_SYMBOL(num_physpages);
 EXPORT_SYMBOL(high_memory);
 
 /*
diff --git a/mm/nommu.c b/mm/nommu.c
index 4eb25a8..ac23388 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -55,7 +55,6 @@
 void *high_memory;
 struct page *mem_map;
 unsigned long max_mapnr;
-unsigned long num_physpages;
 unsigned long highest_memmap_pfn;
 struct percpu_counter vm_committed_as;
 int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
@@ -82,7 +81,6 @@ unsigned long vm_memory_committed(void)
 EXPORT_SYMBOL_GPL(vm_memory_committed);
 
 EXPORT_SYMBOL(mem_map);
-EXPORT_SYMBOL(num_physpages);
 
 /* list of mapped, potentially shareable regions */
 static struct kmem_cache *vm_region_jar;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch] mm: speedup in __early_pfn_to_nid

2013-03-24 Thread Ingo Molnar

* Russ Anderson  wrote:

> --- linux.orig/mm/page_alloc.c2013-03-19 16:09:03.736450861 -0500
> +++ linux/mm/page_alloc.c 2013-03-22 17:07:43.895405617 -0500
> @@ -4161,10 +4161,23 @@ int __meminit __early_pfn_to_nid(unsigne
>  {
>   unsigned long start_pfn, end_pfn;
>   int i, nid;
> + /*
> +NOTE: The following SMP-unsafe globals are only used early
> +in boot when the kernel is running single-threaded.
> +  */
> + static unsigned long last_start_pfn, last_end_pfn;
> + static int last_nid;

I guess I'm the nitpicker of the week:

please use the customary (multi-line) comment style:

  /*
   * Comment .
   * .. goes here.
   */

specified in Documentation/CodingStyle.

Thanks,

Ingo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 01/39] vmlinux.lds: add comments for global variables and clean up useless declarations

2013-03-24 Thread Jiang Liu
This patch documents global variables exported from vmlinux.lds.
1) Add comments about usage guidelines for global variables exported
   from vmlinux.lds.S.
2) Remove unused __initdata_begin[] and __initdata_end[].

Signed-off-by: Jiang Liu 
Cc: Arnd Bergmann 
Cc: linux-a...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 include/asm-generic/sections.h |   21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index c1a1216..f1a24b5 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -3,6 +3,26 @@
 
 /* References to section boundaries */
 
+/*
+ * Usage guidelines:
+ * _text, _data: architecture specific, don't use them in arch-independent code
+ * [_stext, _etext]: contains .text.* sections, may also contain .rodata.*
+ *   and/or .init.* sections
+ * [_sdata, _edata]: contains .data.* sections, may also contain .rodata.*
+ *   and/or .init.* sections.
+ * [__start_rodata, __end_rodata]: contains .rodata.* sections
+ * [__init_begin, __init_end]: contains .init.* sections, but .init.text.*
+ *   may be out of this range on some architectures.
+ * [_sinittext, _einittext]: contains .init.text.* sections
+ * [__bss_start, __bss_stop]: contains BSS sections
+ *
+ * Following global variables are optional and may be unavailable on some
+ * architectures and/or kernel configurations.
+ * _text, _data
+ * __kprobes_text_start, __kprobes_text_end
+ * __entry_text_start, __entry_text_end
+ * __ctors_start, __ctors_end
+ */
 extern char _text[], _stext[], _etext[];
 extern char _data[], _sdata[], _edata[];
 extern char __bss_start[], __bss_stop[];
@@ -12,7 +32,6 @@ extern char _end[];
 extern char __per_cpu_load[], __per_cpu_start[], __per_cpu_end[];
 extern char __kprobes_text_start[], __kprobes_text_end[];
 extern char __entry_text_start[], __entry_text_end[];
-extern char __initdata_begin[], __initdata_end[];
 extern char __start_rodata[], __end_rodata[];
 
 /* Start and end of .ctors section - used for constructor calls. */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 02/39] avr32: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Normalize global variables exported by vmlinux.lds to conform usage
guidelines from include/asm-generic/sections.h.

Use _text to mark the start of the kernel image including the head text,
and _stext to mark the start of the .text section.

Signed-off-by: Jiang Liu 
Cc: Haavard Skinnemoen 
Cc: Hans-Christian Egtvedt 
Cc: linux-kernel@vger.kernel.org
---
 arch/avr32/kernel/setup.c   |2 +-
 arch/avr32/kernel/vmlinux.lds.S |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/avr32/kernel/setup.c b/arch/avr32/kernel/setup.c
index b4247f4..209ae5a 100644
--- a/arch/avr32/kernel/setup.c
+++ b/arch/avr32/kernel/setup.c
@@ -555,7 +555,7 @@ void __init setup_arch (char **cmdline_p)
 {
struct clk *cpu_clk;
 
-   init_mm.start_code = (unsigned long)_text;
+   init_mm.start_code = (unsigned long)_stext;
init_mm.end_code = (unsigned long)_etext;
init_mm.end_data = (unsigned long)_edata;
init_mm.brk = (unsigned long)_end;
diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
index 9cd2bd9..a458917 100644
--- a/arch/avr32/kernel/vmlinux.lds.S
+++ b/arch/avr32/kernel/vmlinux.lds.S
@@ -23,7 +23,7 @@ SECTIONS
 {
. = CONFIG_ENTRY_ADDRESS;
.init   : AT(ADDR(.init) - LOAD_OFFSET) {
-   _stext = .;
+   _text = .;
__init_begin = .;
_sinittext = .;
*(.text.reset)
@@ -46,7 +46,7 @@ SECTIONS
 
.text   : AT(ADDR(.text) - LOAD_OFFSET) {
_evba = .;
-   _text = .;
+   _stext = .;
*(.ex.text)
*(.irq.text)
KPROBES_TEXT
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH v2, part4 04/39] h8300: normalize global variables exported by vmlinux.lds

2013-03-24 Thread Jiang Liu
Generate mandatory global variables __bss_start/__bss_stop in
file vmlinux.lds.

Also remove one unused declaration of _text.

Signed-off-by: Jiang Liu 
Cc: Yoshinori Sato 
Cc: Jiang Liu 
Cc: linux-kernel@vger.kernel.org
---
 arch/h8300/boot/compressed/misc.c |1 -
 arch/h8300/kernel/vmlinux.lds.S   |2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/h8300/boot/compressed/misc.c 
b/arch/h8300/boot/compressed/misc.c
index 51ab6cb..4a1e3dd 100644
--- a/arch/h8300/boot/compressed/misc.c
+++ b/arch/h8300/boot/compressed/misc.c
@@ -79,7 +79,6 @@ static void error(char *m);
 
 int puts(const char *);
 
-extern int _text;  /* Defined in vmlinux.lds.S */
 extern int _end;
 static unsigned long free_mem_ptr;
 static unsigned long free_mem_end_ptr;
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 03d356d..3253fed 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -132,10 +132,12 @@ SECTIONS
 {
. = ALIGN(0x4) ;
__sbss = . ;
+   ___bss_start = . ;
*(.bss*)
. = ALIGN(0x4) ;
*(COMMON)
. = ALIGN(0x4) ;
+   ___bss_stop = . ;
__ebss = . ;
__end = . ;
__ramstart = .;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v2] bnx2x: fix assignment of signed expression to unsigned variable

2013-03-24 Thread Dmitry Kravkov
> -Original Message-
> From: netdev-ow...@vger.kernel.org [mailto:netdev-ow...@vger.kernel.org] On 
> Behalf Of Kumar Amit Mehta
> Sent: Sunday, March 24, 2013 8:10 AM
> To: Eilon Greenstein
> Cc: da...@davemloft.net; dan.carpen...@oracle.com; net...@vger.kernel.org; 
> linux-kernel@vger.kernel.org; kernel-
> janit...@vger.kernel.org
> Subject: [PATCH v2] bnx2x: fix assignment of signed expression to unsigned 
> variable
> 
> fix for incorrect assignment of signed expression to unsigned variable.
> 
> Signed-off-by: Kumar Amit Mehta 
> ---
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c |   18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c 
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
> index 5682054..91ecd6a 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
> @@ -2139,12 +2139,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device 
> *netdev, int capid, u8 *cap)
>   break;
>   default:
>   BNX2X_ERR("Non valid capability ID\n");
> - rval = -EINVAL;
> + rval = 1;
>   break;
>   }
>   } else {
>   DP(BNX2X_MSG_DCB, "DCB disabled\n");
> - rval = -EINVAL;
> + rval = 1;
>   }
> 
>   DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
> @@ -2170,12 +2170,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device 
> *netdev, int tcid, u8 *num)
>   break;
>   default:
>   BNX2X_ERR("Non valid TC-ID\n");
> - rval = -EINVAL;
> + rval = 1;
>   break;
>   }
>   } else {
>   DP(BNX2X_MSG_DCB, "DCB disabled\n");
> - rval = -EINVAL;
> + rval = 1;
>   }
> 
>   return rval;
> @@ -2188,7 +2188,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device 
> *netdev, int tcid, u8 num)
>   return -EINVAL;
>  }
> 
> -static u8  bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
> +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
>  {
>   struct bnx2x *bp = netdev_priv(netdev);
>   DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
> @@ -2390,12 +2390,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device 
> *netdev, int featid,
>   break;
>   default:
>   BNX2X_ERR("Non valid featrue-ID\n");
> - rval = -EINVAL;
> + rval = 1;
>   break;
>   }
>   } else {
>   DP(BNX2X_MSG_DCB, "DCB disabled\n");
> - rval = -EINVAL;
> + rval = 1;
>   }
> 
>   return rval;
> @@ -2431,12 +2431,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device 
> *netdev, int featid,
>   break;
>   default:
>   BNX2X_ERR("Non valid featrue-ID\n");
> - rval = -EINVAL;
> + rval = 1;
>   break;
>   }
>   } else {
>   DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
> - rval = -EINVAL;
> + rval = 1;
>   }
> 
>   return rval;
> --
> 1.7.9.5

Kumar,  thanks!

Acked-by: Dmitry Kravkov 



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] Feature: Support ALPS v6.

2013-03-24 Thread Valyushkov Ivan
Tested on Dell 7720. Works fine.

Signed-off-by: Valyushkov Ivan 
---
 drivers/input/mouse/alps.c |  464 +---
 drivers/input/mouse/alps.h |2 +
 2 files changed, 443 insertions(+), 23 deletions(-)

diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index e229fa3..38361bc 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -15,6 +15,8 @@
  * the Free Software Foundation.
  */
 
+#define DEBUG
+
 #include 
 #include 
 #include 
@@ -30,9 +32,6 @@
 #define ALPS_V3_X_MAX  2000
 #define ALPS_V3_Y_MAX  1400
 
-#define ALPS_BITMAP_X_BITS 15
-#define ALPS_BITMAP_Y_BITS 11
-
 #define ALPS_CMD_NIBBLE_10 0x01f2
 
 static const struct alps_nibble_commands alps_v3_nibble_commands[] = {
@@ -84,6 +83,12 @@ static const struct alps_nibble_commands 
alps_v4_nibble_commands[] = {
 #define ALPS_PS2_INTERLEAVED   0x80/* 3-byte PS/2 packet interleaved with
   6-byte ALPS packet */
 
+/* Set these based upon protocol version */
+static int ALPS_X_MAX;   /* right edge */
+static int ALPS_Y_MAX;   /* bottom edge */
+static int ALPS_BITMAP_X_BITS; /* mt number of x bits */
+static int ALPS_BITMAP_Y_BITS; /* mt number of y bits */
+
 static const struct alps_model_info alps_model_data[] = {
{ { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | 
ALPS_DUALPOINT },  /* Toshiba Salellite Pro M10 */
{ { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 },   
/* UMAX-530T */
@@ -112,6 +117,9 @@ static const struct alps_model_info alps_model_data[] = {
{ { 0x73, 0x02, 0x64 }, 0x9b, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT 
},
{ { 0x73, 0x02, 0x64 }, 0x9d, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT 
},
{ { 0x73, 0x02, 0x64 }, 0x8a, ALPS_PROTO_V4, 0x8f, 0x8f, 0 },
+   { { 0x73, 0x03, 0x0a }, 0x1d, ALPS_PROTO_V5, 0x8f, 0x8f, ALPS_DUALPOINT 
},  /* Dell Latitude E6430 */
+   { { 0x73, 0x03, 0x50 }, 0x0d, ALPS_PROTO_V6, 0xc8, 0xc8, 0 }, /* Dell 
Inspiron N5110 */
+   { { 0x73, 0x03, 0x50 }, 0x02, ALPS_PROTO_V6, 0xc8, 0xc8, 0 } /* Dell 
Inspiron 17R 7720 */
 };
 
 /*
@@ -355,9 +363,9 @@ static int alps_process_bitmap(unsigned int x_map, unsigned 
int y_map,
}
}
 
-   *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) /
+   *x1 = (ALPS_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) /
  (2 * (ALPS_BITMAP_X_BITS - 1));
-   *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) /
+   *y1 = (ALPS_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) /
  (2 * (ALPS_BITMAP_Y_BITS - 1));
 
if (fingers > 1) {
@@ -388,7 +396,7 @@ static void alps_report_semi_mt_data(struct input_dev *dev, 
int num_fingers,
alps_set_slot(dev, 1, num_fingers == 2, x2, y2);
 }
 
-static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
+static void alps_process_trackstick_packet_v3_v5(struct psmouse *psmouse)
 {
struct alps_data *priv = psmouse->private;
unsigned char *packet = psmouse->packet;
@@ -448,7 +456,7 @@ static void alps_process_trackstick_packet_v3(struct 
psmouse *psmouse)
return;
 }
 
-static void alps_process_touchpad_packet_v3(struct psmouse *psmouse)
+static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
 {
struct alps_data *priv = psmouse->private;
unsigned char *packet = psmouse->packet;
@@ -579,7 +587,7 @@ static void alps_process_touchpad_packet_v3(struct psmouse 
*psmouse)
}
 }
 
-static void alps_process_packet_v3(struct psmouse *psmouse)
+static void alps_process_packet_v3_v5(struct psmouse *psmouse)
 {
unsigned char *packet = psmouse->packet;
 
@@ -592,11 +600,11 @@ static void alps_process_packet_v3(struct psmouse 
*psmouse)
 * of packets.
 */
if (packet[5] == 0x3f) {
-   alps_process_trackstick_packet_v3(psmouse);
+   alps_process_trackstick_packet_v3_v5(psmouse);
return;
}
 
-   alps_process_touchpad_packet_v3(psmouse);
+   alps_process_touchpad_packet_v3_v5(psmouse);
 }
 
 static void alps_process_packet_v4(struct psmouse *psmouse)
@@ -696,6 +704,91 @@ static void alps_process_packet_v4(struct psmouse *psmouse)
input_sync(dev);
 }
 
+/* This is similar logic to alps_process_touchpad_packet_v3_v5.   The
+   bitfield positions are different.
+*/
+static void alps_process_packet_v6(struct psmouse *psmouse)
+{
+   struct alps_data *priv = psmouse->private;
+   unsigned char *packet = psmouse->packet;
+   struct input_dev *dev = psmouse->dev;
+   int x, y, z;
+   int left, right, middle;
+   int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+   int fingers = 0;
+   unsigned long int x_bitmap, y_bitmap;
+
+   /* multitouch packet */
+   if (priv->multi_packet) {
+   if (packet[0] & 0x20) {
+   

Re: [RFC PATCH v2, part4 00/39] Simplify mem_init() implementations and kill num_physpages

2013-03-24 Thread James Bottomley
On Sun, 2013-03-24 at 15:24 +0800, Jiang Liu wrote:
> The original goal of this patchset is to fix the bug reported by
> https://bugzilla.kernel.org/show_bug.cgi?id=53501
> Now it has also been expanded to reduce common code used by memory
> initializion.
> 
> This is the last part, previous three patch sets could be accessed at:
> http://marc.info/?l=linux-mm&m=136289696323825&w=2
> http://marc.info/?l=linux-mm&m=136290291524901&w=2
> http://marc.info/?l=linux-mm&m=136345342831592&w=2
> 
> This patchset applies to
> https://git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git since-3.8

You're going to have to have a git tree for this if you want this series
testing on other architectures.  Plus cc'ing linux-arch would be a good
idea for that case.  The patch series seems to be screwed up in the
numbering:  The parisc patches 26/39 and 27/39 are identical.

James





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [GIT PULL] nohz: Full dynticks base interface

2013-03-24 Thread Ingo Molnar

* Frederic Weisbecker  wrote:

> Hi Ingo,
> 
> This settles the initial ground to start a special full dynticks tree in -tip
> that we can iterate incrementally to accelerate the development.
> It is based on tip:sched/core.
> 
> I tried to rearrange a bit the naming. We are probably not yet done with
> that but I guess we can fix it along with the rest.
> 
> Please pull from:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
>   full-dynticks-for-mingo
> 
> Changes on these commits since they were part of 3.9-rc1-nohz1:
> 
> * Force a timekeeping CPU over the full dynticks range
> * Rename CONFIG_NO_HZ_FULL to CONFIG_NO_HZ_EXTENDED
> * Following *_nohz_extended_* APIs renames
> * Handle CPU hotplug for timekeeping
> * Rename full_nohz= kernel parameter to nohz_extended=

Note that boot parameters suck for pretty much any purpose but quirks - 
please also add a (default off!) Kconfig option to easily enable 
nohz_extended for all CPUs.

That way I will be able to test it automatically via randconfig and such.

My next question/request after that would be: could we make sure that 
enabling this option does not break any applications or kernel 
functionality, ASAP? Once that is offered, it becomes pushable to v3.10 I 
think.

Meanwhile I have pulled your tree into tip:sched/nohz to stage and test 
it, in the hope that it becomes mergable quickly! :-)

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [-next] fs/eventpoll.c:545 suspicious rcu_dereference_check() usage

2013-03-24 Thread Sergey Senozhatsky
On (03/23/13 17:34), Eric Wong wrote:
> Sergey Senozhatsky  wrote:
> > [3.163894] ===
> > [3.163895] [ INFO: suspicious RCU usage. ]
> > [3.163897] 3.9.0-rc3-next-20130322-dbg-dirty #1 Not tainted
> > [3.163898] ---
> > [3.163900] fs/eventpoll.c:545 suspicious rcu_dereference_check() usage!
> 
> Sorry about this, I've fixed this and it is in the latest -mm
> 
> http://mid.gmane.org/20130321192748.6d86f31c...@corp2gmr1-1.hot.corp.google.com
> 

thanks a lot.

-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] pinctrl fixes for v3.9

2013-03-24 Thread Linus Walleij
Hi Linus,

here are some assorted pinctrl fixes for the v3.9 rc series.
Just bug fixes, basically.

Please pull them in, detailed info in the tag.

Yours,
Linus Walleij


The following changes since commit 6dbe51c251a327e012439c4772097a13df43c5b8:

  Linux 3.9-rc1 (2013-03-03 15:11:05 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
tags/pinctrl-fixes-for-v3.9

for you to fetch changes up to 740924a267e85de09707ea158bbf594b4d8bae01:

  pinmux: forbid mux_usecount to be set at UINT_MAX (2013-03-21 19:26:18 +0100)


Here are a few pinctrl fixes for the v3.9 rc series:
- Usecount bounds checking so we do not go below zero on
  mux usecounts.
- Loop range checking in GPIO ranges in the DT range parser.
- Proper print in debugfs for pinconf state.
- Fix compilation bug in generic pinconf code.
- Minor bugfixes to abx500 and mvebu drivers.


Axel Lin (1):
  pinctrl: abx500: Fix checking if pin use AlternateFunction register

Haojian Zhuang (1):
  gpio: fix wrong checking condition for gpio range

Laurent Pinchart (1):
  pinctrl: Print the correct information in debugfs pinconf-state file

Richard Genoud (1):
  pinmux: forbid mux_usecount to be set at UINT_MAX

Sachin Kamat (1):
  pinctrl: generic: Fix compilation error

Simon Guinot (1):
  pinctrl: mvebu: fix checking for SoC specific controls

 drivers/gpio/gpiolib-of.c | 5 ++---
 drivers/pinctrl/mvebu/pinctrl-mvebu.c | 2 +-
 drivers/pinctrl/pinconf.c | 2 +-
 drivers/pinctrl/pinconf.h | 2 +-
 drivers/pinctrl/pinctrl-abx500.c  | 2 +-
 drivers/pinctrl/pinmux.c  | 5 +
 6 files changed, 11 insertions(+), 7 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: Add support for handling queueing in hardware

2013-03-24 Thread Guenter Roeck
On Fri, Mar 22, 2013 at 10:43:44AM -0400, Ben Collins wrote:
> On Mar 22, 2013, at 10:33 AM, David Miller  wrote:
> 
> > From: Fleming Andy-AFLEMING 
> > Date: Fri, 22 Mar 2013 14:31:50 +
> > 
> >> It would appear one of our customers is attempting to upstream our
> >> code for us. We are aware that this current solution is unacceptable
> >> (which is why we have not submitted it), and we are currently trying
> >> to develop a less hacky solution that integrates with qdisc.
> > 
> > Ben, can can you coordinate with people instead of doing crap like
> > this?
> 
> 
> "For us" is a loose term, when it's more that we are attempting to upstream 
> code so our system is supported by a mainline kernel instead of having 
> one-off kernels.
> 
> And we have been talking with Freescale about this for quite some time 
> (couple years?). They have a roadmap that doesn't include getting this driver 
> supported in mainline any time soon, so I'm taking time to get this done for 
> our own system. I'm not meaning to step on any toes.
> 
How true. You are not the only one with thatt problem.

Ben, can you possibly send me your complete patch set on top of 3.8, or point me
to a git tree ?

I have exactly the same problem, I need the code in 3.8, it doesn't seem
like the Freescale code will show up anytime soon, and I don't seem to be able
to get early code for testing either. I can promise you a free test coverage
and bug fixing ...

Thanks,
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v10 04/12] watchdog: add Palmas Watchdog support

2013-03-24 Thread Guenter Roeck
On Fri, Mar 22, 2013 at 02:55:14PM +, Ian Lartey wrote:
> From: Graeme Gregory 
> 
> Add support for the Palmas watchdog timer which has a timeout configurable
> from 1s to 128s.
> 
> Signed-off-by: Graeme Gregory 
> Signed-off-by: Ian Lartey 
> ---
>  drivers/watchdog/palmas_wdt.c |  169 
> +
>  1 files changed, 169 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/watchdog/palmas_wdt.c
> 
> diff --git a/drivers/watchdog/palmas_wdt.c b/drivers/watchdog/palmas_wdt.c
> new file mode 100644
> index 000..da7e379
> --- /dev/null
> +++ b/drivers/watchdog/palmas_wdt.c
> @@ -0,0 +1,169 @@
> +/*
> + * Driver for Watchdog part of Palmas PMIC Chips
> + *
> + * Copyright 2011-2013 Texas Instruments Inc.
> + *
> + * Author: Graeme Gregory 
> + * Author: Ian Lartey 
> + *
> + * Based on twl4030_wdt.c
> + *
> + * Author: Timo Kokkonen 
> + *
> + *  This program is free software; you can redistribute it and/or modify it
> + *  under  the terms of the GNU General  Public License as published by the
> + *  Free Software Foundation;  either version 2 of the License, or (at your
> + *  option) any later version.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct palmas_wdt {
> + struct palmas *palmas;
> + struct watchdog_device wdt;
> + struct device *dev;
> +
> + int timer_margin;
> +};
> +
> +
One empty line would be sufficient.

> +static int nowayout = WATCHDOG_NOWAYOUT;
> +module_param(nowayout, int, 0);
> +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
> + "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
> +
> +static int palmas_wdt_write(struct palmas *palmas, unsigned int data)
> +{
> + unsigned int addr;
> +
> + addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_WATCHDOG);
> +
> + return palmas_write(palmas, PALMAS_PMU_CONTROL_BASE, addr, addr);

2 x addr ? Should the second one (last parameter) be data ?

> +}
> +
> +static int palmas_wdt_enable(struct watchdog_device *wdt)
> +{
> + struct palmas_wdt *driver_data = watchdog_get_drvdata(wdt);
> + struct palmas *palmas = driver_data->palmas;
> +
> + return palmas_wdt_write(palmas, driver_data->timer_margin |
> + PALMAS_WATCHDOG_ENABLE);
> +}
> +
> +static int palmas_wdt_disable(struct watchdog_device *wdt)
> +{
> + struct palmas_wdt *driver_data = watchdog_get_drvdata(wdt);
> + struct palmas *palmas = driver_data->palmas;
> +
> + return palmas_wdt_write(palmas, driver_data->timer_margin);

Just wondering - why not just write 0 ?

> +}
> +
> +static int palmas_wdt_set_timeout(struct watchdog_device *wdt, unsigned 
> timeout)
> +{
> + struct palmas_wdt *driver_data = watchdog_get_drvdata(wdt);
> +
> + if (timeout < 1 || timeout > 128) {
> + dev_warn(driver_data->dev,
> + "Timeout can only be in the range [1-128] seconds");
> + return -EINVAL;
> + }
The watchdog core supports limit checking. Might as well use it.

On a side note, it might be an interesting experience if you try setting
a value of 0 or larger than 128. Unless I am missing something,
driver_data->dev is never initialized.

> + driver_data->timer_margin = fls(timeout) - 1;
> + return 0;
> +}
> +
> +static const struct watchdog_info palmas_wdt_info = {
> + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
> + .identity = "Palmas Watchdog",
> + .firmware_version = 0,
> +};
> +
> +static const struct watchdog_ops palmas_wdt_ops = {
> + .owner = THIS_MODULE,
> + .start = palmas_wdt_enable,
> + .stop = palmas_wdt_disable,
> + .ping = palmas_wdt_enable,
> + .set_timeout = palmas_wdt_set_timeout,
> +};
> +
> +static int palmas_wdt_probe(struct platform_device *pdev)
> +{
> + struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
> + struct palmas_wdt *driver_data;
> + struct watchdog_device *palmas_wdt;
> + int ret = 0;
> +
> + driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
> +GFP_KERNEL);
> + if (!driver_data) {
> + dev_err(&pdev->dev, "Unable to alloacate watchdog device\n");

AFAIK devm_ functions already issue a message on errors, so it is unnecessary
to issue another one here.

> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + driver_data->palmas = palmas;
> +
> + palmas_wdt = &driver_data->wdt;
> +
> + palmas_wdt->info = &palmas_wdt_info;
> + palmas_wdt->ops = &palmas_wdt_ops;
> + watchdog_set_nowayout(palmas_wdt, nowayout);
> + watchdog_set_drvdata(palmas_wdt, driver_data);
> +

There is no call to watchdog_init_timeout, and the timeout value is not 
initialized
in palmas_wdt. So the driver depends on the limit being set from user space
with WDIOC_SETTIMEOUT. But that can not happen until aft

Re: [PATCH v10 05/12] watchdog: Kconfig for Palmas watchdog

2013-03-24 Thread Guenter Roeck
On Fri, Mar 22, 2013 at 02:55:15PM +, Ian Lartey wrote:
> Add the Kconfig and Makefile for the Palmas watchdog driver
> 
> Signed-off-by: Ian Lartey 
> Signed-off-by: Graeme Gregory 
> ---

I think this patch should be merged with the previous one.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: mfd: Core driver for Winbond chips

2013-03-24 Thread Guenter Roeck
On Sat, Mar 23, 2013 at 10:49:14AM -0700, Guenter Roeck wrote:
> MFD core driver for various variants of Winbond/Nuvoton SuperIO chips.
> 
> Signed-off-by: Guenter Roeck 

Sorry for sending this twice. I seem to be having trouble with outgoing e-mail
being delayed for hours. The first patch didn't show up for a long time, and I
thought I did something wrong when sending it.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] net: Add support for handling queueing in hardware

2013-03-24 Thread Guenter Roeck
On Fri, Mar 22, 2013 at 06:08:40PM -0400, Theodore Ts'o wrote:
> On Fri, Mar 22, 2013 at 11:39:20AM -0400, Ben Collins wrote:
> > 
> > If your company had hardware going to production, you'd want it supported 
> > in mainline too, I suspect.
> 
> And if companies told their hardware partners that they will drop use
> of their hardware in future products unless they get their !@#@S
> drivers upstream, I'd bet they'd change their engineering priorities
> so they would work on it, instead of foisting this work on their
> customers.
> 
I would love to be in that position. However, the decision to choose
a specific chip is not always coordinated with those who have to provide
the software to run on those chips.

> I've seen this work in enterprise computing, where the RFP had
> requirements for upstream drivers (i.e., if you want your 10gig
> ethernet NIC to be used in HP or IBM's servers, get the darned thing
> upstream!).  The trick is making it clear that selection of components
> depends not just on an OSS driver, but an OSS driver which has been
> accepted upstream (which also helps from a quality-of-code
> requirement).
> 
> I've been waiting for this to start happening in the consumer
> electronics/embedded world, but it's been slow coming,
> unfortunately
> 
The same applies to vendors of non-consumer network devices, unfortunately.

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC] fsfreeze: moving from uniterruptible to killable

2013-03-24 Thread Marco Stornelli
When a fs is frozen, a process can hang because we wait in
uniterruptible state. We give the user the possibility to kill the process.

Not-signed-off-by: Marco Stornelli 
---

--- fs/super.c.orig 2013-03-24 09:56:33.0 +0100
+++ fs/super.c  2013-03-24 09:58:41.0 +0100
@@ -1198,7 +1198,7 @@ retry:
if (unlikely(sb->s_writers.frozen >= level)) {
if (!wait)
return 0;
-   wait_event(sb->s_writers.wait_unfrozen,
+   wait_event_killable(sb->s_writers.wait_unfrozen,
   sb->s_writers.frozen < level);
}
 
@@ -1248,7 +1248,7 @@ static void sb_wait_write(struct super_b
 * of frozen and checking of the counter
 */
prepare_to_wait(&sb->s_writers.wait, &wait,
-   TASK_UNINTERRUPTIBLE);
+TASK_KILLABLE);
 
writers = percpu_counter_sum(&sb->s_writers.counter[level-1]);
if (writers)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: hybrid raid1 with trim support

2013-03-24 Thread Markus
Hi!

Still the same with 3.8.4 ... anybody?

Best regards,
Markus

Markus schrieb am 12.03.2013:
> Hello!
> 
> I created a hybrid raid1 with one ssd and one hdd. Used writemostly and 
> writebehind and put ext4 with discard enabled on it.
> This setup worked quite well for the last months (last kernel was 3.7.6). But 
> now as I booted 3.8.2 the hdd was dropped from the raid with:
> > md/raid1:md2: Disk failure on sdb1, disabling device.
> > md/raid1:md2: Operation continuing on 1 devices.
> 
> Re-adding this drive it will try to resync but the hdd will be dropped short 
> time after. Now I remounted the device without the discard flag and the 
> resync and usage works as before.
> After remounting it again with discard enabled the hdd is dropped again. So I 
> think this is the culprit as the hdd does obviously not support TRIM...
> 
> As it worked fine before, I think this is a regression? Or is this an 
> intended change?
> 
> 
> Thanks,
> Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: 3.9-rc3+: reports battery as 0 mWh capacity on thinkpad x60

2013-03-24 Thread Pavel Machek
Hi!

> > > >> pavel@amd:~$ cat /proc/acpi/battery/BAT0/info 
> > > >> present: yes
> > > >> design capacity: 0 mWh
> > > >> last full capacity:  0 mWh
> > > >> battery technology:  rechargeable
> > > >> design voltage:  14400 mV
> > > >> 
> > > >> This worked before... at least it works in 2.6 kernel used by debian.
> > > >
> > > > This works for me in 3.9-rc3.  May I see your .config?
...
> > But problem is not in /proc, /sys has zeros, too.
> > 
> > pavel@amd:~$ cat /sys/class/power_supply/BAT0/energy_full
> > 0
> > pavel@amd:~$ cat /sys/class/power_supply/BAT0/energy_full_design 
> > 0
> > pavel@amd:~$ cat /sys/class/power_supply/BAT0/model_name 
> > 93P5030
> > pavel@amd:~$
> 
> Can you narrow the time frame when it stopped working a bit?

Well, 2.6.32 from debian works ok, and self-compiled 3.1+ kernel also
seems to work ok.

I'm not sure if 3.7+ kernels worked, actually... I'd have to do some
compiling to check.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v2, part4 01/39] vmlinux.lds: add comments for global variables and clean up useless declarations

2013-03-24 Thread Arnd Bergmann
On Sunday 24 March 2013, Jiang Liu wrote:
> This patch documents global variables exported from vmlinux.lds.
> 1) Add comments about usage guidelines for global variables exported
>from vmlinux.lds.S.
> 2) Remove unused __initdata_begin[] and __initdata_end[].
> 
> Signed-off-by: Jiang Liu 
> Cc: Arnd Bergmann 
> Cc: linux-a...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  include/asm-generic/sections.h |   21 -
>  1 file changed, 20 insertions(+), 1 deletion(-)

for asm-generic:

Acked-by: Arnd Bergmann 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] KVM: allow host header to be included even for !CONFIG_KVM

2013-03-24 Thread Gleb Natapov
On Thu, Mar 21, 2013 at 05:02:15PM -0700, Kevin Hilman wrote:
> Gleb Natapov  writes:
> 
> > On Thu, Mar 21, 2013 at 02:33:13PM -0500, Scott Wood wrote:
> >> On 03/21/2013 02:16:00 PM, Gleb Natapov wrote:
> >> >On Thu, Mar 21, 2013 at 01:42:34PM -0500, Scott Wood wrote:
> >> >> On 03/21/2013 09:27:14 AM, Kevin Hilman wrote:
> >> >> >Gleb Natapov  writes:
> >> >> >
> >> >> >> On Wed, Mar 20, 2013 at 06:58:41PM -0500, Scott Wood wrote:
> >> >> >>> Why can't the entirety kvm_host.h be included regardless of
> >> >> >>> CONFIG_KVM, just like most other feature-specific headers?  Why
> >> >> >>> can't the if/else just go around the functions that you want to
> >> >> >stub
> >> >> >>> out for non-KVM builds?
> >> >> >>>
> >> >> >> Kevin,
> >> >> >>
> >> >> >>  What compilation failure this patch fixes? I presume
> >> >something ARM
> >> >> >> related.
> >> >> >
> >> >> >Not specficially ARM related, but more context tracking related
> >> >since
> >> >> >kernel/context_tracking.c pulls in kvm_host.h, which attempts to
> >> >> >pull in
> >> >> > which may not exist on some platforms.
> >> >> >
> >> >> >At least for ARM, KVM support was added in v3.9 so this patch can
> >> >> >probably be dropped since the non-KVM builds on ARM now work.
> >> >But any
> >> >> >platform without the  will still be broken when
> >> >trying to
> >> >> >build the context tracker.
> >> >>
> >> >> Maybe other platforms should get empty asm/kvm*.h files.  Is there
> >> >> anything from those files that the linux/kvm*.h headers need to
> >> >> build?
> >> >>
> >> >arch things. kvm_vcpu_arch, kvm_arch_memory_slot, kvm_arch etc.
> >> 
> >> Could define them as empty structs.
> >> 
> > Isn't is simpler for kernel/context_tracking.c to define empty
> > __guest_enter()/__guest_exit() if !CONFIG_KVM.
> 
> I proposed something like that in an earlier version but Frederic asked
> me to propose a fix to the KVM headers instead.
> 
> Just in case fixing the context tracking subsystem is preferred, 
> the patch below fixes the problem also.
> 
The patch that broke PPC build was reverted. Frederic can you get the
patch below?

> Kevin
> 
> >From f22995a262144d0d61705fa72134694d911283eb Mon Sep 17 00:00:00 2001
> From: Kevin Hilman 
> Date: Thu, 21 Mar 2013 16:57:14 -0700
> Subject: [PATCH] context_tracking: fix !CONFIG_KVM compile: add stub guest
>  enter/exit
> 
> When KVM is not enabled, or not available on a platform, the KVM
> headers should not be included.  Instead, just define stub
> __guest_[enter|exit] functions.
> 
> Cc: Frederic Weisbecker 
> Signed-off-by: Kevin Hilman 
> ---
>  kernel/context_tracking.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
> index 65349f0..64b0f80 100644
> --- a/kernel/context_tracking.c
> +++ b/kernel/context_tracking.c
> @@ -15,12 +15,18 @@
>   */
>  
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  
> +#if IS_ENABLED(CONFIG_KVM)
> +#include 
> +#else
> +#define __guest_enter()
> +#define __guest_exit()
> +#endif
> +
>  DEFINE_PER_CPU(struct context_tracking, context_tracking) = {
>  #ifdef CONFIG_CONTEXT_TRACKING_FORCE
>   .active = true,
> -- 
> 1.8.2

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: I/O blocked while dirty pages are being flushed

2013-03-24 Thread Bart Van Assche

On 03/24/13 06:12, Fredrik Tolf wrote:

While this flush is running, I find that many a process goes into disk
sleep waiting for the flush to complete. This includes the process
manipulating the mmapped file whenever it tries to redirty a page
currently waiting to be flushed, but also, for instance, programs that
write() to log files (since, I guess, the buffer page backing the last
written portion of the log file is being flushed).


Had you already encountered this article: Jonathan Corbet, The trouble 
with stable pages, March 13, 2012 (http://lwn.net/Articles/486311/) ?


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Caps lock XOR on multiple keyboards?

2013-03-24 Thread Pavel Machek
Hi!
On Mon 2012-12-03 23:58:48, Alan Cox wrote:
> On 3 Dec 2012 16:19:11 -0500
> "George Spelvin"  wrote:
> 
> > (Not sure who owns this; Cc: to the last few people to touch
> > drivers/tty/vt/keyboard.c.)
> 
> linux-input is probably the best place to discuss this

Added few more ccs. Yes, I see that too, in kernels such as debian
2.6.32. It may be even older than that, but I was not using docking
heavily in the old days.

Symptoms for me are that pretty often capslock LED will start show
opposite of true capslock state. I normally use X these days.

(Other problem seems to be that keyboard LEDs are not updated on
keyboard hotplug.)

There is patch to drive keyboard LEDs through LED subsystem, perhaps
that would be good idea?

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Caps lock XOR on multiple keyboards?

2013-03-24 Thread Pavel Machek
On Sun 2013-03-24 11:30:18, Pavel Machek wrote:
> Hi!
> On Mon 2012-12-03 23:58:48, Alan Cox wrote:
> > On 3 Dec 2012 16:19:11 -0500
> > "George Spelvin"  wrote:
> > 
> > > (Not sure who owns this; Cc: to the last few people to touch
> > > drivers/tty/vt/keyboard.c.)
> > 
> > linux-input is probably the best place to discuss this
> 
> Added few more ccs. Yes, I see that too, in kernels such as debian
> 2.6.32. It may be even older than that, but I was not using docking
> heavily in the old days.
> 
> Symptoms for me are that pretty often capslock LED will start show
> opposite of true capslock state. I normally use X these days.

Ok... so it is:

Each capslock key only controls the local LED, but affects global
state.

So I turn on capslock on PS/2 keyboard its led is on. But I type on
USB keyboard, its capslock led is off, but I type in all caps. Oops.

Pavel 
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


kernel 3.8.4 : kernel BUG at fs/locks.c:2093!

2013-03-24 Thread Toralf Förster
Observed it today at a 32 bit Gentoo Linux w/ kernel 3.8.4 :


2013-03-24T11:39:48.749+01:00 n22 kernel: [ cut here ]
2013-03-24T11:39:48.749+01:00 n22 kernel: kernel BUG at fs/locks.c:2093!
2013-03-24T11:39:48.749+01:00 n22 kernel: invalid opcode:  [#1] SMP
2013-03-24T11:39:48.749+01:00 n22 kernel: Modules linked in: microcode 
cpufreq_stats md5 nfsd auth_rpcgss loop nls_iso8859_1 nls_cp437 vfat fat 
ipt_MASQUERADE xt_owner xt_multiport ipt_REJECT xt_tcpudp xt_recent 
xt_conntrack nf_conntrack_ftp xt_limit xt_LOG iptable_nat nf_conntrack_ipv4 
nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_filter ip_tables 
x_tables af_packet pppoe pppox ppp_generic slhc bridge stp llc tun msr i915 
arc4 cfbfillrect cfbimgblt iwldvm mac80211 i2c_algo_bit cfbcopyarea intel_agp 
intel_gtt fbcon snd_hda_codec_conexant bitblit softcursor font drm_kms_helper 
drm uvcvideo agpgart coretemp kvm_intel usblp acpi_cpufreq mperf iwlwifi 
cfg80211 snd_hda_intel fb i2c_i801 videobuf2_vmalloc kvm snd_hda_codec 
videobuf2_memops video e1000e processor fbdev videobuf2_core sdhci_pci snd_pcm 
videodev snd_page_alloc sdhci snd_timer mmc_core thermal wmi 8250_pci 8250_core 
serial_core thermal_sys thinkpad_acpi i2c_core battery button nvram snd 
soundcore rfkill ac tpm_tis hwmo
n tpm psmouse evdev tpm_bios aesni_intel ablk_helper cryptd lrw aes_i586 xts 
gf128mul cbc sha256_generic fuse nfs lockd sunrpc dm_crypt dm_mod hid_monterey 
hid_microsoft hid_logitech hid_ezkey hid_cypress hid_chicony hid_cherry 
hid_belkin hid_apple hid_a4tech hid_generic usbhid hid sr_mod cdrom sg [last 
unloaded: microcode]
2013-03-24T11:39:48.749+01:00 n22 kernel: Pid: 7869, comm: kworker/3:2 Not 
tainted 3.8.4 #7 LENOVO 4180F65/4180F65
2013-03-24T11:39:48.749+01:00 n22 kernel: EIP: 0060:[] EFLAGS: 
00010246 CPU: 3
2013-03-24T11:39:48.749+01:00 n22 kernel: EIP is at locks_remove_flock+0xe9/0xf0
2013-03-24T11:39:48.749+01:00 n22 kernel: EAX: 0001 EBX: ea81ae40 ECX: 
0032 EDX: 3232
2013-03-24T11:39:48.749+01:00 n22 kernel: ESI: c6489e88 EDI: ef7c2100 EBP: 
e9a3dec0 ESP: e9a3de44
2013-03-24T11:39:48.749+01:00 n22 kernel: DS: 007b ES: 007b FS: 00d8 GS: 00e0 
SS: 0068
2013-03-24T11:39:48.750+01:00 n22 kernel: CR0: 80050033 CR2: 4003455c CR3: 
11384000 CR4: 000407f0
2013-03-24T11:39:48.750+01:00 n22 kernel: DR0:  DR1:  DR2: 
 DR3: 
2013-03-24T11:39:48.750+01:00 n22 kernel: DR6: 0ff0 DR7: 0400
2013-03-24T11:39:48.750+01:00 n22 kernel: Process kworker/3:2 (pid: 7869, 
ti=e9a3c000 task=dfde9ea0 task.ti=e9a3c000)
2013-03-24T11:39:48.750+01:00 n22 kernel: Stack:
2013-03-24T11:39:48.750+01:00 n22 kernel: c6489dc8 e9a3de70 c1065355 e9a3de02 
f37e0100 e9c4a840 0199 c8667a20
2013-03-24T11:39:48.750+01:00 n22 kernel: f37e0100 dfde9ea0 f37e0100 0003 
eb08c928 c13d6fc0 dfc09a74 eb08c900
2013-03-24T11:39:48.750+01:00 n22 kernel: dfc09a7c e9a3de9c c1066011 eb08c900 
dfc09a74 ea81ae48 c6489dc8 0008
2013-03-24T11:39:48.750+01:00 n22 kernel: Call Trace:
2013-03-24T11:39:48.750+01:00 n22 kernel: [] ? 
sched_clock_cpu+0xf5/0x160
2013-03-24T11:39:48.750+01:00 n22 kernel: [] ? 
set_next_entity+0x31/0x80
2013-03-24T11:39:48.750+01:00 n22 kernel: [] __fput+0x79/0x1f0
2013-03-24T11:39:48.750+01:00 n22 kernel: [] delayed_fput+0x7c/0x90
2013-03-24T11:39:48.750+01:00 n22 kernel: [] 
process_one_work+0x132/0x3a0
2013-03-24T11:39:48.750+01:00 n22 kernel: [] worker_thread+0x121/0x350
2013-03-24T11:39:48.750+01:00 n22 kernel: [] ? 
manage_workers+0x270/0x270
2013-03-24T11:39:48.750+01:00 n22 kernel: [] kthread+0x94/0xa0
2013-03-24T11:39:48.750+01:00 n22 kernel: [] 
ret_from_kernel_thread+0x1b/0x28
2013-03-24T11:39:48.750+01:00 n22 kernel: [] ? 
flush_kthread_work+0xd0/0xd0
2013-03-24T11:39:48.750+01:00 n22 kernel: Code: f0 e8 6c de ff ff 8b 06 85 c0 
75 de 8d b6 00 00 00 00 80 05 84 56 62 c1 01 83 c4 70 5b 5e 5f 5d c3 90 89 f0 
e8 f9 dd ff ff eb b9 <0f> 0b 90 90 90 90 90 55 89 e5 53 81 ec 8c 00 00 00 66 66 
66 66
2013-03-24T11:39:48.750+01:00 n22 kernel: EIP: [] 
locks_remove_flock+0xe9/0xf0 SS:ESP 0068:e9a3de44

Only the sys-rq key alt+print+b worked after that

-- 
MfG/Sincerely
Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Zombie stuck in zap_pid_ns_processes()

2013-03-24 Thread Eric W. Biederman

Caj Larsson  writes:

> Hello,
>
> We are setting up a container using a CLONE_NEWNS linux namespace.
> Previously we used the 3.4.4 kernel, which worked fine. After I
> upgraded i also experienced races in netlink, which has been resolved
> by placing a monitor around the namespace setup. When we upgraded to
> Linux 3.8.0 however our init processes does not get reaped when the
> namespace is killed and lingers as zombie process under the global
> init.
>
> The init has multiple threads when running and two remain in the
> zombie. One of them is hung in zap_pid_ns_processes() and has been set
> uninterruptible. The other one, which has Tgid=PID, is still in
> do_exit().

Doh.

Thank you for the detailed bug report it appears I goofed, and failed
to account for a multi-threaded init.

Will you please verify that the following patch fixes it for you.

Signed-off-by: "Eric W. Biederman" 
---
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index c1c3dc1..72b7722 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -181,6 +181,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
int nr;
int rc;
struct task_struct *task, *me = current;
+   int init_pids = task_pid_vnr(me) == 1 ? 1 : 2;
 
/* Don't allow any more processes into the pid namespace */
disable_pid_allocation(pid_ns);
@@ -230,7 +231,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 */
for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE);
-   if (pid_ns->nr_hashed == 1)
+   if (pid_ns->nr_hashed == init_pids)
break;
schedule();
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC 0/2] PCI: Introduce MSI chip infrastructure

2013-03-24 Thread Thomas Petazzoni
Andrew, Thierry,

On Fri, 22 Mar 2013 09:30:27 +, Andrew Murray wrote:

> I think this could work well. In the future if the use of an independent MSI
> controller is required, then new DT bindings for host-bridges could use
> phandles to reference independent MSI controllers as their providers of
> MSIs. I guess this functionality can be built on top of what you have proposed
> later as the need arises.

On Marvell HW (at least Armada 370/XP), MSIs are handled by the
main interrupt controller directly, or more precisely, managing the
MSIs requires fiddling with registers that are part of the interrupt
controller registers, and not part of the PCIe controller registers.

Basically, when a MSI interrupt is raised, it corresponds to IRQ 1 on
the main interrupt controller. Then, one has to read a register of the
main interrupt controller to find out which MSI interrupt was actually
triggered. So in our case, the MSI irq_chip really belongs to the
interrupt controller driver, and not the PCIe driver. Also, the
physical address to be added in the 'struct msi_msg' is the physical
address of an interrupt controller register.

Therefore, I'm not sure how to do the interaction between the PCIe
driver and the interrupt controller driver.

Suggestions?

I'll try to post some ugly code next week just to show what is
happening.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   5   >