diff options
| author | Mark Brown <broonie@kernel.org> | 2017-12-04 17:59:52 +0000 | 
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2017-12-04 17:59:52 +0000 | 
| commit | d218439feccafaa3e852bbaecc0d9f6110096b65 (patch) | |
| tree | c4ebfeaebd965735cea5d90332d0f8013b79e628 /mm/sparse.c | |
| parent | a76d7f5454c688b52dc849e832cc4c6dd0975723 (diff) | |
| parent | fdaa451107ce543d345a339b4d5e20e8e4bac396 (diff) | |
| download | talos-op-linux-d218439feccafaa3e852bbaecc0d9f6110096b65.tar.gz talos-op-linux-d218439feccafaa3e852bbaecc0d9f6110096b65.zip | |
Merge branch 'fix/amd' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-amd
Diffstat (limited to 'mm/sparse.c')
| -rw-r--r-- | mm/sparse.c | 34 | 
1 files changed, 25 insertions, 9 deletions
| diff --git a/mm/sparse.c b/mm/sparse.c index 83b3bf6461af..7a5dacaa06e3 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0  /*   * sparse memory mappings.   */ @@ -22,8 +23,7 @@   * 1) mem_section	- memory sections, mem_map's for valid memory   */  #ifdef CONFIG_SPARSEMEM_EXTREME -struct mem_section *mem_section[NR_SECTION_ROOTS] -	____cacheline_internodealigned_in_smp; +struct mem_section **mem_section;  #else  struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]  	____cacheline_internodealigned_in_smp; @@ -100,7 +100,7 @@ static inline int sparse_index_init(unsigned long section_nr, int nid)  int __section_nr(struct mem_section* ms)  {  	unsigned long root_nr; -	struct mem_section* root; +	struct mem_section *root = NULL;  	for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) {  		root = __nr_to_section(root_nr * SECTIONS_PER_ROOT); @@ -111,7 +111,7 @@ int __section_nr(struct mem_section* ms)  		     break;  	} -	VM_BUG_ON(root_nr == NR_SECTION_ROOTS); +	VM_BUG_ON(!root);  	return (root_nr * SECTIONS_PER_ROOT) + (ms - root);  } @@ -207,6 +207,16 @@ void __init memory_present(int nid, unsigned long start, unsigned long end)  {  	unsigned long pfn; +#ifdef CONFIG_SPARSEMEM_EXTREME +	if (unlikely(!mem_section)) { +		unsigned long size, align; + +		size = sizeof(struct mem_section) * NR_SECTION_ROOTS; +		align = 1 << (INTERNODE_CACHE_SHIFT); +		mem_section = memblock_virt_alloc(size, align); +	} +#endif +  	start &= PAGE_SECTION_MASK;  	mminit_validate_memmodel_limits(&start, &end);  	for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) { @@ -329,11 +339,17 @@ again:  static void __init check_usemap_section_nr(int nid, unsigned long *usemap)  {  	unsigned long usemap_snr, pgdat_snr; -	static unsigned long old_usemap_snr = NR_MEM_SECTIONS; -	static unsigned long old_pgdat_snr = NR_MEM_SECTIONS; +	static unsigned long old_usemap_snr; +	static unsigned long old_pgdat_snr;  	struct pglist_data *pgdat = NODE_DATA(nid);  	int usemap_nid; +	/* First call */ +	if (!old_usemap_snr) { +		old_usemap_snr = NR_MEM_SECTIONS; +		old_pgdat_snr = NR_MEM_SECTIONS; +	} +  	usemap_snr = pfn_to_section_nr(__pa(usemap) >> PAGE_SHIFT);  	pgdat_snr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);  	if (usemap_snr == pgdat_snr) @@ -437,9 +453,9 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,  	}  	size = PAGE_ALIGN(size); -	map = memblock_virt_alloc_try_nid(size * map_count, -					  PAGE_SIZE, __pa(MAX_DMA_ADDRESS), -					  BOOTMEM_ALLOC_ACCESSIBLE, nodeid); +	map = memblock_virt_alloc_try_nid_raw(size * map_count, +					      PAGE_SIZE, __pa(MAX_DMA_ADDRESS), +					      BOOTMEM_ALLOC_ACCESSIBLE, nodeid);  	if (map) {  		for (pnum = pnum_begin; pnum < pnum_end; pnum++) {  			if (!present_section_nr(pnum)) | 

