]> Git Repo - linux.git/blobdiff - mm/mempolicy.c
block: Prevent deadlocks when switching elevators
[linux.git] / mm / mempolicy.c
index aec756ae56377996e41e41e06b8659023dab1c9e..327a19b0883dbb8ba7b4fc19a0ea33033e4d336e 100644 (file)
@@ -624,7 +624,7 @@ static int queue_folios_hugetlb(pte_t *pte, unsigned long hmask,
        pte_t entry;
 
        ptl = huge_pte_lock(hstate_vma(walk->vma), walk->mm, pte);
-       entry = huge_ptep_get(pte);
+       entry = huge_ptep_get(walk->mm, addr, pte);
        if (!pte_present(entry)) {
                if (unlikely(is_hugetlb_entry_migration(entry)))
                        qp->nr_failed++;
@@ -1211,7 +1211,6 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src,
        struct migration_mpol *mmpol = (struct migration_mpol *)private;
        struct mempolicy *pol = mmpol->pol;
        pgoff_t ilx = mmpol->ilx;
-       struct page *page;
        unsigned int order;
        int nid = numa_node_id();
        gfp_t gfp;
@@ -1235,8 +1234,7 @@ static struct folio *alloc_migration_target_by_mpol(struct folio *src,
        else
                gfp = GFP_HIGHUSER_MOVABLE | __GFP_RETRY_MAYFAIL | __GFP_COMP;
 
-       page = alloc_pages_mpol(gfp, order, pol, ilx, nid);
-       return page_rmappable_folio(page);
+       return folio_alloc_mpol(gfp, order, pol, ilx, nid);
 }
 #else
 
@@ -2277,6 +2275,13 @@ struct page *alloc_pages_mpol_noprof(gfp_t gfp, unsigned int order,
        return page;
 }
 
+struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int order,
+               struct mempolicy *pol, pgoff_t ilx, int nid)
+{
+       return page_rmappable_folio(alloc_pages_mpol_noprof(gfp | __GFP_COMP,
+                                                       order, pol, ilx, nid));
+}
+
 /**
  * vma_alloc_folio - Allocate a folio for a VMA.
  * @gfp: GFP flags.
@@ -2298,13 +2303,12 @@ struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order, struct vm_area_struct
 {
        struct mempolicy *pol;
        pgoff_t ilx;
-       struct page *page;
+       struct folio *folio;
 
        pol = get_vma_policy(vma, addr, order, &ilx);
-       page = alloc_pages_mpol_noprof(gfp | __GFP_COMP, order,
-                                      pol, ilx, numa_node_id());
+       folio = folio_alloc_mpol_noprof(gfp, order, pol, ilx, numa_node_id());
        mpol_cond_put(pol);
-       return page_rmappable_folio(page);
+       return folio;
 }
 EXPORT_SYMBOL(vma_alloc_folio_noprof);
 
@@ -3293,8 +3297,9 @@ out:
  * @pol:  pointer to mempolicy to be formatted
  *
  * Convert @pol into a string.  If @buffer is too short, truncate the string.
- * Recommend a @maxlen of at least 32 for the longest mode, "interleave", the
- * longest flag, "relative", and to display at least a few node ids.
+ * Recommend a @maxlen of at least 51 for the longest mode, "weighted
+ * interleave", plus the longest flag flags, "relative|balancing", and to
+ * display at least a few node ids.
  */
 void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
 {
@@ -3303,7 +3308,10 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
        unsigned short mode = MPOL_DEFAULT;
        unsigned short flags = 0;
 
-       if (pol && pol != &default_policy && !(pol->flags & MPOL_F_MORON)) {
+       if (pol &&
+           pol != &default_policy &&
+           !(pol >= &preferred_node_policy[0] &&
+             pol <= &preferred_node_policy[ARRAY_SIZE(preferred_node_policy) - 1])) {
                mode = pol->mode;
                flags = pol->flags;
        }
@@ -3331,12 +3339,18 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
                p += snprintf(p, buffer + maxlen - p, "=");
 
                /*
-                * Currently, the only defined flags are mutually exclusive
+                * Static and relative are mutually exclusive.
                 */
                if (flags & MPOL_F_STATIC_NODES)
                        p += snprintf(p, buffer + maxlen - p, "static");
                else if (flags & MPOL_F_RELATIVE_NODES)
                        p += snprintf(p, buffer + maxlen - p, "relative");
+
+               if (flags & MPOL_F_NUMA_BALANCING) {
+                       if (!is_power_of_2(flags & MPOL_MODE_FLAGS))
+                               p += snprintf(p, buffer + maxlen - p, "|");
+                       p += snprintf(p, buffer + maxlen - p, "balancing");
+               }
        }
 
        if (!nodes_empty(nodes))
This page took 0.037459 seconds and 4 git commands to generate.