1 // SPDX-License-Identifier: GPL-2.0
3 * sparse memory mappings.
6 #include <linux/slab.h>
7 #include <linux/mmzone.h>
8 #include <linux/memblock.h>
9 #include <linux/compiler.h>
10 #include <linux/highmem.h>
11 #include <linux/export.h>
12 #include <linux/spinlock.h>
13 #include <linux/vmalloc.h>
17 #include <asm/pgalloc.h>
18 #include <asm/pgtable.h>
21 * Permanent SPARSEMEM data:
23 * 1) mem_section - memory sections, mem_map's for valid memory
25 #ifdef CONFIG_SPARSEMEM_EXTREME
26 struct mem_section
**mem_section
;
28 struct mem_section mem_section
[NR_SECTION_ROOTS
][SECTIONS_PER_ROOT
]
29 ____cacheline_internodealigned_in_smp
;
31 EXPORT_SYMBOL(mem_section
);
33 #ifdef NODE_NOT_IN_PAGE_FLAGS
35 * If we did not store the node number in the page then we have to
36 * do a lookup in the section_to_node_table in order to find which
37 * node the page belongs to.
39 #if MAX_NUMNODES <= 256
40 static u8 section_to_node_table
[NR_MEM_SECTIONS
] __cacheline_aligned
;
42 static u16 section_to_node_table
[NR_MEM_SECTIONS
] __cacheline_aligned
;
45 int page_to_nid(const struct page
*page
)
47 return section_to_node_table
[page_to_section(page
)];
49 EXPORT_SYMBOL(page_to_nid
);
51 static void set_section_nid(unsigned long section_nr
, int nid
)
53 section_to_node_table
[section_nr
] = nid
;
55 #else /* !NODE_NOT_IN_PAGE_FLAGS */
56 static inline void set_section_nid(unsigned long section_nr
, int nid
)
61 #ifdef CONFIG_SPARSEMEM_EXTREME
62 static noinline
struct mem_section __ref
*sparse_index_alloc(int nid
)
64 struct mem_section
*section
= NULL
;
65 unsigned long array_size
= SECTIONS_PER_ROOT
*
66 sizeof(struct mem_section
);
68 if (slab_is_available()) {
69 section
= kzalloc_node(array_size
, GFP_KERNEL
, nid
);
71 section
= memblock_alloc_node(array_size
, SMP_CACHE_BYTES
,
74 panic("%s: Failed to allocate %lu bytes nid=%d\n",
75 __func__
, array_size
, nid
);
81 static int __meminit
sparse_index_init(unsigned long section_nr
, int nid
)
83 unsigned long root
= SECTION_NR_TO_ROOT(section_nr
);
84 struct mem_section
*section
;
86 if (mem_section
[root
])
89 section
= sparse_index_alloc(nid
);
93 mem_section
[root
] = section
;
97 #else /* !SPARSEMEM_EXTREME */
98 static inline int sparse_index_init(unsigned long section_nr
, int nid
)
104 #ifdef CONFIG_SPARSEMEM_EXTREME
105 unsigned long __section_nr(struct mem_section
*ms
)
107 unsigned long root_nr
;
108 struct mem_section
*root
= NULL
;
110 for (root_nr
= 0; root_nr
< NR_SECTION_ROOTS
; root_nr
++) {
111 root
= __nr_to_section(root_nr
* SECTIONS_PER_ROOT
);
115 if ((ms
>= root
) && (ms
< (root
+ SECTIONS_PER_ROOT
)))
121 return (root_nr
* SECTIONS_PER_ROOT
) + (ms
- root
);
124 unsigned long __section_nr(struct mem_section
*ms
)
126 return (unsigned long)(ms
- mem_section
[0]);
131 * During early boot, before section_mem_map is used for an actual
132 * mem_map, we use section_mem_map to store the section's NUMA
133 * node. This keeps us from having to use another data structure. The
134 * node information is cleared just before we store the real mem_map.
136 static inline unsigned long sparse_encode_early_nid(int nid
)
138 return (nid
<< SECTION_NID_SHIFT
);
141 static inline int sparse_early_nid(struct mem_section
*section
)
143 return (section
->section_mem_map
>> SECTION_NID_SHIFT
);
146 /* Validate the physical addressing limitations of the model */
147 void __meminit
mminit_validate_memmodel_limits(unsigned long *start_pfn
,
148 unsigned long *end_pfn
)
150 unsigned long max_sparsemem_pfn
= 1UL << (MAX_PHYSMEM_BITS
-PAGE_SHIFT
);
153 * Sanity checks - do not allow an architecture to pass
154 * in larger pfns than the maximum scope of sparsemem:
156 if (*start_pfn
> max_sparsemem_pfn
) {
157 mminit_dprintk(MMINIT_WARNING
, "pfnvalidation",
158 "Start of range %lu -> %lu exceeds SPARSEMEM max %lu\n",
159 *start_pfn
, *end_pfn
, max_sparsemem_pfn
);
161 *start_pfn
= max_sparsemem_pfn
;
162 *end_pfn
= max_sparsemem_pfn
;
163 } else if (*end_pfn
> max_sparsemem_pfn
) {
164 mminit_dprintk(MMINIT_WARNING
, "pfnvalidation",
165 "End of range %lu -> %lu exceeds SPARSEMEM max %lu\n",
166 *start_pfn
, *end_pfn
, max_sparsemem_pfn
);
168 *end_pfn
= max_sparsemem_pfn
;
173 * There are a number of times that we loop over NR_MEM_SECTIONS,
174 * looking for section_present() on each. But, when we have very
175 * large physical address spaces, NR_MEM_SECTIONS can also be
176 * very large which makes the loops quite long.
178 * Keeping track of this gives us an easy way to break out of
181 unsigned long __highest_present_section_nr
;
182 static void section_mark_present(struct mem_section
*ms
)
184 unsigned long section_nr
= __section_nr(ms
);
186 if (section_nr
> __highest_present_section_nr
)
187 __highest_present_section_nr
= section_nr
;
189 ms
->section_mem_map
|= SECTION_MARKED_PRESENT
;
192 static inline unsigned long next_present_section_nr(unsigned long section_nr
)
196 if (present_section_nr(section_nr
))
198 } while ((section_nr
<= __highest_present_section_nr
));
202 #define for_each_present_section_nr(start, section_nr) \
203 for (section_nr = next_present_section_nr(start-1); \
204 ((section_nr != -1) && \
205 (section_nr <= __highest_present_section_nr)); \
206 section_nr = next_present_section_nr(section_nr))
208 static inline unsigned long first_present_section_nr(void)
210 return next_present_section_nr(-1);
213 /* Record a memory area against a node. */
214 void __init
memory_present(int nid
, unsigned long start
, unsigned long end
)
218 #ifdef CONFIG_SPARSEMEM_EXTREME
219 if (unlikely(!mem_section
)) {
220 unsigned long size
, align
;
222 size
= sizeof(struct mem_section
*) * NR_SECTION_ROOTS
;
223 align
= 1 << (INTERNODE_CACHE_SHIFT
);
224 mem_section
= memblock_alloc(size
, align
);
226 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
227 __func__
, size
, align
);
231 start
&= PAGE_SECTION_MASK
;
232 mminit_validate_memmodel_limits(&start
, &end
);
233 for (pfn
= start
; pfn
< end
; pfn
+= PAGES_PER_SECTION
) {
234 unsigned long section
= pfn_to_section_nr(pfn
);
235 struct mem_section
*ms
;
237 sparse_index_init(section
, nid
);
238 set_section_nid(section
, nid
);
240 ms
= __nr_to_section(section
);
241 if (!ms
->section_mem_map
) {
242 ms
->section_mem_map
= sparse_encode_early_nid(nid
) |
244 section_mark_present(ms
);
250 * Mark all memblocks as present using memory_present(). This is a
251 * convienence function that is useful for a number of arches
252 * to mark all of the systems memory as present during initialization.
254 void __init
memblocks_present(void)
256 struct memblock_region
*reg
;
258 for_each_memblock(memory
, reg
) {
259 memory_present(memblock_get_region_node(reg
),
260 memblock_region_memory_base_pfn(reg
),
261 memblock_region_memory_end_pfn(reg
));
266 * Subtle, we encode the real pfn into the mem_map such that
267 * the identity pfn - section_mem_map will return the actual
268 * physical page frame number.
270 static unsigned long sparse_encode_mem_map(struct page
*mem_map
, unsigned long pnum
)
272 unsigned long coded_mem_map
=
273 (unsigned long)(mem_map
- (section_nr_to_pfn(pnum
)));
274 BUILD_BUG_ON(SECTION_MAP_LAST_BIT
> (1UL<<PFN_SECTION_SHIFT
));
275 BUG_ON(coded_mem_map
& ~SECTION_MAP_MASK
);
276 return coded_mem_map
;
280 * Decode mem_map from the coded memmap
282 struct page
*sparse_decode_mem_map(unsigned long coded_mem_map
, unsigned long pnum
)
284 /* mask off the extra low bits of information */
285 coded_mem_map
&= SECTION_MAP_MASK
;
286 return ((struct page
*)coded_mem_map
) + section_nr_to_pfn(pnum
);
289 static void __meminit
sparse_init_one_section(struct mem_section
*ms
,
290 unsigned long pnum
, struct page
*mem_map
,
291 struct mem_section_usage
*usage
, unsigned long flags
)
293 ms
->section_mem_map
&= ~SECTION_MAP_MASK
;
294 ms
->section_mem_map
|= sparse_encode_mem_map(mem_map
, pnum
)
295 | SECTION_HAS_MEM_MAP
| flags
;
299 static unsigned long usemap_size(void)
301 return BITS_TO_LONGS(SECTION_BLOCKFLAGS_BITS
) * sizeof(unsigned long);
304 size_t mem_section_usage_size(void)
306 return sizeof(struct mem_section_usage
) + usemap_size();
309 #ifdef CONFIG_MEMORY_HOTREMOVE
310 static struct mem_section_usage
* __init
311 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data
*pgdat
,
314 struct mem_section_usage
*usage
;
315 unsigned long goal
, limit
;
318 * A page may contain usemaps for other sections preventing the
319 * page being freed and making a section unremovable while
320 * other sections referencing the usemap remain active. Similarly,
321 * a pgdat can prevent a section being removed. If section A
322 * contains a pgdat and section B contains the usemap, both
323 * sections become inter-dependent. This allocates usemaps
324 * from the same section as the pgdat where possible to avoid
327 goal
= __pa(pgdat
) & (PAGE_SECTION_MASK
<< PAGE_SHIFT
);
328 limit
= goal
+ (1UL << PA_SECTION_SHIFT
);
329 nid
= early_pfn_to_nid(goal
>> PAGE_SHIFT
);
331 usage
= memblock_alloc_try_nid(size
, SMP_CACHE_BYTES
, goal
, limit
, nid
);
332 if (!usage
&& limit
) {
339 static void __init
check_usemap_section_nr(int nid
,
340 struct mem_section_usage
*usage
)
342 unsigned long usemap_snr
, pgdat_snr
;
343 static unsigned long old_usemap_snr
;
344 static unsigned long old_pgdat_snr
;
345 struct pglist_data
*pgdat
= NODE_DATA(nid
);
349 if (!old_usemap_snr
) {
350 old_usemap_snr
= NR_MEM_SECTIONS
;
351 old_pgdat_snr
= NR_MEM_SECTIONS
;
354 usemap_snr
= pfn_to_section_nr(__pa(usage
) >> PAGE_SHIFT
);
355 pgdat_snr
= pfn_to_section_nr(__pa(pgdat
) >> PAGE_SHIFT
);
356 if (usemap_snr
== pgdat_snr
)
359 if (old_usemap_snr
== usemap_snr
&& old_pgdat_snr
== pgdat_snr
)
360 /* skip redundant message */
363 old_usemap_snr
= usemap_snr
;
364 old_pgdat_snr
= pgdat_snr
;
366 usemap_nid
= sparse_early_nid(__nr_to_section(usemap_snr
));
367 if (usemap_nid
!= nid
) {
368 pr_info("node %d must be removed before remove section %ld\n",
373 * There is a circular dependency.
374 * Some platforms allow un-removable section because they will just
375 * gather other removable sections for dynamic partitioning.
376 * Just notify un-removable section's number here.
378 pr_info("Section %ld and %ld (node %d) have a circular dependency on usemap and pgdat allocations\n",
379 usemap_snr
, pgdat_snr
, nid
);
382 static struct mem_section_usage
* __init
383 sparse_early_usemaps_alloc_pgdat_section(struct pglist_data
*pgdat
,
386 return memblock_alloc_node(size
, SMP_CACHE_BYTES
, pgdat
->node_id
);
389 static void __init
check_usemap_section_nr(int nid
,
390 struct mem_section_usage
*usage
)
393 #endif /* CONFIG_MEMORY_HOTREMOVE */
395 #ifdef CONFIG_SPARSEMEM_VMEMMAP
396 static unsigned long __init
section_map_size(void)
398 return ALIGN(sizeof(struct page
) * PAGES_PER_SECTION
, PMD_SIZE
);
402 static unsigned long __init
section_map_size(void)
404 return PAGE_ALIGN(sizeof(struct page
) * PAGES_PER_SECTION
);
407 struct page __init
*sparse_mem_map_populate(unsigned long pnum
, int nid
,
408 struct vmem_altmap
*altmap
)
410 unsigned long size
= section_map_size();
411 struct page
*map
= sparse_buffer_alloc(size
);
412 phys_addr_t addr
= __pa(MAX_DMA_ADDRESS
);
417 map
= memblock_alloc_try_nid(size
,
419 MEMBLOCK_ALLOC_ACCESSIBLE
, nid
);
421 panic("%s: Failed to allocate %lu bytes align=0x%lx nid=%d from=%pa\n",
422 __func__
, size
, PAGE_SIZE
, nid
, &addr
);
426 #endif /* !CONFIG_SPARSEMEM_VMEMMAP */
428 static void *sparsemap_buf __meminitdata
;
429 static void *sparsemap_buf_end __meminitdata
;
431 static void __init
sparse_buffer_init(unsigned long size
, int nid
)
433 phys_addr_t addr
= __pa(MAX_DMA_ADDRESS
);
434 WARN_ON(sparsemap_buf
); /* forgot to call sparse_buffer_fini()? */
436 memblock_alloc_try_nid_raw(size
, PAGE_SIZE
,
438 MEMBLOCK_ALLOC_ACCESSIBLE
, nid
);
439 sparsemap_buf_end
= sparsemap_buf
+ size
;
442 static void __init
sparse_buffer_fini(void)
444 unsigned long size
= sparsemap_buf_end
- sparsemap_buf
;
446 if (sparsemap_buf
&& size
> 0)
447 memblock_free_early(__pa(sparsemap_buf
), size
);
448 sparsemap_buf
= NULL
;
451 void * __meminit
sparse_buffer_alloc(unsigned long size
)
456 ptr
= PTR_ALIGN(sparsemap_buf
, size
);
457 if (ptr
+ size
> sparsemap_buf_end
)
460 sparsemap_buf
= ptr
+ size
;
465 void __weak __meminit
vmemmap_populate_print_last(void)
470 * Initialize sparse on a specific node. The node spans [pnum_begin, pnum_end)
471 * And number of present sections in this node is map_count.
473 static void __init
sparse_init_nid(int nid
, unsigned long pnum_begin
,
474 unsigned long pnum_end
,
475 unsigned long map_count
)
477 struct mem_section_usage
*usage
;
481 usage
= sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nid
),
482 mem_section_usage_size() * map_count
);
484 pr_err("%s: node[%d] usemap allocation failed", __func__
, nid
);
487 sparse_buffer_init(map_count
* section_map_size(), nid
);
488 for_each_present_section_nr(pnum_begin
, pnum
) {
489 if (pnum
>= pnum_end
)
492 map
= sparse_mem_map_populate(pnum
, nid
, NULL
);
494 pr_err("%s: node[%d] memory map backing failed. Some memory will not be available.",
499 check_usemap_section_nr(nid
, usage
);
500 sparse_init_one_section(__nr_to_section(pnum
), pnum
, map
, usage
,
502 usage
= (void *) usage
+ mem_section_usage_size();
504 sparse_buffer_fini();
507 /* We failed to allocate, mark all the following pnums as not present */
508 for_each_present_section_nr(pnum_begin
, pnum
) {
509 struct mem_section
*ms
;
511 if (pnum
>= pnum_end
)
513 ms
= __nr_to_section(pnum
);
514 ms
->section_mem_map
= 0;
519 * Allocate the accumulated non-linear sections, allocate a mem_map
520 * for each and record the physical to section mapping.
522 void __init
sparse_init(void)
524 unsigned long pnum_begin
= first_present_section_nr();
525 int nid_begin
= sparse_early_nid(__nr_to_section(pnum_begin
));
526 unsigned long pnum_end
, map_count
= 1;
528 /* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
529 set_pageblock_order();
531 for_each_present_section_nr(pnum_begin
+ 1, pnum_end
) {
532 int nid
= sparse_early_nid(__nr_to_section(pnum_end
));
534 if (nid
== nid_begin
) {
538 /* Init node with sections in range [pnum_begin, pnum_end) */
539 sparse_init_nid(nid_begin
, pnum_begin
, pnum_end
, map_count
);
541 pnum_begin
= pnum_end
;
544 /* cover the last node */
545 sparse_init_nid(nid_begin
, pnum_begin
, pnum_end
, map_count
);
546 vmemmap_populate_print_last();
549 #ifdef CONFIG_MEMORY_HOTPLUG
551 /* Mark all memory sections within the pfn range as online */
552 void online_mem_sections(unsigned long start_pfn
, unsigned long end_pfn
)
556 for (pfn
= start_pfn
; pfn
< end_pfn
; pfn
+= PAGES_PER_SECTION
) {
557 unsigned long section_nr
= pfn_to_section_nr(pfn
);
558 struct mem_section
*ms
;
560 /* onlining code should never touch invalid ranges */
561 if (WARN_ON(!valid_section_nr(section_nr
)))
564 ms
= __nr_to_section(section_nr
);
565 ms
->section_mem_map
|= SECTION_IS_ONLINE
;
569 #ifdef CONFIG_MEMORY_HOTREMOVE
570 /* Mark all memory sections within the pfn range as offline */
571 void offline_mem_sections(unsigned long start_pfn
, unsigned long end_pfn
)
575 for (pfn
= start_pfn
; pfn
< end_pfn
; pfn
+= PAGES_PER_SECTION
) {
576 unsigned long section_nr
= pfn_to_section_nr(pfn
);
577 struct mem_section
*ms
;
580 * TODO this needs some double checking. Offlining code makes
581 * sure to check pfn_valid but those checks might be just bogus
583 if (WARN_ON(!valid_section_nr(section_nr
)))
586 ms
= __nr_to_section(section_nr
);
587 ms
->section_mem_map
&= ~SECTION_IS_ONLINE
;
592 #ifdef CONFIG_SPARSEMEM_VMEMMAP
593 static inline struct page
*kmalloc_section_memmap(unsigned long pnum
, int nid
,
594 struct vmem_altmap
*altmap
)
596 /* This will make the necessary allocations eventually. */
597 return sparse_mem_map_populate(pnum
, nid
, altmap
);
599 static void __kfree_section_memmap(struct page
*memmap
,
600 struct vmem_altmap
*altmap
)
602 unsigned long start
= (unsigned long)memmap
;
603 unsigned long end
= (unsigned long)(memmap
+ PAGES_PER_SECTION
);
605 vmemmap_free(start
, end
, altmap
);
607 static void free_map_bootmem(struct page
*memmap
)
609 unsigned long start
= (unsigned long)memmap
;
610 unsigned long end
= (unsigned long)(memmap
+ PAGES_PER_SECTION
);
612 vmemmap_free(start
, end
, NULL
);
615 static struct page
*__kmalloc_section_memmap(void)
617 struct page
*page
, *ret
;
618 unsigned long memmap_size
= sizeof(struct page
) * PAGES_PER_SECTION
;
620 page
= alloc_pages(GFP_KERNEL
|__GFP_NOWARN
, get_order(memmap_size
));
624 ret
= vmalloc(memmap_size
);
630 ret
= (struct page
*)pfn_to_kaddr(page_to_pfn(page
));
636 static inline struct page
*kmalloc_section_memmap(unsigned long pnum
, int nid
,
637 struct vmem_altmap
*altmap
)
639 return __kmalloc_section_memmap();
642 static void __kfree_section_memmap(struct page
*memmap
,
643 struct vmem_altmap
*altmap
)
645 if (is_vmalloc_addr(memmap
))
648 free_pages((unsigned long)memmap
,
649 get_order(sizeof(struct page
) * PAGES_PER_SECTION
));
652 static void free_map_bootmem(struct page
*memmap
)
654 unsigned long maps_section_nr
, removing_section_nr
, i
;
655 unsigned long magic
, nr_pages
;
656 struct page
*page
= virt_to_page(memmap
);
658 nr_pages
= PAGE_ALIGN(PAGES_PER_SECTION
* sizeof(struct page
))
661 for (i
= 0; i
< nr_pages
; i
++, page
++) {
662 magic
= (unsigned long) page
->freelist
;
664 BUG_ON(magic
== NODE_INFO
);
666 maps_section_nr
= pfn_to_section_nr(page_to_pfn(page
));
667 removing_section_nr
= page_private(page
);
670 * When this function is called, the removing section is
671 * logical offlined state. This means all pages are isolated
672 * from page allocator. If removing section's memmap is placed
673 * on the same section, it must not be freed.
674 * If it is freed, page allocator may allocate it which will
675 * be removed physically soon.
677 if (maps_section_nr
!= removing_section_nr
)
678 put_page_bootmem(page
);
681 #endif /* CONFIG_SPARSEMEM_VMEMMAP */
684 * sparse_add_one_section - add a memory section
685 * @nid: The node to add section on
686 * @start_pfn: start pfn of the memory range
687 * @altmap: device page map
689 * This is only intended for hotplug.
693 * * -EEXIST - Section has been present.
694 * * -ENOMEM - Out of memory.
696 int __meminit
sparse_add_one_section(int nid
, unsigned long start_pfn
,
697 struct vmem_altmap
*altmap
)
699 unsigned long section_nr
= pfn_to_section_nr(start_pfn
);
700 struct mem_section_usage
*usage
;
701 struct mem_section
*ms
;
706 * no locking for this, because it does its own
707 * plus, it does a kmalloc
709 ret
= sparse_index_init(section_nr
, nid
);
710 if (ret
< 0 && ret
!= -EEXIST
)
713 memmap
= kmalloc_section_memmap(section_nr
, nid
, altmap
);
716 usage
= kzalloc(mem_section_usage_size(), GFP_KERNEL
);
718 __kfree_section_memmap(memmap
, altmap
);
722 ms
= __pfn_to_section(start_pfn
);
723 if (ms
->section_mem_map
& SECTION_MARKED_PRESENT
) {
729 * Poison uninitialized struct pages in order to catch invalid flags
732 page_init_poison(memmap
, sizeof(struct page
) * PAGES_PER_SECTION
);
734 set_section_nid(section_nr
, nid
);
735 section_mark_present(ms
);
736 sparse_init_one_section(ms
, section_nr
, memmap
, usage
, 0);
741 __kfree_section_memmap(memmap
, altmap
);
746 #ifdef CONFIG_MEMORY_FAILURE
747 static void clear_hwpoisoned_pages(struct page
*memmap
, int nr_pages
)
755 * A further optimization is to have per section refcounted
756 * num_poisoned_pages. But that would need more space per memmap, so
757 * for now just do a quick global check to speed up this routine in the
758 * absence of bad pages.
760 if (atomic_long_read(&num_poisoned_pages
) == 0)
763 for (i
= 0; i
< nr_pages
; i
++) {
764 if (PageHWPoison(&memmap
[i
])) {
765 atomic_long_sub(1, &num_poisoned_pages
);
766 ClearPageHWPoison(&memmap
[i
]);
771 static inline void clear_hwpoisoned_pages(struct page
*memmap
, int nr_pages
)
776 static void free_section_usage(struct mem_section
*ms
, struct page
*memmap
,
777 struct mem_section_usage
*usage
, struct vmem_altmap
*altmap
)
783 * Check to see if allocation came from hot-plug-add
785 if (!early_section(ms
)) {
788 __kfree_section_memmap(memmap
, altmap
);
793 * The usemap came from bootmem. This is packed with other usemaps
794 * on the section which has pgdat at boot time. Just keep it as is now.
798 free_map_bootmem(memmap
);
801 void sparse_remove_one_section(struct mem_section
*ms
, unsigned long map_offset
,
802 struct vmem_altmap
*altmap
)
804 struct page
*memmap
= NULL
;
805 struct mem_section_usage
*usage
= NULL
;
807 if (ms
->section_mem_map
) {
809 memmap
= sparse_decode_mem_map(ms
->section_mem_map
,
811 ms
->section_mem_map
= 0;
815 clear_hwpoisoned_pages(memmap
+ map_offset
,
816 PAGES_PER_SECTION
- map_offset
);
817 free_section_usage(ms
, memmap
, usage
, altmap
);
819 #endif /* CONFIG_MEMORY_HOTPLUG */