History

dma-contiguous: simplify cma_early_percent_memory()

The memory size calculation in cma_early_percent_memory() traverses memblock.memory rather than simply call memblock_phys_mem_size(). The comment in that function suggests that at some point there should have been call to memblock_analyze() before memblock_phys_mem_size() could be used. As of now, there is no memblock_analyze() at all and memblock_phys_mem_size() can be used as soon as cold-plug memory is registered with memblock. Replace loop over memblock.memory with a call to memblock_phys_mem_size().

Mike Rapoport committed 6 years ago

Commit e9aa36c1 parent 04ba0a91 file · +1 −10Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/dma/contiguous.c+1−10
@@ -73,16 +73,7 @@ early_param("cma", early_cma); · 72 unmodified lines
7373
7474 static phys_addr_t __init __maybe_unused cma_early_percent_memory(void)
7575 {
76− struct memblock_region *reg;
77− unsigned long total_pages = 0;
78−
79− /*
80− * We cannot use memblock_phys_mem_size() here, because
81− * memblock_analyze() has not been called yet.
82− */
83− for_each_memblock(memory, reg)
84− total_pages += memblock_region_memory_end_pfn(reg) -
85− memblock_region_memory_base_pfn(reg);
76+ unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size());
8677
8778 return (total_pages * CONFIG_CMA_SIZE_PERCENTAGE / 100) << PAGE_SHIFT;
8879 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t