Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 30721
b: refs/heads/master
c: bc02af9
h: refs/heads/master
i:
  30719: 9991833
v: v3
  • Loading branch information
Yasunori Goto authored and Linus Torvalds committed Jun 28, 2006
1 parent 003a593 commit efd22c9
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dd56a8e36f91f63c0a31e8a118d87b7cf01526b8
refs/heads/master: bc02af93dd2bbddce1b55e0a493f833a1b7cf140
2 changes: 1 addition & 1 deletion trunk/arch/i386/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void __init mem_init(void)
*/
#ifdef CONFIG_MEMORY_HOTPLUG
#ifndef CONFIG_NEED_MULTIPLE_NODES
int add_memory(u64 start, u64 size)
int arch_add_memory(int nid, u64 start, u64 size)
{
struct pglist_data *pgdata = &contig_page_data;
struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1;
Expand Down
5 changes: 2 additions & 3 deletions trunk/arch/ia64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,15 @@ void online_page(struct page *page)
num_physpages++;
}

int add_memory(u64 start, u64 size)
int arch_add_memory(int nid, u64 start, u64 size)
{
pg_data_t *pgdat;
struct zone *zone;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;

pgdat = NODE_DATA(0);
pgdat = NODE_DATA(nid);

zone = pgdat->node_zones + ZONE_NORMAL;
ret = __add_pages(zone, start_pfn, nr_pages);
Expand All @@ -671,7 +671,6 @@ int add_memory(u64 start, u64 size)

return ret;
}
EXPORT_SYMBOL_GPL(add_memory);

int remove_memory(u64 start, u64 size)
{
Expand Down
11 changes: 8 additions & 3 deletions trunk/arch/powerpc/mm/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ void online_page(struct page *page)
num_physpages++;
}

int __devinit add_memory(u64 start, u64 size)
#ifdef CONFIG_NUMA
int memory_add_physaddr_to_nid(u64 start)
{
return hot_add_scn_to_nid(start);
}
#endif

int __devinit arch_add_memory(int nid, u64 start, u64 size)
{
struct pglist_data *pgdata;
struct zone *zone;
int nid;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;

nid = hot_add_scn_to_nid(start);
pgdata = NODE_DATA(nid);

start = (unsigned long)__va(start);
Expand Down
66 changes: 38 additions & 28 deletions trunk/arch/x86_64/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ void __init clear_kernel_mapping(unsigned long address, unsigned long size)
/*
* Memory hotplug specific functions
*/
#if defined(CONFIG_ACPI_HOTPLUG_MEMORY) || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)

void online_page(struct page *page)
{
ClearPageReserved(page);
Expand All @@ -517,41 +515,27 @@ void online_page(struct page *page)
num_physpages++;
}

#ifndef CONFIG_MEMORY_HOTPLUG
#ifdef CONFIG_MEMORY_HOTPLUG
/*
* Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
* just online the pages.
* XXX: memory_add_physaddr_to_nid() is to find node id from physical address
* via probe interface of sysfs. If acpi notifies hot-add event, then it
* can tell node id by searching dsdt. But, probe interface doesn't have
* node id. So, return 0 as node id at this time.
*/
int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
#ifdef CONFIG_NUMA
int memory_add_physaddr_to_nid(u64 start)
{
int err = -EIO;
unsigned long pfn;
unsigned long total = 0, mem = 0;
for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
if (pfn_valid(pfn)) {
online_page(pfn_to_page(pfn));
err = 0;
mem++;
}
total++;
}
if (!err) {
z->spanned_pages += total;
z->present_pages += mem;
z->zone_pgdat->node_spanned_pages += total;
z->zone_pgdat->node_present_pages += mem;
}
return err;
return 0;
}
#endif

