All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	Matthew Wilcox <matthew.r.wilcox@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Dave Chinner <david@fromorbit.com>, Ning Qu <quning@gmail.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCHv3 1/2] mm: introduce vm_ops->map_pages()
Date: Tue, 4 Mar 2014 03:26:13 +0200	[thread overview]
Message-ID: <20140304012613.GB21508@node.dhcp.inet.fi> (raw)
In-Reply-To: <20140303151611.5671eebb74cedb99aa5396c8@linux-foundation.org>

On Mon, Mar 03, 2014 at 03:16:11PM -0800, Andrew Morton wrote:
> On Thu, 27 Feb 2014 21:53:46 +0200 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
> 
> > The patch introduces new vm_ops callback ->map_pages() and uses it for
> > mapping easy accessible pages around fault address.
> > 
> > On read page fault, if filesystem provides ->map_pages(), we try to map
> > up to FAULT_AROUND_PAGES pages around page fault address in hope to
> > reduce number of minor page faults.
> > 
> > We call ->map_pages first and use ->fault() as fallback if page by the
> > offset is not ready to be mapped (cold page cache or something).
> >
> > ...
> >
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> >
> > ...
> >
> > @@ -571,6 +576,9 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
> >  		pte = pte_mkwrite(pte);
> >  	return pte;
> >  }
> > +
> > +void do_set_pte(struct vm_area_struct *vma, unsigned long address,
> > +		struct page *page, pte_t *pte, bool write, bool anon);
> >  #endif
> >  
> >  /*
> 
> lguest made a dubious naming decision:
> 
> drivers/lguest/page_tables.c:890: error: conflicting types for 'do_set_pte'
> include/linux/mm.h:593: note: previous declaration of 'do_set_pte' was here
> 
> I'll rename lguest's do_set_pte() to do_guest_set_pte() as a
> preparatory patch.

Thanks.

> btw, do_set_pte() could really do with some documentation.  It's not a
> trivial function and it does a lot of stuff.  It's exported to other
> compilation units and we should explain the what, the why and
> particularly the locking preconditions.

Like this?

>From f9be5307ed59ab65645377c1da03eaf4167bfcf2 Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date: Tue, 4 Mar 2014 03:15:43 +0200
Subject: [PATCH] mm: documentaton for do_set_pte()

do_set_pte() now exported to other compilation unit. Let's document
interface.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/memory.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index e2d54e818c5b..6dc622b06915 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3319,7 +3319,21 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
 	return ret;
 }
 
-
+/**
+ * do_set_pte - setup new PTE entry for given page and add reverse page mapping.
+ *
+ * @vma: virtual memory area
+ * @address: user virtual address
+ * @page: page to map
+ * @pte: pointer to target page table entry
+ * @write: true, if new entry is writable
+ * @anon: true, if it's anonymous page
+ *
+ * Caller must hold page table lock relevant for @pte.
+ *
+ * Target users are page handler itself and implementations of
+ * vm_ops->map_pages.
+ */
 void do_set_pte(struct vm_area_struct *vma, unsigned long address,
 		struct page *page, pte_t *pte, bool write, bool anon)
 {
-- 
 Kirill A. Shutemov

--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	Matthew Wilcox <matthew.r.wilcox@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Dave Chinner <david@fromorbit.com>, Ning Qu <quning@gmail.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCHv3 1/2] mm: introduce vm_ops->map_pages()
Date: Tue, 4 Mar 2014 03:26:13 +0200	[thread overview]
Message-ID: <20140304012613.GB21508@node.dhcp.inet.fi> (raw)
In-Reply-To: <20140303151611.5671eebb74cedb99aa5396c8@linux-foundation.org>

