}
 EXPORT_SYMBOL_GPL(generic_online_page);
 
-static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
-                       void *arg)
+static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)
 {
        const unsigned long end_pfn = start_pfn + nr_pages;
        unsigned long pfn;
-       int order;
 
        /*
-        * Online the pages. The callback might decide to keep some pages
-        * PG_reserved (to add them to the buddy later), but we still account
-        * them as being online/belonging to this zone ("present").
+        * Online the pages in MAX_ORDER - 1 aligned chunks. The callback might
+        * decide to not expose all pages to the buddy (e.g., expose them
+        * later). We account all pages as being online and belonging to this
+        * zone ("present").
         */
-       for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) {
-               order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn)));
-               /* __free_pages_core() wants pfns to be aligned to the order */
-               if (WARN_ON_ONCE(!IS_ALIGNED(pfn, 1ul << order)))
-                       order = 0;
-               (*online_page_callback)(pfn_to_page(pfn), order);
-       }
+       for (pfn = start_pfn; pfn < end_pfn; pfn += MAX_ORDER_NR_PAGES)
+               (*online_page_callback)(pfn_to_page(pfn), MAX_ORDER - 1);
 
        /* mark all involved sections as online */
        online_mem_sections(start_pfn, end_pfn);
-
-       *(unsigned long *)arg += nr_pages;
-       return 0;
 }
 
 /* check which state of node_states will be changed when online memory */
                       int online_type, int nid)
 {
        unsigned long flags;
-       unsigned long onlined_pages = 0;
        struct zone *zone;
        int need_zonelists_rebuild = 0;
        int ret;
                setup_zone_pageset(zone);
        }
 
-       ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
-               online_pages_range);
-       if (ret) {
-               /* not a single memory resource was applicable */
-               if (need_zonelists_rebuild)
-                       zone_pcp_reset(zone);
-               goto failed_addition;
-       }
-
-       zone->present_pages += onlined_pages;
+       online_pages_range(pfn, nr_pages);
+       zone->present_pages += nr_pages;
 
        pgdat_resize_lock(zone->zone_pgdat, &flags);
-       zone->zone_pgdat->node_present_pages += onlined_pages;
+       zone->zone_pgdat->node_present_pages += nr_pages;
        pgdat_resize_unlock(zone->zone_pgdat, &flags);
 
        /*