linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <dhillf@gmail.com>
To: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Andi Kleen <andi@firstfloor.org>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [PATCH 2/4] thp: optimize away unnecessary page table locking
Date: Thu, 22 Dec 2011 21:04:23 +0800	[thread overview]
Message-ID: <CAJd=RBDxZbsk8RxFpHUJtsc=fq+=WWGeWvJGJX_SFFGj4AvuHg@mail.gmail.com> (raw)
In-Reply-To: <1324506228-18327-3-git-send-email-n-horiguchi@ah.jp.nec.com>

On Thu, Dec 22, 2011 at 6:23 AM, Naoya Horiguchi
<n-horiguchi@ah.jp.nec.com> 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@ah.jp.nec.com>
> Cc: David Rientjes <rientjes@google.com>
> ---
>  fs/proc/task_mmu.c      |   74 ++++++++++------------------
>  include/linux/huge_mm.h |    7 +++
>  mm/huge_memory.c        |  124 ++++++++++++++++++++++------------------------
>  mm/mremap.c             |    3 +-
>  4 files changed, 93 insertions(+), 115 deletions(-)
>

[...]

>
> +/*
> + * Returns 1 if a given pmd is mapping a thp and stable (not under splitting.)
> + * Returns 0 otherwise. Note that if it returns 1, this routine returns without
> + * unlocking page table locks. So callers must unlock them.
> + */
> +int check_and_wait_split_huge_pmd(pmd_t *pmd, struct vm_area_struct *vma)
> +{
> +       if (!pmd_trans_huge(*pmd))
> +               return 0;
> +
> +       spin_lock(&vma->vm_mm->page_table_lock);
> +       if (likely(pmd_trans_huge(*pmd))) {
> +               if (pmd_trans_splitting(*pmd)) {
> +                       spin_unlock(&vma->vm_mm->page_table_lock);
> +                       wait_split_huge_page(vma->anon_vma, pmd);

                            return 0;   yes?

> +               } else {
> +                       /* Thp mapped by 'pmd' is stable, so we can
> +                        * handle it as it is. */
> +                       return 1;
> +               }
> +       }
> +       spin_unlock(&vma->vm_mm->page_table_lock);
> +       return 0;
> +}
> +

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-12-22 13:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 22:23 [PATCH 0/4 v2] pagemap handles transparent hugepage Naoya Horiguchi
2011-12-21 22:23 ` [PATCH 1/4] pagemap: avoid splitting thp when reading /proc/pid/pagemap Naoya Horiguchi
2011-12-26  8:26   ` KAMEZAWA Hiroyuki
2011-12-30  3:39   ` KOSAKI Motohiro
2012-01-03 20:07     ` Naoya Horiguchi
2012-01-03 21:06       ` KOSAKI Motohiro
2012-01-03 21:31         ` Naoya Horiguchi
2012-01-04 23:50   ` Andrew Morton
2012-01-05 16:28     ` Naoya Horiguchi
2011-12-21 22:23 ` [PATCH 2/4] thp: optimize away unnecessary page table locking Naoya Horiguchi
2011-12-22 13:04   ` Hillf Danton [this message]
2011-12-22 16:01     ` Naoya Horiguchi
2011-12-30  3:59   ` KOSAKI Motohiro
2012-01-03 20:08     ` Naoya Horiguchi
2011-12-21 22:23 ` [PATCH 3/4] pagemap: export KPF_THP Naoya Horiguchi
2011-12-26  8:40   ` KAMEZAWA Hiroyuki
2011-12-30  4:01   ` KOSAKI Motohiro
2012-01-04 23:55   ` Andrew Morton
2011-12-21 22:23 ` [PATCH 4/4] pagemap: document KPF_THP and make page-types aware of it Naoya Horiguchi
2011-12-26  8:42   ` KAMEZAWA Hiroyuki
2011-12-30  4:02   ` KOSAKI Motohiro
2012-01-04 23:57   ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJd=RBDxZbsk8RxFpHUJtsc=fq+=WWGeWvJGJX_SFFGj4AvuHg@mail.gmail.com' \
    --to=dhillf@gmail.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=fengguang.wu@intel.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox