lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 17 Jun 2013 16:24:46 +0900
From:	Minchan Kim <minchan@...nel.org>
To:	John Stultz <john.stultz@...aro.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Android Kernel Team <kernel-team@...roid.com>,
	Robert Love <rlove@...gle.com>, Mel Gorman <mel@....ul.ie>,
	Hugh Dickins <hughd@...gle.com>,
	Dave Hansen <dave@...ux.vnet.ibm.com>,
	Rik van Riel <riel@...hat.com>,
	Dmitry Adamushko <dmitry.adamushko@...il.com>,
	Dave Chinner <david@...morbit.com>, Neil Brown <neilb@...e.de>,
	Andrea Righi <andrea@...terlinux.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
	Mike Hommey <mh@...ndium.org>, Taras Glek <tglek@...illa.com>,
	Dhaval Giani <dgiani@...illa.com>, Jan Kara <jack@...e.cz>,
	KOSAKI Motohiro <kosaki.motohiro@...il.com>,
	Michel Lespinasse <walken@...gle.com>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH 7/8] vrange: Add method to purge volatile ranges

On Mon, Jun 17, 2013 at 04:13:31PM +0900, Minchan Kim wrote:
> Hello John,
> 
> I am rewriting purging path and found a bug from this patch.
> I might forget it so I will send this comment for recording.
> 
> On Tue, Jun 11, 2013 at 09:22:50PM -0700, John Stultz wrote:
> > From: Minchan Kim <minchan@...nel.org>
> > 
> > This patch adds discarding function to purge volatile ranges under
> > memory pressure. Logic is as following:
> > 
> > 1. Memory pressure happens
> > 2. VM start to reclaim pages
> > 3. Check the page is in volatile range.
> > 4. If so, zap the page from the process's page table.
> >    (By semantic vrange(2), we should mark it with another one to
> >     make page fault when you try to access the address. It will
> >     be introduced later patch)
> > 5. If page is unmapped from all processes, discard it instead of swapping.
> > 
> > This patch does not address the case where there is no swap, which
> > keeps anonymous pages from being aged off the LRUs. Minchan has
> > additional patches that add support for purging anonymous pages
> > 
> > XXX: First pass at file purging. Seems to work, but is likely broken
> > and needs close review.
> > 
> > Cc: Andrew Morton <akpm@...ux-foundation.org>
> > Cc: Android Kernel Team <kernel-team@...roid.com>
> > Cc: Robert Love <rlove@...gle.com>
> > Cc: Mel Gorman <mel@....ul.ie>
> > Cc: Hugh Dickins <hughd@...gle.com>
> > Cc: Dave Hansen <dave@...ux.vnet.ibm.com>
> > Cc: Rik van Riel <riel@...hat.com>
> > Cc: Dmitry Adamushko <dmitry.adamushko@...il.com>
> > Cc: Dave Chinner <david@...morbit.com>
> > Cc: Neil Brown <neilb@...e.de>
> > Cc: Andrea Righi <andrea@...terlinux.com>
> > Cc: Andrea Arcangeli <aarcange@...hat.com>
> > Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
> > Cc: Mike Hommey <mh@...ndium.org>
> > Cc: Taras Glek <tglek@...illa.com>
> > Cc: Dhaval Giani <dgiani@...illa.com>
> > Cc: Jan Kara <jack@...e.cz>
> > Cc: KOSAKI Motohiro <kosaki.motohiro@...il.com>
> > Cc: Michel Lespinasse <walken@...gle.com>
> > Cc: Minchan Kim <minchan@...nel.org>
> > Cc: linux-mm@...ck.org <linux-mm@...ck.org>
> > Signed-off-by: Minchan Kim <minchan@...nel.org>
> > [jstultz: Reworked to add purging of file pages, commit log tweaks]
> > Signed-off-by: John Stultz <john.stultz@...aro.org>
> > ---
> >  include/linux/rmap.h   |  12 +-
> >  include/linux/swap.h   |   1 +
> >  include/linux/vrange.h |   7 ++
> >  mm/ksm.c               |   2 +-
> >  mm/rmap.c              |  30 +++--
> >  mm/swapfile.c          |  36 ++++++
> >  mm/vmscan.c            |  16 ++-
> >  mm/vrange.c            | 332 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  8 files changed, 420 insertions(+), 16 deletions(-)
> > 
> > diff --git a/include/linux/rmap.h b/include/linux/rmap.h
> > index 6dacb93..6432dfb 100644
> > --- a/include/linux/rmap.h
> > +++ b/include/linux/rmap.h
> > @@ -83,6 +83,8 @@ enum ttu_flags {
> >  };
> >  
> 
> < snip >
> 
> > @@ -662,7 +663,7 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
> >   */
> >  int page_referenced_one(struct page *page, struct vm_area_struct *vma,
> >  			unsigned long address, unsigned int *mapcount,
> > -			unsigned long *vm_flags)
> > +			unsigned long *vm_flags, int *is_vrange)
> >  {
> >  	struct mm_struct *mm = vma->vm_mm;
> >  	int referenced = 0;
> > @@ -724,6 +725,9 @@ int page_referenced_one(struct page *page, struct vm_area_struct *vma,
> >  				referenced++;
> >  		}
> >  		pte_unmap_unlock(pte, ptl);
> > +		if (is_vrange &&
> > +			vrange_address(mm, address, address + PAGE_SIZE - 1))
> > +			*is_vrange = 1;
> 
> < snip >
> 
> > +static bool __vrange_address(struct vrange_root *vroot,
> > +			unsigned long start, unsigned long end)
> > +{
> > +	struct interval_tree_node *node;
> > +
> > +	node = interval_tree_iter_first(&vroot->v_rb, start, end);
> > +	return node ? true : false;
> > +}
> > +
> > +bool vrange_address(struct mm_struct *mm,
> > +			unsigned long start, unsigned long end)
> > +{
> > +	struct vrange_root *vroot;
> > +	unsigned long vstart_idx, vend_idx;
> > +	struct vm_area_struct *vma;
> > +	bool ret;
> > +
> > +	vma = find_vma(mm, start);
> 
> It seems to be tweaked by you while you are refactoring with file-vrange
> The problem of the code is that you couldn't use vma without holding
> the lock of mmap_sem and you couldn't use the lock in purging path
> because you couldn't know other tasks's state so it might be a dealock
> if you try to hold a lock.

It was sent by mistake with not completing. :(
Exactly speaking, the find_vma is a problem and we don't need it.
Couldn't we pass just vma, NOT mm?
Have you seen any problem?

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