Merge tag 'v3.3-rc7' into x86/mce
authorIngo Molnar <mingo@elte.hu>
Wed, 14 Mar 2012 06:44:11 +0000 (07:44 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 14 Mar 2012 06:44:11 +0000 (07:44 +0100)
Merge reason: Update from an ancient -rc1 base to an almost-final stable kernel.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
1  2 
drivers/base/memory.c

diff --combined drivers/base/memory.c
index 9b3a71e391f4412b619db7b4094aecc8c0f0d6ec,9e60dbe9fd94884cb5850f10af74567a9bc6300f..7dda4f790f00d58145cc3b58ce4607c42ea829b1
@@@ -466,7 -466,7 +466,7 @@@ store_hard_offline_page(struct device *
        if (strict_strtoull(buf, 0, &pfn) < 0)
                return -EINVAL;
        pfn >>= PAGE_SHIFT;
 -      ret = __memory_failure(pfn, 0, 0);
 +      ret = memory_failure(pfn, 0, 0);
        return ret ? ret : count;
  }
  
@@@ -572,19 -572,36 +572,36 @@@ static int init_memory_block(struct mem
  }
  
  static int add_memory_section(int nid, struct mem_section *section,
+                       struct memory_block **mem_p,
                        unsigned long state, enum mem_add_context context)
  {
-       struct memory_block *mem;
+       struct memory_block *mem = NULL;
+       int scn_nr = __section_nr(section);
        int ret = 0;
  
        mutex_lock(&mem_sysfs_mutex);
  
-       mem = find_memory_block(section);
+       if (context == BOOT) {
+               /* same memory block ? */
+               if (mem_p && *mem_p)
+                       if (scn_nr >= (*mem_p)->start_section_nr &&
+                           scn_nr <= (*mem_p)->end_section_nr) {
+                               mem = *mem_p;
+                               kobject_get(&mem->dev.kobj);
+                       }
+       } else
+               mem = find_memory_block(section);
        if (mem) {
                mem->section_count++;
                kobject_put(&mem->dev.kobj);
-       } else
+       } else {
                ret = init_memory_block(&mem, section, state);
+               /* store memory_block pointer for next loop */
+               if (!ret && context == BOOT)
+                       if (mem_p)
+                               *mem_p = mem;
+       }
  
        if (!ret) {
                if (context == HOTPLUG &&
@@@ -627,7 -644,7 +644,7 @@@ int remove_memory_block(unsigned long n
   */
  int register_new_memory(int nid, struct mem_section *section)
  {
-       return add_memory_section(nid, section, MEM_OFFLINE, HOTPLUG);
+       return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
  }
  
  int unregister_memory_section(struct mem_section *section)
@@@ -647,6 -664,7 +664,7 @@@ int __init memory_dev_init(void
        int ret;
        int err;
        unsigned long block_sz;
+       struct memory_block *mem = NULL;
  
        ret = subsys_system_register(&memory_subsys, NULL);
        if (ret)
        for (i = 0; i < NR_MEM_SECTIONS; i++) {
                if (!present_section_nr(i))
                        continue;
-               err = add_memory_section(0, __nr_to_section(i), MEM_ONLINE,
+               /* don't need to reuse memory_block if only one per block */
+               err = add_memory_section(0, __nr_to_section(i),
+                                (sections_per_block == 1) ? NULL : &mem,
+                                        MEM_ONLINE,
                                         BOOT);
                if (!ret)
                        ret = err;