Re: [PATCH][mm] adjust the logic of checking THP

From: Hillf Danton
Date: Wed Nov 02 2011 - 08:17:39 EST


On Wed, Nov 2, 2011 at 2:34 PM, Guanjun He <heguanbo@xxxxxxxxx> wrote:
>
> Acturally, pmd_trans_huge(orig_pmd) only checks the _PAGE_PSE bits,
> it's a pmd entry bits, only mark a size, not a flag;As one can easily
> create the same pmd entry bits for some special use,then the check
> will get confused.And this patch is to adjust the logic to use the flag,
> it can perfectly avoid this potential issuse,and basically no impact
> to the current code.
>
>
> Signed-off-by: Guanjun He <heguanbo@xxxxxxxxx>
> ---
> Âmm/memory.c | Â 28 +++++++++++++++-------------
> Â1 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index a56e3ba..a76b17f 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3465,20 +3465,22 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
> Â Â Â Âpmd = pmd_alloc(mm, pud, address);
> Â Â Â Âif (!pmd)
> Â Â Â Â Â Â Â Âreturn VM_FAULT_OOM;
> - Â Â Â if (pmd_none(*pmd) && transparent_hugepage_enabled(vma)) {
> - Â Â Â Â Â Â Â if (!vma->vm_ops)
> - Â Â Â Â Â Â Â Â Â Â Â return do_huge_pmd_anonymous_page(mm, vma, address,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pmd, flags);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â pmd_t orig_pmd = *pmd;
> - Â Â Â Â Â Â Â barrier();
> - Â Â Â Â Â Â Â if (pmd_trans_huge(orig_pmd)) {
> - Â Â Â Â Â Â Â Â Â Â Â if (flags & FAULT_FLAG_WRITE &&
> - Â Â Â Â Â Â Â Â Â Â Â Â Â !pmd_write(orig_pmd) &&
> - Â Â Â Â Â Â Â Â Â Â Â Â Â !pmd_trans_splitting(orig_pmd))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return do_huge_pmd_wp_page(mm, vma, address,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âpmd, orig_pmd);
> + Â Â Â if (transparent_hugepage_enabled(vma)) {

Well, how about THP not configured?

Thanks,
Hillf

> + Â Â Â Â Â Â Â if (pmd_none(*pmd)) {
> + Â Â Â Â Â Â Â Â Â Â Â if (!vma->vm_ops)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return do_huge_pmd_anonymous_page(mm, vma, address,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â pmd, flags);
> + Â Â Â Â Â Â Â } else {
> + Â Â Â Â Â Â Â Â Â Â Â pmd_t orig_pmd = *pmd;
> + Â Â Â Â Â Â Â Â Â Â Â barrier();
> + Â Â Â Â Â Â Â Â Â Â Â if (pmd_trans_huge(orig_pmd)) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (flags & FAULT_FLAG_WRITE &&
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â !pmd_write(orig_pmd) &&
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â !pmd_trans_splitting(orig_pmd))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return do_huge_pmd_wp_page(mm, vma, address,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âpmd, orig_pmd);
> Â Â Â Â Â Â Â Â Â Â Â Âreturn 0;
> + Â Â Â Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â}
> Â Â Â Â}
>
> --
> 1.7.7
>
> --
> 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/
>
>
>
N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i