History

mm: make deferred init's max threads arch-specific

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().

Daniel Jordan committed 6 years ago

Commit ecd09651 parent e4443143 files · +23 −5Browse files

Unified · Split

3 files
  1. arch/x86/mm/init_64.c +12 −0
  2. include/linux/memblock.h +3 −0
  3. mm/page_alloc.c +8 −5
arch/x86/mm/init_64.c+12−0
@@ -1265,6 +1265,18 @@ void __init mem_init(void) · 1264 unmodified lines
12651265 mem_init_print_info(NULL);
12661266 }
12671267
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+
12681280 int kernel_set_to_readonly;
12691281
12701282 void mark_rodata_ro(void)
include/linux/memblock.h+3−0
@@ -273,6 +273,9 @@ void __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, · 272 unmodified lines
273273 #define for_each_free_mem_pfn_range_in_zone_from(i, zone, p_start, p_end) \
274274 for (; i != U64_MAX; \
275275 __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+
276279 #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */
277280
278281 /**
mm/page_alloc.c+8−5
@@ -1836,6 +1836,13 @@ deferred_init_memmap_chunk(unsigned long start_pfn, unsigned long end_pfn, · 1835 unmodified lines
18361836 }
18371837 }
18381838
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+
18391846 /* Initialise remaining memory on a node */
18401847 static int __init deferred_init_memmap(void *data)
18411848 {
@@ -1884,11 +1891,7 @@ static int __init deferred_init_memmap(void *data) · 42 unmodified lines
18841891 first_init_pfn))
18851892 goto zone_empty;
18861893
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);
18921895
18931896 while (spfn < epfn) {
18941897 unsigned long epfn_align = ALIGN(epfn, PAGES_PER_SECTION);