diff options
| author | Nathan Fontenot <nfont@austin.ibm.com> | 2010-10-19 13:46:19 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:16:44 -0400 |
| commit | 07681215975e05a1454b0afdeef07deb0db626ee (patch) | |
| tree | 87caa0a9fd41f9e6cb323d52cf0f75036ea1ad2a | |
| parent | 2938ffbd466d2811a6012609684a2298eef35065 (diff) | |
Driver core: Add section count to memory_block struct
Add a section count property to the memory_block struct to track the number
of memory sections that have been added/removed from a memory block. This
allows us to know when the last memory section of a memory block has been
removed so we can remove the memory block.
Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com>
Reviewed-by: Robin Holt <holt@sgi.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/base/memory.c | 17 | ||||
| -rw-r--r-- | include/linux/memory.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 5185bcff2de9..cafeaaf0428f 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
| @@ -490,6 +490,7 @@ static int add_memory_block(int nid, struct mem_section *section, | |||
| 490 | 490 | ||
| 491 | mem->phys_index = __section_nr(section); | 491 | mem->phys_index = __section_nr(section); |
| 492 | mem->state = state; | 492 | mem->state = state; |
| 493 | mem->section_count++; | ||
| 493 | mutex_init(&mem->state_mutex); | 494 | mutex_init(&mem->state_mutex); |
| 494 | start_pfn = section_nr_to_pfn(mem->phys_index); | 495 | start_pfn = section_nr_to_pfn(mem->phys_index); |
| 495 | mem->phys_device = arch_get_memory_phys_device(start_pfn); | 496 | mem->phys_device = arch_get_memory_phys_device(start_pfn); |
| @@ -519,12 +520,16 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, | |||
| 519 | 520 | ||
| 520 | mutex_lock(&mem_sysfs_mutex); | 521 | mutex_lock(&mem_sysfs_mutex); |
| 521 | mem = find_memory_block(section); | 522 | mem = find_memory_block(section); |
| 522 | unregister_mem_sect_under_nodes(mem); | 523 | |
| 523 | mem_remove_simple_file(mem, phys_index); | 524 | mem->section_count--; |
| 524 | mem_remove_simple_file(mem, state); | 525 | if (mem->section_count == 0) { |
| 525 | mem_remove_simple_file(mem, phys_device); | 526 | unregister_mem_sect_under_nodes(mem); |
| 526 | mem_remove_simple_file(mem, removable); | 527 | mem_remove_simple_file(mem, phys_index); |
| 527 | unregister_memory(mem, section); | 528 | mem_remove_simple_file(mem, state); |
| 529 | mem_remove_simple_file(mem, phys_device); | ||
| 530 | mem_remove_simple_file(mem, removable); | ||
| 531 | unregister_memory(mem, section); | ||
| 532 | } | ||
| 528 | 533 | ||
| 529 | mutex_unlock(&mem_sysfs_mutex); | 534 | mutex_unlock(&mem_sysfs_mutex); |
| 530 | return 0; | 535 | return 0; |
diff --git a/include/linux/memory.h b/include/linux/memory.h index c4f3127dbd48..06c1fa0a5c7b 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h | |||
| @@ -23,6 +23,8 @@ | |||
| 23 | struct memory_block { | 23 | struct memory_block { |
| 24 | unsigned long phys_index; | 24 | unsigned long phys_index; |
| 25 | unsigned long state; | 25 | unsigned long state; |
| 26 | int section_count; | ||
| 27 | |||
| 26 | /* | 28 | /* |
| 27 | * This serializes all state change requests. It isn't | 29 | * This serializes all state change requests. It isn't |
| 28 | * held during creation because the control files are | 30 | * held during creation because the control files are |
