mm: teach mm by current context info to not do I/O during memory allocation
[~shefty/rdma-dev.git] / mm / page_alloc.c
index e3fb290194c0a006853455a8549965d9b75b1160..3ede25e6686e0e7f7dbf7816740ba67abdb97710 100644 (file)
@@ -2624,10 +2624,17 @@ retry_cpuset:
        page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
                        zonelist, high_zoneidx, alloc_flags,
                        preferred_zone, migratetype);
-       if (unlikely(!page))
+       if (unlikely(!page)) {
+               /*
+                * Runtime PM, block IO and its error handling path
+                * can deadlock because I/O on the device might not
+                * complete.
+                */
+               gfp_mask = memalloc_noio_flags(gfp_mask);
                page = __alloc_pages_slowpath(gfp_mask, order,
                                zonelist, high_zoneidx, nodemask,
                                preferred_zone, migratetype);
+       }
 
        trace_mm_page_alloc(page, order, gfp_mask, migratetype);