All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Hugh Dickins <hughd@google.com>,
	Dave Hansen <dave.hansen@intel.com>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	John Stultz <john.stultz@linaro.org>, Jason Evans <je@fb.com>
Subject: Re: [RFC 3/6] mm: support madvise(MADV_FREE)
Date: Wed, 19 Mar 2014 10:22:48 +0900	[thread overview]
Message-ID: <20140319012248.GD13475@bbox> (raw)
In-Reply-To: <20140318182621.GH14688@cmpxchg.org>

Hello Hannes,

On Tue, Mar 18, 2014 at 02:26:21PM -0400, Johannes Weiner wrote:
> On Fri, Mar 14, 2014 at 03:37:47PM +0900, Minchan Kim wrote:
> > Linux doesn't have an ability to free pages lazy while other OS
> > already have been supported that named by madvise(MADV_FREE).
> > 
> > The gain is clear that kernel can evict freed pages rather than
> > swapping out or OOM if memory pressure happens.
> > 
> > Without memory pressure, freed pages would be reused by userspace
> > without another additional overhead(ex, page fault + + page allocation
> > + page zeroing).
> > 
> > Firstly, heavy users would be general allocators(ex, jemalloc,
> > I hope ptmalloc support it) and jemalloc already have supported
> > the feature for other OS(ex, FreeBSD)
> > 
> > At the moment, this patch would break build other ARCHs which have
> > own TLB flush scheme other than that x86 but if there is no objection
> > in this direction, I will add patches for handling other ARCHs
> > in next iteration.
> > 
> > Signed-off-by: Minchan Kim <minchan@kernel.org>
> 
> > @@ -284,8 +286,17 @@ static long madvise_dontneed(struct vm_area_struct *vma,
> >  			.last_index = ULONG_MAX,
> >  		};
> >  		zap_page_range(vma, start, end - start, &details);
> > +	} else if (behavior == MADV_FREE) {
> > +		struct zap_details details = {
> > +			.lazy_free = 1,
> > +		};
> > +
> > +		if (vma->vm_file)
> > +			return -EINVAL;
> > +		zap_page_range(vma, start, end - start, &details);
> 
> Wouldn't a custom page table walker to clear dirty bits and move pages
> be better?  It's awkward to hook this into the freeing code and then
> special case the pages and not actually free them.

NP.

> 
> > @@ -817,6 +817,25 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> >  
> >  		sc->nr_scanned++;
> >  
> > +		if (PageLazyFree(page)) {
> > +			switch (try_to_unmap(page, ttu_flags)) {
> 
> I don't get why we need a page flag for this.  page_check_references()
> could use the rmap walk to also check if any pte/pmd is dirty.  If so,
> you have to swap the page.  If all are clean, it can be discarded.

Ugh, you're right. I guess it could work.
I will look into that in next iteration.

Thanks!

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

-- 
Kind regards,
Minchan Kim

--
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:[~2014-03-19  1:22 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14  6:37 [RFC 0/6] mm: support madvise(MADV_FREE) Minchan Kim
2014-03-14  6:37 ` Minchan Kim
2014-03-14  6:37 ` [RFC 1/6] mm: clean up PAGE_MAPPING_FLAGS Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  6:37 ` [RFC 2/6] mm: work deactivate_page with anon pages Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  6:37 ` [RFC 3/6] mm: support madvise(MADV_FREE) Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  7:49   ` Minchan Kim
2014-03-14  7:49     ` Minchan Kim
2014-03-14 13:33   ` Kirill A. Shutemov
2014-03-14 13:33     ` Kirill A. Shutemov
2014-03-14 15:24     ` Minchan Kim
2014-03-14 15:24       ` Minchan Kim
2014-03-18 18:26   ` Johannes Weiner
2014-03-18 18:26     ` Johannes Weiner
2014-03-19  1:22     ` Minchan Kim [this message]
2014-03-14  6:37 ` [RFC 4/6] mm: add stat about lazyfree pages Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  6:37 ` [RFC 5/6] mm: reclaim lazyfree pages in swapless system Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  6:37 ` [RFC 6/6] mm: ksm: don't merge lazyfree page Minchan Kim
2014-03-14  6:37   ` Minchan Kim
2014-03-14  7:37 ` [RFC 0/6] mm: support madvise(MADV_FREE) Zhang Yanfei
2014-03-14  7:37   ` Zhang Yanfei
2014-03-14  7:56   ` Minchan Kim
2014-03-14  7:56     ` Minchan Kim
2014-03-18 17:55 ` Andy Lutomirski
2014-03-18 17:55   ` Andy Lutomirski
2014-03-19  0:18   ` Minchan Kim
2014-03-19  0:23     ` Andy Lutomirski
2014-03-19  0:23       ` Andy Lutomirski
2014-03-19  1:02       ` Minchan Kim
2014-03-19  5:15       ` Johannes Weiner
2014-03-19  5:15         ` Johannes Weiner

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=20140319012248.GD13475@bbox \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=je@fb.com \
    --cc=john.stultz@linaro.org \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=riel@redhat.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 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.