Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753411AbbKLEuV (ORCPT ); Wed, 11 Nov 2015 23:50:21 -0500 Received: from mail-ob0-f175.google.com ([209.85.214.175]:34751 "EHLO mail-ob0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753241AbbKLEuS (ORCPT ); Wed, 11 Nov 2015 23:50:18 -0500 MIME-Version: 1.0 In-Reply-To: <1447302793-5376-2-git-send-email-minchan@kernel.org> References: <1447302793-5376-1-git-send-email-minchan@kernel.org> <1447302793-5376-2-git-send-email-minchan@kernel.org> From: Andy Lutomirski Date: Wed, 11 Nov 2015 20:49:58 -0800 Message-ID: Subject: Re: [PATCH v3 01/17] mm: support madvise(MADV_FREE) To: Minchan Kim Cc: Andrew Morton , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Michael Kerrisk , Linux API , Hugh Dickins , Johannes Weiner , Rik van Riel , Mel Gorman , KOSAKI Motohiro , Jason Evans , Daniel Micay , "Kirill A. Shutemov" , Shaohua Li , Michal Hocko , yalin wang Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1682 Lines: 37 On Wed, Nov 11, 2015 at 8:32 PM, 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 discard freed pages rather than swapping > out or OOM if memory pressure happens. > > When madvise syscall is called, VM clears dirty bit of ptes of the range. > If memory pressure happens, VM checks dirty bit of page table and if it > found still "clean", it means it's a "lazyfree pages" so VM could discard > the page instead of swapping out. Once there was store operation for the > page before VM peek a page to reclaim, dirty bit is set so VM can swap out > the page instead of discarding. > I realize that this lends itself to an efficient implementation, but it's certainly the case that the kernel *could* use the accessed bit instead of the dirty bit to give more sensible user semantics, and the semantics that rely on the dirty bit make me uncomfortable from an ABI perspective. I also think that the kernel should commit to either zeroing the page or leaving it unchanged in response to MADV_FREE (even if the decision of which to do is made later on). I think that your patch series does this, but only after a few of the patches are applied (the swap entry freeing), and I think that it should be a real guaranteed part of the semantics and maybe have a test case. --Andy -- 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/