Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp221285ybf; Thu, 27 Feb 2020 19:44:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyHVwRYKdoCn90dv6bDty5E12QaRrUxWjgjArd0QLNAhHDFkcD7uePLAh+VoJddnc+p1xka X-Received: by 2002:aca:4e10:: with SMTP id c16mr1693461oib.6.1582861457572; Thu, 27 Feb 2020 19:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582861457; cv=none; d=google.com; s=arc-20160816; b=Lke1rpNbF3keXN+qOpsnDy51Pu5BGA5/GrAmHhITgLGW762yymV0gRTnlUjsR5Lzmy TCSkSr+lZ+utsfvy+kPP44GfuH8BuMIPzeOAJtQ5DzZ2bAEdCHXPd5TOjR/0LU2iX/fJ Wv7unYpgrv/qOdFsGbS2e3cRTcXitsJG6B8VDfpyos37ZNF2+YECnCp1jSO5hION6SxO OpWBNkh+bLjF0aSUu/6i1nCY8X0MJa9Q9XIzYFbyUXYBkchVhzhyhdK6Ax7PZPhVfQP6 //8iOriMhg6nJBoEWSJ4onY/hf7aU37hgKd6/mi4cZnu0hLlaR0gcIP7GPbGrfk022Gi Tnag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=SorkXSQyHVFqXiBzU6ChGVstv5nQC7vtybcab5vAzZQ=; b=RBV6tycwbnU5oAEvNLECDF1KE93G4AWb5v+ko+wBQOfehSGqjxEvIwoA4yTCW6xGFx Bw8jk4CQen/UYE8OZXrtrHYE7HKHYKGomYDL4bm/8iPf82shChZ9LPm4m+eL4VZXsAc5 xMRKf23wCXIzkvUHH3KCNxcp5Nj5DqkTmNtGKXNpFWhXdcizCGln6eaTteS+X2N/9ZVW sVKFkXm4OiWskJAZts2162bjjrWk98wKAEDN+E/spT1lNrZZGDfRGWu6Sn1ssY/c9CfN WTvTV8ymDYpMbPoM78aMIm03F7XKQvuEOy5+09MKJYuSl3agggZgdO1yFdUERJPYO6BU +2GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PrwiOPtF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si851676otf.257.2020.02.27.19.44.05; Thu, 27 Feb 2020 19:44:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PrwiOPtF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730822AbgB1Dmw (ORCPT + 99 others); Thu, 27 Feb 2020 22:42:52 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42104 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730586AbgB1Dmw (ORCPT ); Thu, 27 Feb 2020 22:42:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SorkXSQyHVFqXiBzU6ChGVstv5nQC7vtybcab5vAzZQ=; b=PrwiOPtFyyIzy115nfdPW77hCd 2pCQCdbsaNz9X9vQFk1rhdEqJvGggUmOXriIAnfF98EIVos5VDeNA2nc3wFuXld3G+xMV2AKkgRdy NrwQOFsxfdpv6vO/Y1zt3rRLxxqySeehc62tv5RGVf7sAIHtLXgJG59+csJ/OTYMP1NxEH+UvQ/al MhwPsy4gMb5m9s63zmXXddeEXHedXvMzLwJsboi0MlFEDVWSjHkmsMcN60Qy3LPqm7iqiGhN8ZNfI ApqtIiyf083m1Cxujpp4PM030y06HGwps8F8Km0ZSZ6EeIJ7D53Nk6O9hi0aNjXv3+uThGdivtHie HKCVdJdw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7WY4-0006gR-7A; Fri, 28 Feb 2020 03:42:48 +0000 Date: Thu, 27 Feb 2020 19:42:48 -0800 From: Matthew Wilcox To: "Huang, Ying" Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand , Mel Gorman , Vlastimil Babka , Zi Yan , Michal Hocko , Peter Zijlstra , Dave Hansen , Minchan Kim , Johannes Weiner , Hugh Dickins Subject: Re: [RFC 0/3] mm: Discard lazily freed pages when migrating Message-ID: <20200228034248.GE29971@bombadil.infradead.org> References: <20200228033819.3857058-1-ying.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200228033819.3857058-1-ying.huang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 28, 2020 at 11:38:16AM +0800, Huang, Ying wrote: > MADV_FREE is a lazy free mechanism in Linux. According to the manpage > of mavise(2), the semantics of MADV_FREE is, > > The application no longer requires the pages in the range specified > by addr and len. The kernel can thus free these pages, but the > freeing could be delayed until memory pressure occurs. ... > > Originally, the pages freed lazily by MADV_FREE will only be freed > really by page reclaiming when there is memory pressure or when > unmapping the address range. In addition to that, there's another > opportunity to free these pages really, when we try to migrate them. > > The main value to do that is to avoid to create the new memory > pressure immediately if possible. Instead, even if the pages are > required again, they will be allocated gradually on demand. That is, > the memory will be allocated lazily when necessary. This follows the > common philosophy in the Linux kernel, allocate resources lazily on > demand. Do you have an example program which does this (and so benefits)? If so, can you quantify the benefit at all?