mm/page_alloc.c: __perform_reclaim should return 'unsigned long'
[linux-block.git] / mm / page_alloc.c
index 316fff2780c0f2e8bc4c8cc49811d77e8d7391e0..a105c657be379a3d0f435a2915eb6487d237e04b 100644 (file)
@@ -156,16 +156,16 @@ static int __init early_init_on_alloc(char *buf)
        int ret;
        bool bool_result;
 
-       if (!buf)
-               return -EINVAL;
        ret = kstrtobool(buf, &bool_result);
+       if (ret)
+               return ret;
        if (bool_result && page_poisoning_enabled())
                pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, will take precedence over init_on_alloc\n");
        if (bool_result)
                static_branch_enable(&init_on_alloc);
        else
                static_branch_disable(&init_on_alloc);
-       return ret;
+       return 0;
 }
 early_param("init_on_alloc", early_init_on_alloc);
 
@@ -174,16 +174,16 @@ static int __init early_init_on_free(char *buf)
        int ret;
        bool bool_result;
 
-       if (!buf)
-               return -EINVAL;
        ret = kstrtobool(buf, &bool_result);
+       if (ret)
+               return ret;
        if (bool_result && page_poisoning_enabled())
                pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, will take precedence over init_on_free\n");
        if (bool_result)
                static_branch_enable(&init_on_free);
        else
                static_branch_disable(&init_on_free);
-       return ret;
+       return 0;
 }
 early_param("init_on_free", early_init_on_free);
 
@@ -3986,8 +3986,10 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
         * success so it is time to admit defeat. We will skip the OOM killer
         * because it is very likely that the caller has a more reasonable
         * fallback than shooting a random task.
+        *
+        * The OOM killer may not free memory on a specific node.
         */
-       if (gfp_mask & __GFP_RETRY_MAYFAIL)
+       if (gfp_mask & (__GFP_RETRY_MAYFAIL | __GFP_THISNODE))
                goto out;
        /* The OOM killer does not needlessly kill tasks for lowmem */
        if (ac->highest_zoneidx < ZONE_NORMAL)
@@ -4004,10 +4006,6 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
         * failures more gracefully we should just bail out here.
         */
 
-       /* The OOM killer may not free memory on a specific node */
-       if (gfp_mask & __GFP_THISNODE)
-               goto out;
-
        /* Exhausted what can be done so it's blame time */
        if (out_of_memory(&oc) || WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
                *did_some_progress = 1;
@@ -4255,13 +4253,12 @@ EXPORT_SYMBOL_GPL(fs_reclaim_release);
 #endif
 
 /* Perform direct synchronous page reclaim */
-static int
+static unsigned long
 __perform_reclaim(gfp_t gfp_mask, unsigned int order,
                                        const struct alloc_context *ac)
 {
-       int progress;
        unsigned int noreclaim_flag;
-       unsigned long pflags;
+       unsigned long pflags, progress;
 
        cond_resched();
 
@@ -4840,12 +4837,6 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
 
        *alloc_flags = current_alloc_flags(gfp_mask, *alloc_flags);
 
-       return true;
-}
-
-/* Determine whether to spread dirty pages and what the first usable zone */
-static inline void finalise_ac(gfp_t gfp_mask, struct alloc_context *ac)
-{
        /* Dirty zone balancing only done in the fast path */
        ac->spread_dirty_pages = (gfp_mask & __GFP_WRITE);
 
@@ -4856,6 +4847,8 @@ static inline void finalise_ac(gfp_t gfp_mask, struct alloc_context *ac)
         */
        ac->preferred_zoneref = first_zones_zonelist(ac->zonelist,
                                        ac->highest_zoneidx, ac->nodemask);
+
+       return true;
 }
 
 /*
@@ -4884,8 +4877,6 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
        if (!prepare_alloc_pages(gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))
                return NULL;
 
-       finalise_ac(gfp_mask, &ac);
-
        /*
         * Forbid the first pass from falling back to types that fragment
         * memory until all local zones are considered.