diff options
-rw-r--r-- | include/linux/mm.h | 12 | ||||
-rw-r--r-- | init/main.c | 2 | ||||
-rw-r--r-- | mm/memory.c | 13 |
3 files changed, 24 insertions, 3 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 58202c26c559..fc4415256ec3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1350,6 +1350,7 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a | |||
1350 | 1350 | ||
1351 | #if USE_SPLIT_PTE_PTLOCKS | 1351 | #if USE_SPLIT_PTE_PTLOCKS |
1352 | #if ALLOC_SPLIT_PTLOCKS | 1352 | #if ALLOC_SPLIT_PTLOCKS |
1353 | void __init ptlock_cache_init(void); | ||
1353 | extern bool ptlock_alloc(struct page *page); | 1354 | extern bool ptlock_alloc(struct page *page); |
1354 | extern void ptlock_free(struct page *page); | 1355 | extern void ptlock_free(struct page *page); |
1355 | 1356 | ||
@@ -1358,6 +1359,10 @@ static inline spinlock_t *ptlock_ptr(struct page *page) | |||
1358 | return page->ptl; | 1359 | return page->ptl; |
1359 | } | 1360 | } |
1360 | #else /* ALLOC_SPLIT_PTLOCKS */ | 1361 | #else /* ALLOC_SPLIT_PTLOCKS */ |
1362 | static inline void ptlock_cache_init(void) | ||
1363 | { | ||
1364 | } | ||
1365 | |||
1361 | static inline bool ptlock_alloc(struct page *page) | 1366 | static inline bool ptlock_alloc(struct page *page) |
1362 | { | 1367 | { |
1363 | return true; | 1368 | return true; |
@@ -1410,10 +1415,17 @@ static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd) | |||
1410 | { | 1415 | { |
1411 | return &mm->page_table_lock; | 1416 | return &mm->page_table_lock; |
1412 | } | 1417 | } |
1418 | static inline void ptlock_cache_init(void) {} | ||
1413 | static inline bool ptlock_init(struct page *page) { return true; } | 1419 | static inline bool ptlock_init(struct page *page) { return true; } |
1414 | static inline void pte_lock_deinit(struct page *page) {} | 1420 | static inline void pte_lock_deinit(struct page *page) {} |
1415 | #endif /* USE_SPLIT_PTE_PTLOCKS */ | 1421 | #endif /* USE_SPLIT_PTE_PTLOCKS */ |
1416 | 1422 | ||
1423 | static inline void pgtable_init(void) | ||
1424 | { | ||
1425 | ptlock_cache_init(); | ||
1426 | pgtable_cache_init(); | ||
1427 | } | ||
1428 | |||
1417 | static inline bool pgtable_page_ctor(struct page *page) | 1429 | static inline bool pgtable_page_ctor(struct page *page) |
1418 | { | 1430 | { |
1419 | inc_zone_page_state(page, NR_PAGETABLE); | 1431 | inc_zone_page_state(page, NR_PAGETABLE); |
diff --git a/init/main.c b/init/main.c index febc511e078a..01573fdfa186 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -476,7 +476,7 @@ static void __init mm_init(void) | |||
476 | mem_init(); | 476 | mem_init(); |
477 | kmem_cache_init(); | 477 | kmem_cache_init(); |
478 | percpu_init_late(); | 478 | percpu_init_late(); |
479 | pgtable_cache_init(); | 479 | pgtable_init(); |
480 | vmalloc_init(); | 480 | vmalloc_init(); |
481 | } | 481 | } |
482 | 482 | ||
diff --git a/mm/memory.c b/mm/memory.c index e9c550484ba6..86487dfa5e59 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -4275,11 +4275,20 @@ void copy_user_huge_page(struct page *dst, struct page *src, | |||
4275 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ | 4275 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_HUGETLBFS */ |
4276 | 4276 | ||
4277 | #if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS | 4277 | #if USE_SPLIT_PTE_PTLOCKS && ALLOC_SPLIT_PTLOCKS |
4278 | |||
4279 | static struct kmem_cache *page_ptl_cachep; | ||
4280 | |||
4281 | void __init ptlock_cache_init(void) | ||
4282 | { | ||
4283 | page_ptl_cachep = kmem_cache_create("page->ptl", sizeof(spinlock_t), 0, | ||
4284 | SLAB_PANIC, NULL); | ||
4285 | } | ||
4286 | |||
4278 | bool ptlock_alloc(struct page *page) | 4287 | bool ptlock_alloc(struct page *page) |
4279 | { | 4288 | { |
4280 | spinlock_t *ptl; | 4289 | spinlock_t *ptl; |
4281 | 4290 | ||
4282 | ptl = kmalloc(sizeof(spinlock_t), GFP_KERNEL); | 4291 | ptl = kmem_cache_alloc(page_ptl_cachep, GFP_KERNEL); |
4283 | if (!ptl) | 4292 | if (!ptl) |
4284 | return false; | 4293 | return false; |
4285 | page->ptl = ptl; | 4294 | page->ptl = ptl; |
@@ -4288,6 +4297,6 @@ bool ptlock_alloc(struct page *page) | |||
4288 | 4297 | ||
4289 | void ptlock_free(struct page *page) | 4298 | void ptlock_free(struct page *page) |
4290 | { | 4299 | { |
4291 | kfree(page->ptl); | 4300 | kmem_cache_free(page_ptl_cachep, page->ptl); |
4292 | } | 4301 | } |
4293 | #endif | 4302 | #endif |