diff options
author | Oscar Salvador <osalvador@suse.de> | 2018-10-26 18:07:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-26 19:26:33 -0400 |
commit | 8efe33f40f3e69ac6069ed46666d2d527ddc2c04 (patch) | |
tree | 98625f1326f116dd287dbc4cdd56c24329245e42 | |
parent | cf01f6f5e398a74f00fa9ac490ec98c12e63e4b1 (diff) |
mm/memory_hotplug.c: simplify node_states_check_changes_online
While looking at node_states_check_changes_online, I stumbled upon some
confusing things.
Right after entering the function, we find this:
if (N_MEMORY == N_NORMAL_MEMORY)
zone_last = ZONE_MOVABLE;
This is wrong.
N_MEMORY cannot really be equal to N_NORMAL_MEMORY.
My guess is that this wanted to be something like:
if (N_NORMAL_MEMORY == N_HIGH_MEMORY)
to check if we have CONFIG_HIGHMEM.
Later on, in the CONFIG_HIGHMEM block, we have:
if (N_MEMORY == N_HIGH_MEMORY)
zone_last = ZONE_MOVABLE;
Again, this is wrong, and will never be evaluated to true.
Besides removing these wrong if statements, I simplified the function a
bit.
[osalvador@suse.de: address feedback from Pavel]
Link: http://lkml.kernel.org/r/20180921132634.10103-4-osalvador@techadventures.net
Link: http://lkml.kernel.org/r/20180919100819.25518-5-osalvador@techadventures.net
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mathieu Malaterre <malat@debian.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: <yasu.isimatu@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/memory_hotplug.c | 57 |
1 files changed, 7 insertions, 50 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 561c44761f95..eadd149eb7bc 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
@@ -687,62 +687,19 @@ static void node_states_check_changes_online(unsigned long nr_pages, | |||
687 | struct zone *zone, struct memory_notify *arg) | 687 | struct zone *zone, struct memory_notify *arg) |
688 | { | 688 | { |
689 | int nid = zone_to_nid(zone); | 689 | int nid = zone_to_nid(zone); |
690 | enum zone_type zone_last = ZONE_NORMAL; | ||
691 | 690 | ||
692 | /* | 691 | arg->status_change_nid = -1; |
693 | * If we have HIGHMEM or movable node, node_states[N_NORMAL_MEMORY] | 692 | arg->status_change_nid_normal = -1; |
694 | * contains nodes which have zones of 0...ZONE_NORMAL, | 693 | arg->status_change_nid_high = -1; |
695 | * set zone_last to ZONE_NORMAL. | ||
696 | * | ||
697 | * If we don't have HIGHMEM nor movable node, | ||
698 | * node_states[N_NORMAL_MEMORY] contains nodes which have zones of | ||
699 | * 0...ZONE_MOVABLE, set zone_last to ZONE_MOVABLE. | ||
700 | */ | ||
701 | if (N_MEMORY == N_NORMAL_MEMORY) | ||
702 | zone_last = ZONE_MOVABLE; | ||
703 | 694 | ||
704 | /* | 695 | if (!node_state(nid, N_MEMORY)) |
705 | * if the memory to be online is in a zone of 0...zone_last, and | 696 | arg->status_change_nid = nid; |
706 | * the zones of 0...zone_last don't have memory before online, we will | 697 | if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY)) |
707 | * need to set the node to node_states[N_NORMAL_MEMORY] after | ||
708 | * the memory is online. | ||
709 | */ | ||
710 | if (zone_idx(zone) <= zone_last && !node_state(nid, N_NORMAL_MEMORY)) | ||
711 | arg->status_change_nid_normal = nid; | 698 | arg->status_change_nid_normal = nid; |
712 | else | ||
713 | arg->status_change_nid_normal = -1; | ||
714 | |||
715 | #ifdef CONFIG_HIGHMEM | 699 | #ifdef CONFIG_HIGHMEM |
716 | /* | 700 | if (zone_idx(zone) <= N_HIGH_MEMORY && !node_state(nid, N_HIGH_MEMORY)) |
717 | * If we have movable node, node_states[N_HIGH_MEMORY] | ||
718 | * contains nodes which have zones of 0...ZONE_HIGHMEM, | ||
719 | * set zone_last to ZONE_HIGHMEM. | ||
720 | * | ||
721 | * If we don't have movable node, node_states[N_NORMAL_MEMORY] | ||
722 | * contains nodes which have zones of 0...ZONE_MOVABLE, | ||
723 | * set zone_last to ZONE_MOVABLE. | ||
724 | */ | ||
725 | zone_last = ZONE_HIGHMEM; | ||
726 | if (N_MEMORY == N_HIGH_MEMORY) | ||
727 | zone_last = ZONE_MOVABLE; | ||
728 | |||
729 | if (zone_idx(zone) <= zone_last && !node_state(nid, N_HIGH_MEMORY)) | ||
730 | arg->status_change_nid_high = nid; | 701 | arg->status_change_nid_high = nid; |
731 | else | ||
732 | arg->status_change_nid_high = -1; | ||
733 | #else | ||
734 | arg->status_change_nid_high = arg->status_change_nid_normal; | ||
735 | #endif | 702 | #endif |
736 | |||
737 | /* | ||
738 | * if the node don't have memory befor online, we will need to | ||
739 | * set the node to node_states[N_MEMORY] after the memory | ||
740 | * is online. | ||
741 | */ | ||
742 | if (!node_state(nid, N_MEMORY)) | ||
743 | arg->status_change_nid = nid; | ||
744 | else | ||
745 | arg->status_change_nid = -1; | ||
746 | } | 703 | } |
747 | 704 | ||
748 | static void node_states_set_node(int node, struct memory_notify *arg) | 705 | static void node_states_set_node(int node, struct memory_notify *arg) |