Re: [PATCH 2/6] thp: optimize away unnecessary page table locking

From: Hillf Danton
Date: Sat Jan 28 2012 - 06:23:47 EST


Hi Naoya

On Sat, Jan 28, 2012 at 7:02 AM, Naoya Horiguchi
<n-horiguchi@xxxxxxxxxxxxx> wrote:
> Currently when we check if we can handle thp as it is or we need to
> split it into regular sized pages, we hold page table lock prior to
> check whether a given pmd is mapping thp or not. Because of this,
> when it's not "huge pmd" we suffer from unnecessary lock/unlock overhead.
> To remove it, this patch introduces a optimized check function and
> replace several similar logics with it.
>
> Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
> Cc: David Rientjes <rientjes@xxxxxxxxxx>
>
> Changes since v3:
> Â- Fix likely/unlikely pattern in pmd_trans_huge_stable()
> Â- Change suffix from _stable to _lock
> Â- Introduce __pmd_trans_huge_lock() to avoid micro-regression
> Â- Return 1 when wait_split_huge_page path is taken
>
> Changes since v2:
> Â- Fix missing "return 0" in "thp under splitting" path
> Â- Remove unneeded comment
> Â- Change the name of check function to describe what it does
> Â- Add VM_BUG_ON(mmap_sem)
> ---
> Âfs/proc/task_mmu.c   Â|  70 +++++++++------------------
> Âinclude/linux/huge_mm.h | Â 17 +++++++
> Âmm/huge_memory.c    Â| Â120 ++++++++++++++++++++++-------------------------
> Â3 files changed, 96 insertions(+), 111 deletions(-)
>
[...]

> @@ -1064,21 +1056,14 @@ int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
> Â{
> Â Â Â Âint ret = 0;
>
> - Â Â Â spin_lock(&vma->vm_mm->page_table_lock);
> - Â Â Â if (likely(pmd_trans_huge(*pmd))) {
> - Â Â Â Â Â Â Â ret = !pmd_trans_splitting(*pmd);

Here the value of ret is either false or true,

> - Â Â Â Â Â Â Â spin_unlock(&vma->vm_mm->page_table_lock);
> - Â Â Â Â Â Â Â if (unlikely(!ret))
> - Â Â Â Â Â Â Â Â Â Â Â wait_split_huge_page(vma->anon_vma, pmd);
> - Â Â Â Â Â Â Â else {
> - Â Â Â Â Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â Â Â Â Â* All logical pages in the range are present
> - Â Â Â Â Â Â Â Â Â Â Â Â* if backed by a huge page.
> - Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â memset(vec, 1, (end - addr) >> PAGE_SHIFT);
> - Â Â Â Â Â Â Â }
> - Â Â Â } else
> + Â Â Â if (__pmd_trans_huge_lock(pmd, vma) == 1) {
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* All logical pages in the range are present
> + Â Â Â Â Â Â Â Â* if backed by a huge page.
> + Â Â Â Â Â Â Â Â*/
> Â Â Â Â Â Â Â Âspin_unlock(&vma->vm_mm->page_table_lock);
> + Â Â Â Â Â Â Â memset(vec, 1, (end - addr) >> PAGE_SHIFT);
> + Â Â Â }
>
> Â Â Â Âreturn ret;

what is the returned value of this function? /Hillf

> Â}
> @@ -1108,20 +1093,10 @@ int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
> Â Â Â Â Â Â Â Âgoto out;
> Â Â Â Â}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/