aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/memory.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2013-04-29 18:08:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:54:37 -0400
commit4edd7ceff0662afde195da6f6c43e7cbe1ed2dc4 (patch)
tree89e53f524dae229f9db490a1e091842302010c21 /drivers/base/memory.c
parentfe74ebb106a5950e82222c8ea258a9c0d7c65f04 (diff)
mm, hotplug: avoid compiling memory hotremove functions when disabled
__remove_pages() is only necessary for CONFIG_MEMORY_HOTREMOVE. PowerPC pseries will return -EOPNOTSUPP if unsupported. Adding an #ifdef causes several other functions it depends on to also become unnecessary, which saves in .text when disabled (it's disabled in most defconfigs besides powerpc, including x86). remove_memory_block() becomes static since it is not referenced outside of drivers/base/memory.c. Build tested on x86 and powerpc with CONFIG_MEMORY_HOTREMOVE both enabled and disabled. Signed-off-by: David Rientjes <rientjes@google.com> Acked-by: Toshi Kani <toshi.kani@hp.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Wen Congyang <wency@cn.fujitsu.com> Cc: Tang Chen <tangchen@cn.fujitsu.com> Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base/memory.c')
-rw-r--r--drivers/base/memory.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index a51007b79032..65d9799cbb61 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -93,16 +93,6 @@ int register_memory(struct memory_block *memory)
93 return error; 93 return error;
94} 94}
95 95
96static void
97unregister_memory(struct memory_block *memory)
98{
99 BUG_ON(memory->dev.bus != &memory_subsys);
100
101 /* drop the ref. we got in remove_memory_block() */
102 kobject_put(&memory->dev.kobj);
103 device_unregister(&memory->dev);
104}
105
106unsigned long __weak memory_block_size_bytes(void) 96unsigned long __weak memory_block_size_bytes(void)
107{ 97{
108 return MIN_MEMORY_BLOCK_SIZE; 98 return MIN_MEMORY_BLOCK_SIZE;
@@ -637,8 +627,28 @@ static int add_memory_section(int nid, struct mem_section *section,
637 return ret; 627 return ret;
638} 628}
639 629
640int remove_memory_block(unsigned long node_id, struct mem_section *section, 630/*
641 int phys_device) 631 * need an interface for the VM to add new memory regions,
632 * but without onlining it.
633 */
634int register_new_memory(int nid, struct mem_section *section)
635{
636 return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
637}
638
639#ifdef CONFIG_MEMORY_HOTREMOVE
640static void
641unregister_memory(struct memory_block *memory)
642{
643 BUG_ON(memory->dev.bus != &memory_subsys);
644
645 /* drop the ref. we got in remove_memory_block() */
646 kobject_put(&memory->dev.kobj);
647 device_unregister(&memory->dev);
648}
649
650static int remove_memory_block(unsigned long node_id,
651 struct mem_section *section, int phys_device)
642{ 652{
643 struct memory_block *mem; 653 struct memory_block *mem;
644 654
@@ -661,15 +671,6 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
661 return 0; 671 return 0;
662} 672}
663 673
664/*
665 * need an interface for the VM to add new memory regions,
666 * but without onlining it.
667 */
668int register_new_memory(int nid, struct mem_section *section)
669{
670 return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
671}
672
673int unregister_memory_section(struct mem_section *section) 674int unregister_memory_section(struct mem_section *section)
674{ 675{
675 if (!present_section(section)) 676 if (!present_section(section))
@@ -677,6 +678,7 @@ int unregister_memory_section(struct mem_section *section)
677 678
678 return remove_memory_block(0, section, 0); 679 return remove_memory_block(0, section, 0);
679} 680}
681#endif /* CONFIG_MEMORY_HOTREMOVE */
680 682
681/* 683/*
682 * offline one memory block. If the memory block has been offlined, do nothing. 684 * offline one memory block. If the memory block has been offlined, do nothing.