From 2cc1d4d00301bf5216ddc371279e08d208f99643 Mon Sep 17 00:00:00 2001 From: Robin Holt Date: Wed, 29 Sep 2010 14:00:55 -0500 Subject: [PATCH] --- yaml --- r: 213471 b: refs/heads/master c: 98383031ed77c6eb49ab612166fef9c0efe1604a h: refs/heads/master i: 213469: f15d6d394db542bb5d952849d3cbcbefeb4faaad 213467: dacc793016874e691763b0fda46daaa95d982371 213463: 03498f915815431f1062c0594e52d2c43b3fdef5 213455: 079bfbe6d4d1c3c075da0f25be7059ffccded6fd 213439: 5ef7ec31a9a7f9a37cb2ee667b8946c54304ba6b v: v3 --- [refs] | 2 +- trunk/drivers/base/memory.c | 28 ++++++++++++++++++---------- trunk/include/linux/memory.h | 2 ++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 0a0ae276c74c..03313167e196 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c25d1dfbd403209025df41a737f82ce8f43d93f5 +refs/heads/master: 98383031ed77c6eb49ab612166fef9c0efe1604a diff --git a/trunk/drivers/base/memory.c b/trunk/drivers/base/memory.c index 933442f40321..a7994409b9a5 100644 --- a/trunk/drivers/base/memory.c +++ b/trunk/drivers/base/memory.c @@ -468,28 +468,23 @@ static int add_memory_block(int nid, struct mem_section *section, return ret; } -/* - * For now, we have a linear search to go find the appropriate - * memory_block corresponding to a particular phys_index. If - * this gets to be a real problem, we can always use a radix - * tree or something here. - * - * This could be made generic for all sysdev classes. - */ -struct memory_block *find_memory_block(struct mem_section *section) +struct memory_block *find_memory_block_hinted(struct mem_section *section, + struct memory_block *hint) { struct kobject *kobj; struct sys_device *sysdev; struct memory_block *mem; char name[sizeof(MEMORY_CLASS_NAME) + 9 + 1]; + kobj = hint ? &hint->sysdev.kobj : NULL; + /* * This only works because we know that section == sysdev->id * slightly redundant with sysdev_register() */ sprintf(&name[0], "%s%d", MEMORY_CLASS_NAME, __section_nr(section)); - kobj = kset_find_obj(&memory_sysdev_class.kset, name); + kobj = kset_find_obj_hinted(&memory_sysdev_class.kset, name, kobj); if (!kobj) return NULL; @@ -499,6 +494,19 @@ struct memory_block *find_memory_block(struct mem_section *section) return mem; } +/* + * For now, we have a linear search to go find the appropriate + * memory_block corresponding to a particular phys_index. If + * this gets to be a real problem, we can always use a radix + * tree or something here. + * + * This could be made generic for all sysdev classes. + */ +struct memory_block *find_memory_block(struct mem_section *section) +{ + return find_memory_block_hinted(section, NULL); +} + int remove_memory_block(unsigned long node_id, struct mem_section *section, int phys_device) { diff --git a/trunk/include/linux/memory.h b/trunk/include/linux/memory.h index 85582e1bcee9..c4f3127dbd48 100644 --- a/trunk/include/linux/memory.h +++ b/trunk/include/linux/memory.h @@ -113,6 +113,8 @@ extern int memory_dev_init(void); extern int remove_memory_block(unsigned long, struct mem_section *, int); extern int memory_notify(unsigned long val, void *v); extern int memory_isolate_notify(unsigned long val, void *v); +extern struct memory_block *find_memory_block_hinted(struct mem_section *, + struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<