linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
	linux-mm <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>, Jan Kara <jack@suse.cz>,
	Mel Gorman <mgorman@techsingularity.net>,
	Peter Zijlstra <peterz@infradead.org>,
	Rik van Riel <riel@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH 2/2] mm: add PageWaiters bit to indicate waitqueue should be checked
Date: Wed, 2 Nov 2016 19:12:48 +1100	[thread overview]
Message-ID: <20161102191248.5b1dd6cd@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20161102075855.lt3323biol4cbfin@black.fi.intel.com>

On Wed, 2 Nov 2016 10:58:55 +0300
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> wrote:

> On Wed, Nov 02, 2016 at 06:50:35PM +1100, Nicholas Piggin wrote:
> > On Wed, 2 Nov 2016 10:31:57 +0300
> > "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
> >   
> > > On Wed, Nov 02, 2016 at 06:03:46PM +1100, Nicholas Piggin wrote:  
> > > > Add a new page flag, PageWaiters. This bit is always set when the
> > > > page has waiters on page_waitqueue(page), within the same synchronization
> > > > scope as waitqueue_active(page) (i.e., it is manipulated under waitqueue
> > > > lock). It may be set in some cases where that condition is not true
> > > > (e.g., some scenarios of hash collisions or signals waking page waiters).
> > > > 
> > > > This bit can be used to avoid the costly waitqueue_active test for most
> > > > cases where the page has no waiters (the hashed address effectively adds
> > > > another line of cache footprint for most page operations). In cases where
> > > > the bit is set when the page has no waiters, the slower wakeup path will
> > > > end up clearing up the bit.
> > > > 
> > > > The generic bit-waitqueue infrastructure is no longer used for pages, and
> > > > instead waitqueues are used directly with a custom key type. The generic
> > > > code was not flexible enough to do PageWaiters manipulation under waitqueue
> > > > lock, or always allow danging bits to be cleared when no waiters for this
> > > > page on the waitqueue.
> > > > 
> > > > The upshot is that the page wait is much more flexible now, and could be
> > > > easily extended to wait on other properties of the page (by carrying that
> > > > data in the wait key).
> > > > 
> > > > This improves the performance of a streaming write into a preallocated
> > > > tmpfs file by 2.2% on a POWER8 system with 64K pages (which is pretty
> > > > significant if there is only a single unlock_page per 64K of copy_from_user).
> > > > 
> > > > Idea seems to have been around for a while, https://lwn.net/Articles/233391/
> > > > 
> > > > ---
> > > >  include/linux/page-flags.h     |   2 +
> > > >  include/linux/pagemap.h        |  23 +++---
> > > >  include/trace/events/mmflags.h |   1 +
> > > >  mm/filemap.c                   | 157 ++++++++++++++++++++++++++++++++---------
> > > >  mm/swap.c                      |   2 +
> > > >  5 files changed, 138 insertions(+), 47 deletions(-)
> > > > 
> > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> > > > index 58d30b8..da40a1d 100644
> > > > --- a/include/linux/page-flags.h
> > > > +++ b/include/linux/page-flags.h
> > > > @@ -73,6 +73,7 @@
> > > >   */
> > > >  enum pageflags {
> > > >  	PG_locked,		/* Page is locked. Don't touch. */
> > > > +	PG_waiters,		/* Page has waiters, check its waitqueue */
> > > >  	PG_error,
> > > >  	PG_referenced,
> > > >  	PG_uptodate,
> > > > @@ -255,6 +256,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; }
> > > >  	TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
> > > >  
> > > >  __PAGEFLAG(Locked, locked, PF_NO_TAIL)
> > > > +PAGEFLAG(Waiters, waiters, PF_NO_COMPOUND) __CLEARPAGEFLAG(Waiters, waiters, PF_NO_COMPOUND)    
> > > 
> > > This should be at least PF_NO_TAIL to work with shmem/tmpfs huge pages.  
> > 
> > I thought all paths using it already took the head page, but I'll double
> > check. Did you see a specific problem?  
> 
> PF_NO_COMPOUND doesn't allow both head and tail pages.
> CONFIG_DEBUG_VM_PGFLAGS=y will make it expode.
> 

Oh my mistake, that should be something like PF_ONLY_HEAD, where

#define PF_ONLY_HEAD(page, enforce) ({                                    \
                VM_BUG_ON_PGFLAGS(PageTail(page), page);                  \
                page; })

Thanks,
Nick

--
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>

  reply	other threads:[~2016-11-02  8:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02  7:03 [RFC][PATCH 0/2] optimise unlock_page / end_page_writeback Nicholas Piggin
2016-11-02  7:03 ` [PATCH 1/2] mm: Use owner_priv bit for PageSwapCache, valid when PageSwapBacked Nicholas Piggin
2016-11-04  2:20   ` Hugh Dickins
2016-11-11  0:58     ` Nicholas Piggin
2016-11-02  7:03 ` [PATCH 2/2] mm: add PageWaiters bit to indicate waitqueue should be checked Nicholas Piggin
2016-11-02  7:31   ` Kirill A. Shutemov
2016-11-02  7:50     ` Nicholas Piggin
2016-11-02  7:58       ` Kirill A. Shutemov
2016-11-02  8:12         ` Nicholas Piggin [this message]
2016-11-02  8:33           ` Kirill A. Shutemov
2016-11-02  8:40             ` Nicholas Piggin
2016-11-02  9:04               ` Kirill A. Shutemov
2016-11-02 15:18   ` Linus Torvalds
2016-11-03  3:46     ` Nicholas Piggin
2016-11-03 15:49       ` Linus Torvalds
2016-11-04  2:40         ` Nicholas Piggin
2016-11-04  7:29           ` Nicholas Piggin
2016-11-04 15:59             ` Linus Torvalds
2016-11-07  3:04               ` Nicholas Piggin
2016-11-04  2:31   ` [lkp] [mm] 731b9bc419: kernel BUG at include/linux/page-flags.h:259! kernel test robot
2016-11-04  2:47     ` Nicholas Piggin
  -- strict thread matches above, loose matches on Subject: below --
2016-12-21 15:19 [PATCH 0/2] respin of PageWaiters patch Nicholas Piggin
2016-12-21 15:19 ` [PATCH 2/2] mm: add PageWaiters bit to indicate waitqueue should be checked Nicholas Piggin

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=20161102191248.5b1dd6cd@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=jack@suse.cz \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).