mm, memory_hotplug: drop artificial restriction on online/offline
[platform/kernel/linux-starfive.git] / mm / memory_hotplug.c
index 9ac997b..9373198 100644 (file)
@@ -759,23 +759,6 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
        return 0;
 }
 
-#ifdef CONFIG_MOVABLE_NODE
-/*
- * When CONFIG_MOVABLE_NODE, we permit onlining of a node which doesn't have
- * normal memory.
- */
-static bool can_online_high_movable(int nid)
-{
-       return true;
-}
-#else /* CONFIG_MOVABLE_NODE */
-/* ensure every online node has NORMAL memory */
-static bool can_online_high_movable(int nid)
-{
-       return node_state(nid, N_NORMAL_MEMORY);
-}
-#endif /* CONFIG_MOVABLE_NODE */
-
 /* check which state of node_states will be changed when online memory */
 static void node_states_check_changes_online(unsigned long nr_pages,
        struct zone *zone, struct memory_notify *arg)
@@ -992,9 +975,6 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
        if (!allow_online_pfn_range(nid, pfn, nr_pages, online_type))
                return -EINVAL;
 
-       if (online_type == MMOP_ONLINE_MOVABLE && !can_online_high_movable(nid))
-               return -EINVAL;
-
        /* associate pfn range with the zone */
        zone = move_pfn_range(online_type, nid, pfn, nr_pages);
 
@@ -1590,41 +1570,6 @@ check_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
        return offlined;
 }
 
-#ifdef CONFIG_MOVABLE_NODE
-/*
- * When CONFIG_MOVABLE_NODE, we permit offlining of a node which doesn't have
- * normal memory.
- */
-static bool can_offline_normal(struct zone *zone, unsigned long nr_pages)
-{
-       return true;
-}
-#else /* CONFIG_MOVABLE_NODE */
-/* ensure the node has NORMAL memory if it is still online */
-static bool can_offline_normal(struct zone *zone, unsigned long nr_pages)
-{
-       struct pglist_data *pgdat = zone->zone_pgdat;
-       unsigned long present_pages = 0;
-       enum zone_type zt;
-
-       for (zt = 0; zt <= ZONE_NORMAL; zt++)
-               present_pages += pgdat->node_zones[zt].present_pages;
-
-       if (present_pages > nr_pages)
-               return true;
-
-       present_pages = 0;
-       for (; zt <= ZONE_MOVABLE; zt++)
-               present_pages += pgdat->node_zones[zt].present_pages;
-
-       /*
-        * we can't offline the last normal memory until all
-        * higher memory is offlined.
-        */
-       return present_pages == 0;
-}
-#endif /* CONFIG_MOVABLE_NODE */
-
 static int __init cmdline_parse_movable_node(char *p)
 {
 #ifdef CONFIG_MOVABLE_NODE
@@ -1752,9 +1697,6 @@ static int __ref __offline_pages(unsigned long start_pfn,
        node = zone_to_nid(zone);
        nr_pages = end_pfn - start_pfn;
 
-       if (zone_idx(zone) <= ZONE_NORMAL && !can_offline_normal(zone, nr_pages))
-               return -EINVAL;
-
        /* set above range as isolated */
        ret = start_isolate_page_range(start_pfn, end_pfn,
                                       MIGRATE_MOVABLE, true);