Using padata during deferred init has only been tested on x86, so for now limit it to this architecture. If another arch wants this, it can find the max thread limit that's best for it and override deferred_page_init_max_threads().
Unified · Split
| @@ -1265,6 +1265,18 @@ void __init mem_init(void) · 1264 unmodified lines | ||
| 1265 | 1265 | mem_init_print_info(NULL); |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | +#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT | |
| 1269 | +int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask) | |
| 1270 | +{ | |
| 1271 | + /* | |
| 1272 | + * More CPUs always led to greater speedups on tested systems, up to | |
| 1273 | + * all the nodes' CPUs. Use all since the system is otherwise idle | |
| 1274 | + * now. | |
| 1275 | + */ | |
| 1276 | + return max_t(int, cpumask_weight(node_cpumask), 1); | |
| 1277 | +} | |
| 1278 | +#endif | |
| 1279 | + | |
| 1268 | 1280 | int kernel_set_to_readonly; |
| 1269 | 1281 | |
| 1270 | 1282 | void mark_rodata_ro(void) |
| @@ -273,6 +273,9 @@ void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, · 272 unmodified lines | ||
| 273 | 273 | #define for_each_free_mem_pfn_range_in_zone_from(i, zone, p_start, p_end) \ |
| 274 | 274 | for (; i != U64_MAX; \ |
| 275 | 275 | __next_mem_pfn_range_in_zone(&i, zone, p_start, p_end)) |
| 276 | + | |
| 277 | +int __init deferred_page_init_max_threads(const struct cpumask *node_cpumask); | |
| 278 | + | |
| 276 | 279 | #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ |
| 277 | 280 | |
| 278 | 281 | /** |
| @@ -1836,6 +1836,13 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, · 1835 unmodified lines | ||
| 1836 | 1836 | } |
| 1837 | 1837 | } |
| 1838 | 1838 | |
| 1839 | +/* An arch may override for more concurrency. */ | |
| 1840 | +__weak int __init | |
| 1841 | +deferred_page_init_max_threads(const struct cpumask *node_cpumask) | |
| 1842 | +{ | |
| 1843 | + return 1; | |
| 1844 | +} | |
| 1845 | + | |
| 1839 | 1846 | /* Initialise remaining memory on a node */ |
| 1840 | 1847 | static int __init deferred_init_memmap(void *data) |
| 1841 | 1848 | { |
| @@ -1884,11 +1891,7 @@ static int __init deferred_init_memmap(void *data) · 42 unmodified lines | ||
| 1884 | 1891 | first_init_pfn)) |
| 1885 | 1892 | goto zone_empty; |
| 1886 | 1893 | |
| 1887 | − /* | |
| 1888 | − * More CPUs always led to greater speedups on tested systems, up to | |
| 1889 | − * all the nodes' CPUs. Use all since the system is otherwise idle now. | |
| 1890 | − */ | |
| 1891 | − max_threads = max(cpumask_weight(cpumask), 1u); | |
| 1894 | + max_threads = deferred_page_init_max_threads(cpumask); | |
| 1892 | 1895 | |
| 1893 | 1896 | while (spfn < epfn) { |
| 1894 | 1897 | unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION); |