Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753484Ab2JJALI (ORCPT ); Tue, 9 Oct 2012 20:11:08 -0400 Received: from LGEMRELSE1Q.lge.com ([156.147.1.111]:64316 "EHLO LGEMRELSE1Q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554Ab2JJALF (ORCPT ); Tue, 9 Oct 2012 20:11:05 -0400 X-AuditID: 9c93016f-b7b1eae000000815-85-5074bd13b75f Date: Wed, 10 Oct 2012 09:15:14 +0900 From: Minchan Kim To: John Stultz Cc: Mike Hommey , LKML , Andrew Morton , Android Kernel Team , Robert Love , Mel Gorman , Hugh Dickins , Dave Hansen , Rik van Riel , Dmitry Adamushko , Dave Chinner , Neil Brown , Andrea Righi , "Aneesh Kumar K.V" , Taras Glek , Jan Kara , KOSAKI Motohiro , Michel Lespinasse , "linux-mm@kvack.org" Subject: Re: [PATCH 0/3] Volatile Ranges (v7) & Lots of words Message-ID: <20121010001514.GJ13817@bbox> References: <1348888593-23047-1-git-send-email-john.stultz@linaro.org> <20121009080735.GA24375@glandium.org> <5074975B.20809@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5074975B.20809@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2856 Lines: 66 On Tue, Oct 09, 2012 at 02:30:03PM -0700, John Stultz wrote: > On 10/09/2012 01:07 AM, Mike Hommey wrote: > >Note it doesn't have to be a vs. situation. madvise could be an > >additional way to interface with volatile ranges on a given fd. > > > >That is, madvise doesn't have to mean anonymous memory. As a matter of > >fact, MADV_WILLNEED/MADV_DONTNEED are usually used on mmaped files. > >Similarly, there could be a way to use madvise to mark volatile ranges, > >without the application having to track what memory ranges are > >associated to what part of what file, which the kernel already tracks. > > Good point. We could add madvise() interface, but limit it only to > mmapped tmpfs files, in parallel with the fallocate() interface. > > However, I would like to think through how MADV_MARK_VOLATILE with > purely anonymous memory could work, before starting that approach. > That and Neil's point that having an identical kernel interface > restricted to tmpfs, only as a convenience to userland in switching > from virtual address to/from mmapped file offset may be better left > to a userland library. How about this? The scenario I imagine about madvise semantic following as. 1) Anonymous pages Assume that there is some allocator library which manage mmaped reserved pool. If it has lots of free memory which isn't used by anyone, it can unmap part of reserved pool but unmap isn't cheap because kernel should zap all ptes of the pages in the range. But if we avoid unmap, VM would swap out that range which have just garbage unnecessary when memory pressure happens. If it mark that range volatile, we can avoid unnecessary swap out and even reclaim them with no swap. Only thing allocator have to do is unmark that range before allocating to user. 2) File pages(NOT tmpfs) We can reclaim volatile file pages easily without recycling of LRU although it is accessed recently. The difference with DONTNEED is that DONTNEED always move pages to tail of inactive LRU to reclaim early but VOLATILE semantic leave them as it is without moving to tail and reclaim them without considering recently-used when they reach at tail of LRU by aging because they can be unmarked sooner or later for using and we can't expect cost of recreating of the object. So reclaim preference : NORMAL < VOLATILE < DONTNEED > > thanks > -john > > -- > 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: email@kvack.org -- Kind regards, Minchan Kim -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/