History

x86/mm: Initialize PGD cache during mm initialization

Poking-mm initialization might require to duplicate the PGD in early stage. Initialize the PGD cache earlier to prevent boot failures.

Nadav Amit committed 7 years ago

Commit caa84131 parent 39507463 files · +11 −4Browse files

Unified · Split

3 files
  1. arch/x86/mm/pgtable.c +6 −4
  2. include/asm-generic/pgtable.h +2 −0
  3. init/main.c +3 −0
arch/x86/mm/pgtable.c+6−4
@@ -373,14 +373,14 @@ static void pgd_prepopulate_user_pmd(struct mm_struct *mm, · 372 unmodified lines
373373
374374 static struct kmem_cache *pgd_cache;
375375
376−static int __init pgd_cache_init(void)
376+void __init pgd_cache_init(void)
377377 {
378378 /*
379379 * When PAE kernel is running as a Xen domain, it does not use
380380 * shared kernel pmd. And this requires a whole page for pgd.
381381 */
382382 if (!SHARED_KERNEL_PMD)
383− return 0;
383+ return;
384384
385385 /*
386386 * when PAE kernel is not running as a Xen domain, it uses
@@ -390,9 +390,7 @@ static int __init pgd_cache_init(void) · 3 unmodified lines
390390 */
391391 pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
392392 SLAB_PANIC, NULL);
393− return 0;
394393 }
395−core_initcall(pgd_cache_init);
396394
397395 static inline pgd_t *_pgd_alloc(void)
398396 {
@@ -420,6 +418,10 @@ static inline void _pgd_free(pgd_t *pgd) · 21 unmodified lines
420418 }
421419 #else
422420
421+void __init pgd_cache_init(void)
422+{
423+}
424+
423425 static inline pgd_t *_pgd_alloc(void)
424426 {
425427 return (pgd_t *)__get_free_pages(PGALLOC_GFP, PGD_ALLOCATION_ORDER);
include/asm-generic/pgtable.h+2−0
@@ -1126,6 +1126,8 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, · 1125 unmodified lines
11261126 static inline void init_espfix_bsp(void) { }
11271127 #endif
11281128
1129+extern void __init pgd_cache_init(void);
1130+
11291131 #ifndef __HAVE_ARCH_PFN_MODIFY_ALLOWED
11301132 static inline bool pfn_modify_allowed(unsigned long pfn, pgprot_t prot)
11311133 {
init/main.c+3−0
@@ -506,6 +506,8 @@ void __init __weak mem_encrypt_init(void) { } · 505 unmodified lines
506506
507507 void __init __weak poking_init(void) { }
508508
509+void __init __weak pgd_cache_init(void) { }
510+
509511 bool initcall_debug;
510512 core_param(initcall_debug, initcall_debug, bool, 0644);
511513
@@ -537,6 +539,7 @@ static void __init mm_init(void) · 25 unmodified lines
537539 init_espfix_bsp();
538540 /* Should be run after espfix64 is set up. */
539541 pti_init();
542+ pgd_cache_init();
540543 }
541544
542545 void __init __weak arch_call_rest_init(void)

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