lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1276666966-14259-7-git-send-email-yinghai@kernel.org>
Date:	Tue, 15 Jun 2010 22:42:15 -0700
From:	Yinghai Lu <yinghai@...nel.org>
To:	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
	"H. Peter Anvin" <hpa@...or.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>
Cc:	David Miller <davem@...emloft.net>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Johannes Weiner <hannes@...xchg.org>,
	linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
	Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH 06/37] lmb: Add ARCH_DISCARD_LMB to put lmb code to .init

So those lmb bits could be released after kernel is booted up.

Arch code could define ARCH_DISCARD_LMB in asm/lmb.h,
__init_lmb will become __init, __initdata_lmb will becom __initdata

x86 code will use that.

if ARCH_DISCARD_LMB is defined, debugfs is not used

-v2: use ARCH_DISCARD_LMB according to Michael Ellerman

Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
 include/linux/lmb.h |    8 ++++++++
 lib/lmb.c           |   48 ++++++++++++++++++++++++------------------------
 2 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index d529232..5310c7b 100644
--- a/include/linux/lmb.h
+++ b/include/linux/lmb.h
@@ -145,6 +145,14 @@ static inline unsigned long lmb_region_pages(const struct lmb_region *reg)
 	     region++)
 
 
+#ifdef ARCH_DISCARD_LMB
+#define __init_lmb __init
+#define __initdata_lmb __initdata
+#else
+#define __init_lmb
+#define __initdata_lmb
+#endif
+
 #endif /* CONFIG_HAVE_LMB */
 
 #endif /* __KERNEL__ */
diff --git a/lib/lmb.c b/lib/lmb.c
index 2aaeeec..e45e967 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -20,12 +20,12 @@
 #include <linux/seq_file.h>
 #include <linux/lmb.h>
 
-struct lmb lmb;
+struct lmb lmb __initdata_lmb;
 
-int lmb_debug;
-int lmb_can_resize;
-static struct lmb_region lmb_memory_init_regions[INIT_LMB_REGIONS + 1];
-struct lmb_region lmb_reserved_init_regions[INIT_LMB_REGIONS + 1];
+int lmb_debug __initdata_lmb;
+int lmb_can_resize __initdata_lmb;
+static struct lmb_region lmb_memory_init_regions[INIT_LMB_REGIONS + 1] __initdata_lmb;
+struct lmb_region lmb_reserved_init_regions[INIT_LMB_REGIONS + 1] __initdata_lmb;
 
 /* inline so we don't get a warning when pr_debug is compiled out */
 static inline const char *lmb_type_name(struct lmb_type *type)
@@ -42,23 +42,23 @@ static inline const char *lmb_type_name(struct lmb_type *type)
  * Address comparison utilities
  */
 
-static phys_addr_t lmb_align_down(phys_addr_t addr, phys_addr_t size)
+static phys_addr_t __init_lmb lmb_align_down(phys_addr_t addr, phys_addr_t size)
 {
 	return addr & ~(size - 1);
 }
 
-static phys_addr_t lmb_align_up(phys_addr_t addr, phys_addr_t size)
+static phys_addr_t __init_lmb lmb_align_up(phys_addr_t addr, phys_addr_t size)
 {
 	return (addr + (size - 1)) & ~(size - 1);
 }
 
-static unsigned long lmb_addrs_overlap(phys_addr_t base1, phys_addr_t size1,
+static unsigned long __init_lmb lmb_addrs_overlap(phys_addr_t base1, phys_addr_t size1,
 				       phys_addr_t base2, phys_addr_t size2)
 {
 	return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
 }
 
-static long lmb_addrs_adjacent(phys_addr_t base1, phys_addr_t size1,
+static long __init_lmb lmb_addrs_adjacent(phys_addr_t base1, phys_addr_t size1,
 			       phys_addr_t base2, phys_addr_t size2)
 {
 	if (base2 == base1 + size1)
@@ -69,7 +69,7 @@ static long lmb_addrs_adjacent(phys_addr_t base1, phys_addr_t size1,
 	return 0;
 }
 
-static long lmb_regions_adjacent(struct lmb_type *type,
+static long __init_lmb lmb_regions_adjacent(struct lmb_type *type,
 				 unsigned long r1, unsigned long r2)
 {
 	phys_addr_t base1 = type->regions[r1].base;
@@ -80,7 +80,7 @@ static long lmb_regions_adjacent(struct lmb_type *type,
 	return lmb_addrs_adjacent(base1, size1, base2, size2);
 }
 
-long lmb_overlaps_region(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
+long __init_lmb lmb_overlaps_region(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
 {
 	unsigned long i;
 
@@ -156,7 +156,7 @@ static phys_addr_t __init lmb_find_base(phys_addr_t size, phys_addr_t align,
 	return LMB_ERROR;
 }
 
-static void lmb_remove_region(struct lmb_type *type, unsigned long r)
+static void __init_lmb lmb_remove_region(struct lmb_type *type, unsigned long r)
 {
 	unsigned long i;
 
@@ -168,7 +168,7 @@ static void lmb_remove_region(struct lmb_type *type, unsigned long r)
 }
 
 /* Assumption: base addr of region 1 < base addr of region 2 */
-static void lmb_coalesce_regions(struct lmb_type *type,
+static void __init_lmb lmb_coalesce_regions(struct lmb_type *type,
 		unsigned long r1, unsigned long r2)
 {
 	type->regions[r1].size += type->regions[r2].size;
@@ -178,7 +178,7 @@ static void lmb_coalesce_regions(struct lmb_type *type,
 /* Defined below but needed now */
 static long lmb_add_region(struct lmb_type *type, phys_addr_t base, phys_addr_t size);
 
-static int lmb_double_array(struct lmb_type *type)
+static int __init_lmb lmb_double_array(struct lmb_type *type)
 {
 	struct lmb_region *new_array, *old_array;
 	phys_addr_t old_size, new_size, addr;
@@ -250,13 +250,13 @@ static int lmb_double_array(struct lmb_type *type)
 	return 0;
 }
 
-extern int __weak lmb_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
+extern int __init_lmb __weak lmb_memory_can_coalesce(phys_addr_t addr1, phys_addr_t size1,
 					  phys_addr_t addr2, phys_addr_t size2)
 {
 	return 1;
 }
 
-static long lmb_add_region(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
+static long __init_lmb lmb_add_region(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
 {
 	unsigned long coalesced = 0;
 	long adjacent, i;
@@ -343,13 +343,13 @@ static long lmb_add_region(struct lmb_type *type, phys_addr_t base, phys_addr_t
 	return 0;
 }
 
-long lmb_add(phys_addr_t base, phys_addr_t size)
+long __init_lmb lmb_add(phys_addr_t base, phys_addr_t size)
 {
 	return lmb_add_region(&lmb.memory, base, size);
 
 }
 
-static long __lmb_remove(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
+static long __init_lmb __lmb_remove(struct lmb_type *type, phys_addr_t base, phys_addr_t size)
 {
 	phys_addr_t rgnbegin, rgnend;
 	phys_addr_t end = base + size;
@@ -397,7 +397,7 @@ static long __lmb_remove(struct lmb_type *type, phys_addr_t base, phys_addr_t si
 	return lmb_add_region(type, end, rgnend - end);
 }
 
-long lmb_remove(phys_addr_t base, phys_addr_t size)
+long __init_lmb lmb_remove(phys_addr_t base, phys_addr_t size)
 {
 	return __lmb_remove(&lmb.memory, base, size);
 }
@@ -554,7 +554,7 @@ phys_addr_t __init lmb_phys_mem_size(void)
 	return lmb.memory_size;
 }
 
-phys_addr_t lmb_end_of_DRAM(void)
+phys_addr_t __init_lmb lmb_end_of_DRAM(void)
 {
 	int idx = lmb.memory.cnt - 1;
 
@@ -615,7 +615,7 @@ int __init lmb_is_reserved(phys_addr_t addr)
 	return 0;
 }
 
-int lmb_is_region_reserved(phys_addr_t base, phys_addr_t size)
+int __init_lmb lmb_is_region_reserved(phys_addr_t base, phys_addr_t size)
 {
 	return lmb_overlaps_region(&lmb.reserved, base, size);
 }
@@ -626,7 +626,7 @@ void __init lmb_set_current_limit(phys_addr_t limit)
 	lmb.current_limit = limit;
 }
 
-static void lmb_dump(struct lmb_type *region, char *name)
+static void __init_lmb lmb_dump(struct lmb_type *region, char *name)
 {
 	unsigned long long base, size;
 	int i;
@@ -642,7 +642,7 @@ static void lmb_dump(struct lmb_type *region, char *name)
 	}
 }
 
-void lmb_dump_all(void)
+void __init_lmb lmb_dump_all(void)
 {
 	if (!lmb_debug)
 		return;
@@ -708,7 +708,7 @@ static int __init early_lmb(char *p)
 }
 early_param("lmb", early_lmb);
 
-#ifdef CONFIG_DEBUG_FS
+#if defined(CONFIG_DEBUG_FS) && !defined(ARCH_DISCARD_LMB)
 
 static int lmb_debug_show(struct seq_file *m, void *private)
 {
-- 
1.6.4.2

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