Thread (1 message) 1 message, 1 author, 2021-01-31

Re: [PATCH v8 07/14] mm: honor PF_MEMALLOC_PIN for all movable pages

From: Pavel Tatashin <pasha.tatashin@soleen.com>
Date: 2021-01-31 16:05:14
Also in: linux-doc, linux-mm, lkml

On Sun, Jan 31, 2021 at 8:09 AM Lecopzer Chen [off-list ref] wrote:

Hi,

[...]
quoted
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c93e801a45e9..3f17c73ad582 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3807,16 +3807,13 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask)
      return alloc_flags;
 }

-static inline unsigned int current_alloc_flags(gfp_t gfp_mask,
-                                     unsigned int alloc_flags)
+/* Must be called after current_gfp_context() which can change gfp_mask */
+static inline unsigned int gpf_to_alloc_flags(gfp_t gfp_mask,
+                                           unsigned int alloc_flags)
 {
 #ifdef CONFIG_CMA
-     unsigned int pflags = current->flags;
-
-     if (!(pflags & PF_MEMALLOC_PIN) &&
-         gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE)
+     if (gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE)
              alloc_flags |= ALLOC_CMA;
-
 #endif
      return alloc_flags;
 }
@@ -4472,7 +4469,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
      } else if (unlikely(rt_task(current)) && !in_interrupt())
              alloc_flags |= ALLOC_HARDER;

-     alloc_flags = current_alloc_flags(gfp_mask, alloc_flags);
+     alloc_flags = gpf_to_alloc_flags(gfp_mask, alloc_flags);

      return alloc_flags;
 }
@@ -4774,7 +4771,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,

      reserve_flags = __gfp_pfmemalloc_flags(gfp_mask);
      if (reserve_flags)
-             alloc_flags = current_alloc_flags(gfp_mask, reserve_flags);
+             alloc_flags = gpf_to_alloc_flags(gfp_mask, reserve_flags);

      /*
       * Reset the nodemask and zonelist iterators if memory policies can be
@@ -4943,7 +4940,7 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
      if (should_fail_alloc_page(gfp_mask, order))
              return false;

-     *alloc_flags = current_alloc_flags(gfp_mask, *alloc_flags);
+     *alloc_flags = gpf_to_alloc_flags(gfp_mask, *alloc_flags);
I have a question, what is the abbreviation of "gpf" in the function
name gpf_to_alloc_flags()?

It seems that this function still use gfp_mask, is this supposed
to be gfp (Get Free Page)?
Thank you for noticing this, it was accidental, I will rename the
function gpf_to_alloc_flags() -> gfp_to_alloc_flags()
Thanks,
Lecopzer
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help