aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/mm/tsb.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/mm/tsb.c')
-rw-r--r--arch/sparc/mm/tsb.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
index 6725ed45580e..f2b77112e9d8 100644
--- a/arch/sparc/mm/tsb.c
+++ b/arch/sparc/mm/tsb.c
@@ -469,8 +469,10 @@ retry_tsb_alloc:
469 469
470int init_new_context(struct task_struct *tsk, struct mm_struct *mm) 470int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
471{ 471{
472 unsigned long mm_rss = get_mm_rss(mm);
472#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) 473#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
473 unsigned long total_huge_pte_count; 474 unsigned long saved_hugetlb_pte_count;
475 unsigned long saved_thp_pte_count;
474#endif 476#endif
475 unsigned int i; 477 unsigned int i;
476 478
@@ -483,10 +485,12 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
483 * will re-increment the counters as the parent PTEs are 485 * will re-increment the counters as the parent PTEs are
484 * copied into the child address space. 486 * copied into the child address space.
485 */ 487 */
486 total_huge_pte_count = mm->context.hugetlb_pte_count + 488 saved_hugetlb_pte_count = mm->context.hugetlb_pte_count;
487 mm->context.thp_pte_count; 489 saved_thp_pte_count = mm->context.thp_pte_count;
488 mm->context.hugetlb_pte_count = 0; 490 mm->context.hugetlb_pte_count = 0;
489 mm->context.thp_pte_count = 0; 491 mm->context.thp_pte_count = 0;
492
493 mm_rss -= saved_thp_pte_count * (HPAGE_SIZE / PAGE_SIZE);
490#endif 494#endif
491 495
492 /* copy_mm() copies over the parent's mm_struct before calling 496 /* copy_mm() copies over the parent's mm_struct before calling
@@ -499,11 +503,13 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
499 /* If this is fork, inherit the parent's TSB size. We would 503 /* If this is fork, inherit the parent's TSB size. We would
500 * grow it to that size on the first page fault anyways. 504 * grow it to that size on the first page fault anyways.
501 */ 505 */
502 tsb_grow(mm, MM_TSB_BASE, get_mm_rss(mm)); 506 tsb_grow(mm, MM_TSB_BASE, mm_rss);
503 507
504#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) 508#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
505 if (unlikely(total_huge_pte_count)) 509 if (unlikely(saved_hugetlb_pte_count + saved_thp_pte_count))
506 tsb_grow(mm, MM_TSB_HUGE, total_huge_pte_count); 510 tsb_grow(mm, MM_TSB_HUGE,
511 (saved_hugetlb_pte_count + saved_thp_pte_count) *
512 REAL_HPAGE_PER_HPAGE);
507#endif 513#endif
508 514
509 if (unlikely(!mm->context.tsb_block[MM_TSB_BASE].tsb)) 515 if (unlikely(!mm->context.tsb_block[MM_TSB_BASE].tsb))