Skip to content

Commit

Permalink
mm/memory_hotplug: convert memhp_auto_online to store an online_type
Browse files Browse the repository at this point in the history
...  and rename it to memhp_default_online_type.  This is a preparation
for more detailed default online behavior.

Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Baoquan He <bhe@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Yumei Huang <yuhuang@redhat.com>
Link: http://lkml.kernel.org/r/20200317104942.11178-8-david@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Hildenbrand authored and Linus Torvalds committed Apr 7, 2020
1 parent 5a04af1 commit 862919e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 4 additions & 6 deletions drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,18 @@ static DEVICE_ATTR_RO(block_size_bytes);
static ssize_t auto_online_blocks_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
if (memhp_auto_online)
return sprintf(buf, "online\n");
else
return sprintf(buf, "offline\n");
return sprintf(buf, "%s\n",
online_type_to_str[memhp_default_online_type]);
}

static ssize_t auto_online_blocks_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
if (sysfs_streq(buf, "online"))
memhp_auto_online = true;
memhp_default_online_type = MMOP_ONLINE;
else if (sysfs_streq(buf, "offline"))
memhp_auto_online = false;
memhp_default_online_type = MMOP_OFFLINE;
else
return -EINVAL;

Expand Down
3 changes: 2 additions & 1 deletion include/linux/memory_hotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ extern int arch_add_memory(int nid, u64 start, u64 size,
struct mhp_restrictions *restrictions);
extern u64 max_mem_size;

extern bool memhp_auto_online;
/* Default online_type (MMOP_*) when new memory blocks are added. */
extern int memhp_default_online_type;
/* If movable_node boot option specified */
extern bool movable_node_enabled;
static inline bool movable_node_is_enabled(void)
Expand Down
11 changes: 6 additions & 5 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ void put_online_mems(void)
bool movable_node_enabled = false;

#ifndef CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE
bool memhp_auto_online;
int memhp_default_online_type = MMOP_OFFLINE;
#else
bool memhp_auto_online = true;
int memhp_default_online_type = MMOP_ONLINE;
#endif

static int __init setup_memhp_default_state(char *str)
{
if (!strcmp(str, "online"))
memhp_auto_online = true;
memhp_default_online_type = MMOP_ONLINE;
else if (!strcmp(str, "offline"))
memhp_auto_online = false;
memhp_default_online_type = MMOP_OFFLINE;

return 1;
}
Expand Down Expand Up @@ -990,6 +990,7 @@ static int check_hotplug_memory_range(u64 start, u64 size)

static int online_memory_block(struct memory_block *mem, void *arg)
{
mem->online_type = memhp_default_online_type;
return device_online(&mem->dev);
}

Expand Down Expand Up @@ -1062,7 +1063,7 @@ int __ref add_memory_resource(int nid, struct resource *res)
mem_hotplug_done();

/* online pages if requested */
if (memhp_auto_online)
if (memhp_default_online_type != MMOP_OFFLINE)
walk_memory_blocks(start, size, NULL, online_memory_block);

return ret;
Expand Down

0 comments on commit 862919e

Please sign in to comment.