/*
* Memory is added always to NORMAL zone. This means you will never get
* additional DMA/DMA32 memory.
*/
int add_memory(u64 start, u64 size)
int arch_add_memory(int nid, u64 start, u64 size)
{
struct pglist_data *pgdat = NODE_DATA(0);
struct pglist_data *pgdat = NODE_DATA(nid);
struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
Expand All @@ -568,15 +552,41 @@ int add_memory(u64 start, u64 size)
printk("%s: Problem encountered in __add_pages!\n", __func__);
return ret;
}
EXPORT_SYMBOL_GPL(add_memory);
EXPORT_SYMBOL_GPL(arch_add_memory);

int remove_memory(u64 start, u64 size)
{
return -EINVAL;
}
EXPORT_SYMBOL_GPL(remove_memory);

#endif
#else /* CONFIG_MEMORY_HOTPLUG */
/*
* Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
* just online the pages.
*/
int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
{
int err = -EIO;
unsigned long pfn;
unsigned long total = 0, mem = 0;
for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) {
if (pfn_valid(pfn)) {
online_page(pfn_to_page(pfn));
err = 0;
mem++;
}
total++;
}
if (!err) {
z->spanned_pages += total;
z->present_pages += mem;
z->zone_pgdat->node_spanned_pages += total;
z->zone_pgdat->node_present_pages += mem;
}
return err;
}
#endif /* CONFIG_MEMORY_HOTPLUG */

static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
kcore_vsyscall;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ config ACPI_CONTAINER
config ACPI_HOTPLUG_MEMORY
tristate "Memory Hotplug"
depends on ACPI
depends on MEMORY_HOTPLUG || X86_64
depends on MEMORY_HOTPLUG
default n
help
This driver adds supports for ACPI Memory Hotplug. This driver
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/acpi/acpi_memhotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
{
int result, num_enabled = 0;
struct acpi_memory_info *info;
int node = 0;

ACPI_FUNCTION_TRACE("acpi_memory_enable_device");

Expand Down Expand Up @@ -245,7 +246,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
continue;
}

result = add_memory(info->start_addr, info->length);
result = add_memory(node, info->start_addr, info->length);
if (result)
continue;
info->enabled = 1;
Expand Down
4 changes: 3 additions & 1 deletion trunk/drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,13 @@ static ssize_t
memory_probe_store(struct class *class, const char *buf, size_t count)
{
u64 phys_addr;
int nid;
int ret;

phys_addr = simple_strtoull(buf, NULL, 0);

ret = add_memory(phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);
nid = memory_add_physaddr_to_nid(phys_addr);
ret = add_memory(nid, phys_addr, PAGES_PER_SECTION << PAGE_SHIFT);

if (ret)
count = ret;
Expand Down
13 changes: 12 additions & 1 deletion trunk/include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ extern int online_pages(unsigned long, unsigned long);
/* reasonably generic interface to expand the physical pages in a zone */
extern int __add_pages(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages);

#ifdef CONFIG_NUMA
extern int memory_add_physaddr_to_nid(u64 start);
#else
static inline int memory_add_physaddr_to_nid(u64 start)
{
return 0;
}
#endif

#else /* ! CONFIG_MEMORY_HOTPLUG */
/*
* Stub functions for when hotplug is off
Expand Down Expand Up @@ -99,7 +109,8 @@ static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
return -ENOSYS;
}

extern int add_memory(u64 start, u64 size);
extern int add_memory(int nid, u64 start, u64 size);
extern int arch_add_memory(int nid, u64 start, u64 size);
extern int remove_memory(u64 start, u64 size);

#endif /* __LINUX_MEMORY_HOTPLUG_H */
11 changes: 11 additions & 0 deletions trunk/mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,14 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
vm_total_pages = nr_free_pagecache_pages();
return 0;
}

int add_memory(int nid, u64 start, u64 size)
{
int ret;

/* call arch's memory hotadd */
ret = arch_add_memory(nid, start, size);

return ret;
}
EXPORT_SYMBOL_GPL(add_memory);

0 comments on commit efd22c9

Please sign in to comment.