]> git.karo-electronics.de Git - karo-tx-linux.git/commit
pagewalk: update page table walker core
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Thu, 22 May 2014 00:42:39 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:42:39 +0000 (10:42 +1000)
commit67b5244e3232588208aba0e418c89a6d7b8a8f2b
treeb86455041ff4982d99073ef90f11c09ffdc06dd0
parent9f941a9547cac52f8b68ffd556731727fef62082
pagewalk: update page table walker core

This patch updates mm/pagewalk.c to make code less complex and more
maintainable.  The basic idea is unchanged and there's no userspace visible
effect.

Most of existing callback functions need access to vma to handle each
entry.  So we had better add a new member vma in struct mm_walk instead of
using mm_walk->private, which makes code simpler.

One problem in current page table walker is that we check vma in pgd loop.
 Historically this was introduced to support hugetlbfs in the strange
manner.  It's better and cleaner to do the vma check outside pgd loop.

Another problem is that many users of page table walker now use only
pmd_entry(), although it does both pmd-walk and pte-walk.  This makes code
duplication and fluctuation among callers, which worsens the
maintenability.

One difficulty of code sharing is that the callers want to determine
whether they try to walk over a specific vma or not in their own way.  To
solve this, this patch introduces test_walk() callback.

When we try to use multiple callbacks in different levels, skip control is
also important.  For example we have thp enabled in normal configuration,
and we are interested in doing some work for a thp.  But sometimes we want
to split it and handle as normal pages, and in another time user would
handle both at pmd level and pte level.  What we need is that when we've
done pmd_entry() we want to decide whether to go down to pte level
handling based on the pmd_entry()'s result.  So this patch introduces a
skip control flag in mm_walk.  We can't use the returned value for this
purpose, because we already defined the meaning of whole range of returned
values (>0 is to terminate page table walk in caller's specific manner, =0
is to continue to walk, and <0 is to abort the walk in the general
manner.)

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Cliff Wickman <cpw@sgi.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
mm/pagewalk.c