On Mon, Mar 03, 2014 at 03:16:11PM -0800, Andrew Morton wrote:
> On Thu, 27 Feb 2014 21:53:46 +0200 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
> 
> > The patch introduces new vm_ops callback ->map_pages() and uses it for
> > mapping easy accessible pages around fault address.
> > 
> > On read page fault, if filesystem provides ->map_pages(), we try to map
> > up to FAULT_AROUND_PAGES pages around page fault address in hope to
> > reduce number of minor page faults.
> > 
> > We call ->map_pages first and use ->fault() as fallback if page by the
> > offset is not ready to be mapped (cold page cache or something).
> >
> > ...
> >
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> >
> > ...
> >
> > @@ -571,6 +576,9 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
> >  		pte = pte_mkwrite(pte);
> >  	return pte;
> >  }
> > +
> > +void do_set_pte(struct vm_area_struct *vma, unsigned long address,
> > +		struct page *page, pte_t *pte, bool write, bool anon);
> >  #endif
> >  
> >  /*
> 
> lguest made a dubious naming decision:
> 
> drivers/lguest/page_tables.c:890: error: conflicting types for 'do_set_pte'
> include/linux/mm.h:593: note: previous declaration of 'do_set_pte' was here
> 
> I'll rename lguest's do_set_pte() to do_guest_set_pte() as a
> preparatory patch.

Thanks.

> btw, do_set_pte() could really do with some documentation.  It's not a
> trivial function and it does a lot of stuff.  It's exported to other
> compilation units and we should explain the what, the why and
> particularly the locking preconditions.

Like this?

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	Andi Kleen <ak@linux.intel.com>,
	Matthew Wilcox <matthew.r.wilcox@intel.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Dave Chinner <david@fromorbit.com>, Ning Qu <quning@gmail.com>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCHv3 1/2] mm: introduce vm_ops->map_pages()
Date: Tue, 4 Mar 2014 03:26:13 +0200	[thread overview]
Message-ID: <20140304012613.GB21508@node.dhcp.inet.fi> (raw)
In-Reply-To: <20140303151611.5671eebb74cedb99aa5396c8@linux-foundation.org>

On Mon, Mar 03, 2014 at 03:16:11PM -0800, Andrew Morton wrote:
> On Thu, 27 Feb 2014 21:53:46 +0200 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:
> 
> > The patch introduces new vm_ops callback ->map_pages() and uses it for
> > mapping easy accessible pages around fault address.
> > 
> > On read page fault, if filesystem provides ->map_pages(), we try to map
> > up to FAULT_AROUND_PAGES pages around page fault address in hope to
> > reduce number of minor page faults.
> > 
> > We call ->map_pages first and use ->fault() as fallback if page by the
> > offset is not ready to be mapped (cold page cache or something).
> >
> > ...
> >
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> >
> > ...
> >
> > @@ -571,6 +576,9 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
> >  		pte = pte_mkwrite(pte);
> >  	return pte;
> >  }
> > +
> > +void do_set_pte(struct vm_area_struct *vma, unsigned long address,
> > +		struct page *page, pte_t *pte, bool write, bool anon);
> >  #endif
> >  
> >  /*
> 
> lguest made a dubious naming decision:
> 
> drivers/lguest/page_tables.c:890: error: conflicting types for 'do_set_pte'
> include/linux/mm.h:593: note: previous declaration of 'do_set_pte' was here
> 
> I'll rename lguest's do_set_pte() to do_guest_set_pte() as a
> preparatory patch.

Thanks.

> btw, do_set_pte() could really do with some documentation.  It's not a
> trivial function and it does a lot of stuff.  It's exported to other
> compilation units and we should explain the what, the why and
> particularly the locking preconditions.

Like this?

>From f9be5307ed59ab65645377c1da03eaf4167bfcf2 Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date: Tue, 4 Mar 2014 03:15:43 +0200
Subject: [PATCH] mm: documentaton for do_set_pte()

do_set_pte() now exported to other compilation unit. Let's document
interface.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
 mm/memory.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index e2d54e818c5b..6dc622b06915 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3319,7 +3319,21 @@ static int __do_fault(struct vm_area_struct *vma, unsigned long address,
 	return ret;
 }
 
-
+/**
+ * do_set_pte - setup new PTE entry for given page and add reverse page mapping.
+ *
+ * @vma: virtual memory area
+ * @address: user virtual address
+ * @page: page to map
+ * @pte: pointer to target page table entry
+ * @write: true, if new entry is writable
+ * @anon: true, if it's anonymous page
+ *
+ * Caller must hold page table lock relevant for @pte.
+ *
+ * Target users are page handler itself and implementations of
+ * vm_ops->map_pages.
+ */
 void do_set_pte(struct vm_area_struct *vma, unsigned long address,
 		struct page *page, pte_t *pte, bool write, bool anon)
 {
-- 
 Kirill A. Shutemov

  reply	other threads:[~2014-03-04  1:26 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 19:53 [PATCHv3 0/2] mm: map few pages around fault address if they are in page cache Kirill A. Shutemov
2014-02-27 19:53 ` Kirill A. Shutemov
2014-02-27 19:53 ` [PATCHv3 1/2] mm: introduce vm_ops->map_pages() Kirill A. Shutemov
2014-02-27 19:53   ` Kirill A. Shutemov
2014-02-27 21:59   ` Dave Hansen
2014-02-27 21:59     ` Dave Hansen
2014-02-27 22:06     ` Linus Torvalds
2014-02-27 22:06       ` Linus Torvalds
2014-02-27 22:34       ` Dave Hansen
2014-02-27 22:34         ` Dave Hansen
2014-02-28  0:18         ` Kirill A. Shutemov
2014-02-28  0:18           ` Kirill A. Shutemov
2014-02-28 11:50         ` Benjamin Herrenschmidt
2014-02-28 11:50           ` Benjamin Herrenschmidt
2014-02-27 22:08     ` Andrew Morton
2014-02-27 22:08       ` Andrew Morton
2014-03-03 23:16   ` Andrew Morton
2014-03-04  1:26     ` Kirill A. Shutemov [this message]
2014-03-04  1:26       ` Kirill A. Shutemov
2014-03-04  1:26       ` Kirill A. Shutemov
2014-03-05  0:04     ` Rusty Russell
2014-03-05  0:04       ` Rusty Russell
2014-03-05 20:02       ` Andrew Morton
2014-03-05 20:02         ` Andrew Morton
2014-07-24  3:33   ` Sasha Levin
2014-07-24  3:33     ` Sasha Levin
2014-07-24  6:53     ` Andrey Ryabinin
2014-07-24  6:53       ` Andrey Ryabinin
2014-07-24 12:48       ` Sasha Levin
2014-07-24 12:48         ` Sasha Levin
2014-07-24 13:05     ` Sasha Levin
2014-07-24 13:05       ` Sasha Levin
2014-07-24 13:30       ` Konstantin Khlebnikov
2014-07-24 13:30         ` Konstantin Khlebnikov
2014-07-28  7:43     ` [PATCH] mm: don't allow fault_around_bytes to be 0 Andrey Ryabinin
2014-07-28  7:43       ` Andrey Ryabinin
2014-07-28  7:47       ` Andrey Ryabinin
2014-07-28  7:47         ` Andrey Ryabinin
2014-07-28  9:36       ` Kirill A. Shutemov
2014-07-28  9:36         ` Kirill A. Shutemov
2014-07-28  9:36         ` Kirill A. Shutemov
2014-07-28 10:27         ` Andrey Ryabinin
2014-07-28 10:27           ` Andrey Ryabinin
2014-07-28 10:27           ` Andrey Ryabinin
2014-07-28 10:27           ` Andrey Ryabinin
2014-07-28 10:52           ` Kirill A. Shutemov
2014-07-28 10:52             ` Kirill A. Shutemov
2014-07-28 12:32           ` Sasha Levin
2014-07-28 12:32             ` Sasha Levin
2014-07-28 22:43           ` David Rientjes
2014-07-28 22:43             ` David Rientjes
2014-07-28 15:26         ` Dave Hansen
2014-07-28 15:26           ` Dave Hansen
2014-02-27 19:53 ` [PATCHv3 2/2] mm: implement ->map_pages for page cache Kirill A. Shutemov
2014-02-27 19:53   ` Kirill A. Shutemov
2014-02-27 21:47   ` Andrew Morton
2014-02-27 21:47     ` Andrew Morton
2014-02-28  0:31     ` Kirill A. Shutemov
2014-02-28  0:31       ` Kirill A. Shutemov
2014-04-02 18:03   ` Konstantin Khlebnikov
2014-04-02 18:03     ` Konstantin Khlebnikov
2014-04-02 19:07     ` Kirill A. Shutemov
2014-04-02 19:07       ` Kirill A. Shutemov
2014-02-27 21:28 ` [PATCHv3 0/2] mm: map few pages around fault address if they are in " Linus Torvalds
2014-02-27 21:28   ` Linus Torvalds
2014-02-28  0:10   ` Kirill A. Shutemov
2014-02-28  0:10     ` Kirill A. Shutemov
2014-02-28  3:52     ` Wilcox, Matthew R
2014-02-28  3:52       ` Wilcox, Matthew R
2014-02-28 23:08     ` Linus Torvalds
2014-02-28 23:08       ` Linus Torvalds
2014-03-12 14:22   ` Kirill A. Shutemov
2014-03-12 14:22     ` Kirill A. Shutemov

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=20140304012613.GB21508@node.dhcp.inet.fi \
    --to=kirill@shutemov.name \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@fromorbit.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.r.wilcox@intel.com \
    --cc=mgorman@suse.de \
    --cc=quning@gmail.com \
    --cc=riel@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.