提交 260ae3f7 编写于 作者: D Dan Williams 提交者: Linus Torvalds

mm: skip memory block registration for ZONE_DEVICE

Prevent userspace from trying and failing to online ZONE_DEVICE pages
which are meant to never be onlined.

For example on platforms with a udev rule like the following:

  SUBSYSTEM=="memory", ACTION=="add", ATTR{state}=="offline", ATTR{state}="online"

...will generate futile attempts to online the ZONE_DEVICE sections.
Example kernel messages:

    Built 1 zonelists in Node order, mobility grouping on.  Total pages: 1004747
    Policy zone: Normal
    online_pages [mem 0x248000000-0x24fffffff] failed
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 34c0fd54
...@@ -647,6 +647,13 @@ static int add_memory_block(int base_section_nr) ...@@ -647,6 +647,13 @@ static int add_memory_block(int base_section_nr)
return 0; return 0;
} }
static bool is_zone_device_section(struct mem_section *ms)
{
struct page *page;
page = sparse_decode_mem_map(ms->section_mem_map, __section_nr(ms));
return is_zone_device_page(page);
}
/* /*
* need an interface for the VM to add new memory regions, * need an interface for the VM to add new memory regions,
...@@ -657,6 +664,9 @@ int register_new_memory(int nid, struct mem_section *section) ...@@ -657,6 +664,9 @@ int register_new_memory(int nid, struct mem_section *section)
int ret = 0; int ret = 0;
struct memory_block *mem; struct memory_block *mem;
if (is_zone_device_section(section))
return 0;
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
mem = find_memory_block(section); mem = find_memory_block(section);
...@@ -693,6 +703,9 @@ static int remove_memory_section(unsigned long node_id, ...@@ -693,6 +703,9 @@ static int remove_memory_section(unsigned long node_id,
{ {
struct memory_block *mem; struct memory_block *mem;
if (is_zone_device_section(section))
return 0;
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
mem = find_memory_block(section); mem = find_memory_block(section);
unregister_mem_sect_under_nodes(mem, __section_nr(section)); unregister_mem_sect_under_nodes(mem, __section_nr(section));
......
...@@ -674,6 +674,18 @@ static inline enum zone_type page_zonenum(const struct page *page) ...@@ -674,6 +674,18 @@ static inline enum zone_type page_zonenum(const struct page *page)
return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
} }
#ifdef CONFIG_ZONE_DEVICE
static inline bool is_zone_device_page(const struct page *page)
{
return page_zonenum(page) == ZONE_DEVICE;
}
#else
static inline bool is_zone_device_page(const struct page *page)
{
return false;
}
#endif
#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
#define SECTION_IN_PAGE_FLAGS #define SECTION_IN_PAGE_FLAGS
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册