[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190801145032.GB31538@redhat.com>
Date: Thu, 1 Aug 2019 16:50:32 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Song Liu <songliubraving@...com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
akpm@...ux-foundation.org, matthew.wilcox@...cle.com,
kirill.shutemov@...ux.intel.com, kernel-team@...com,
william.kucharski@...cle.com, srikar@...ux.vnet.ibm.com
Subject: Re: [PATCH v2 1/2] khugepaged: enable collapse pmd for pte-mapped THP
On 07/31, Song Liu wrote:
>
> +static int khugepaged_add_pte_mapped_thp(struct mm_struct *mm,
> + unsigned long addr)
> +{
> + struct mm_slot *mm_slot;
> + int ret = 0;
> +
> + /* hold mmap_sem for khugepaged_test_exit() */
> + VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
> + VM_BUG_ON(addr & ~HPAGE_PMD_MASK);
> +
> + if (unlikely(khugepaged_test_exit(mm)))
> + return 0;
> +
> + if (!test_bit(MMF_VM_HUGEPAGE, &mm->flags) &&
> + !test_bit(MMF_DISABLE_THP, &mm->flags)) {
> + ret = __khugepaged_enter(mm);
> + if (ret)
> + return ret;
> + }
could you explain why do we need mm->mmap_sem, khugepaged_test_exit() check
and __khugepaged_enter() ?
> + spin_lock(&khugepaged_mm_lock);
> + mm_slot = get_mm_slot(mm);
> + if (likely(mm_slot && mm_slot->nr_pte_mapped_thp < MAX_PTE_MAPPED_THP))
> + mm_slot->pte_mapped_thp[mm_slot->nr_pte_mapped_thp++] = addr;
if get_mm_slot() returns mm_slot != NULL we can safely modify ->pte_mapped_thp.
We do not care even if this task has already passed __mmput/__khugepaged_exit,
this slot can't go away.
No?
Oleg.
Powered by blists - more mailing lists