Thread (76 messages) 76 messages, 7 authors, 2021-12-22

Re: [PATCH] mm: fix panic in __alloc_pages

From: Alexey Makhalov <hidden>
Date: 2021-11-08 06:12:20
Also in: lkml, stable

I’m going to send patch v2, with node_online check moved to caller (pcpu_alloc_pages() function)
as was suggested by David. It seems as it is only one place which passes present but offlined
node to alloc-pages_node(). Moving node online check to the caller keeps hot path (alloc_pages)
simple and performant.
quoted hunk ↗ jump to hunk
diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
index 2054c9213c43..c21ff5bb91dc 100644
--- a/mm/percpu-vm.c
+++ b/mm/percpu-vm.c
@@ -84,15 +84,19 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk,
                          gfp_t gfp)
{
      unsigned int cpu, tcpu;
-       int i;
+       int i, nid;

      gfp |= __GFP_HIGHMEM;

      for_each_possible_cpu(cpu) {
+               nid = cpu_to_node(cpu);
+
+               if (nid == NUMA_NO_NODE || !node_online(nid))
+                       nid = numa_mem_id();
              for (i = page_start; i < page_end; i++) {
                      struct page **pagep = &pages[pcpu_page_idx(cpu, i)];

-                       *pagep = alloc_pages_node(cpu_to_node(cpu), gfp, 0);
+                       *pagep = alloc_pages_node(nid, gfp, 0);
                      if (!*pagep)
                              goto err;
              }
Thanks,
—Alexey

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help