Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp379768ybf; Thu, 27 Feb 2020 23:26:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzP0PMlGri7r6yQ0JzQ4D6G1/Usnbbb7lN2mVAMT4ILDnh9QAAZz/Kuiy4XwSGOsck32S2q X-Received: by 2002:a9d:615d:: with SMTP id c29mr1567993otk.100.1582874763378; Thu, 27 Feb 2020 23:26:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582874763; cv=none; d=google.com; s=arc-20160816; b=YwaeuXVG3UkQL0FigoK8cMadhgq8jQikvoUIefb/wQQHUiaF+2rQEyS8hqvIbzUJK0 /PsoQPnid/kEfwC1OFhIl117y27jhTdYN2mNVY0aFJ20ofS4SACGLCAroiSTAwxrMhea e0sTGndCVjp+5SontUOH5Q9i2LkolHyjFERkDGp4OCwjwT/J7nv4RVDHamL6/HoX/jtC DZmi9YF9JYQrAhKCh/fDqdu8+ow7cjw9m8yHrCrE+DzL2pgDNZDH6CeBXZD8HCq6Gp6n w1YykgWkGRC/stWv7CCICVciemLqmIIafWUxfvrvphRIXrpgnj+3DXx18R0Or0bxLWGB WQSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=+xvUw2eLHpP7/jYHicEBu1SCblxlHnuT2Glp2jcEc1A=; b=X/MpfIk63DrtZ3k/73px+V7W1+/5tgxUdyvS70mRcINWMFV+mnuowdGkCClHug5q0u JHYwrLBbMfbtoOEoUPikurWVdXCcaTgkbirpyQTe1yKczj0LHUqqvkhxR5FSlYL6ccrp TanDkv8poT/Y/T1ACfN5wh7C4szx77/i4LuKtYqIUy5t7lLGwLDpADTxC+JcosdlxaCE uPm5bLfJFnaqvLZdzC99hxXewFGYA4hCQTTzw2e4DcjzpQzTkLsbM+AMCYxtr7VUf8Iy wrJENN30LYdsULdckaKl5zGyHRWs5MxdQUD3NHoxTU9UN5Xjj1tiTk24+C4gVeX80kUM 6MqQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si1135112otg.179.2020.02.27.23.25.50; Thu, 27 Feb 2020 23:26:03 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbgB1HZh (ORCPT + 99 others); Fri, 28 Feb 2020 02:25:37 -0500 Received: from mga02.intel.com ([134.134.136.20]:53396 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726880AbgB1HZh (ORCPT ); Fri, 28 Feb 2020 02:25:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2020 23:25:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,493,1574150400"; d="scan'208";a="272544608" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga002.fm.intel.com with ESMTP; 27 Feb 2020 23:25:32 -0800 From: "Huang\, Ying" To: Matthew Wilcox Cc: Andrew Morton , , , 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 References: <20200228033819.3857058-1-ying.huang@intel.com> <20200228034248.GE29971@bombadil.infradead.org> Date: Fri, 28 Feb 2020 15:25:32 +0800 In-Reply-To: <20200228034248.GE29971@bombadil.infradead.org> (Matthew Wilcox's message of "Thu, 27 Feb 2020 19:42:48 -0800") Message-ID: <87a7538977.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Matthew, Matthew Wilcox writes: > 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)? Sorry, what do you mean exactly for "this" here? Call madvise(,,MADV_FREE)? Or migrate pages? > If so, can you quantify the benefit at all? The question is what is the right workload? For example, I can build a scenario as below to show benefit. - run program A in node 0 with many lazily freed pages - run program B in node 1, so that the free memory on node 1 is low - migrate the program A from node 0 to node 1, so that the program B is influenced by the memory pressure created by migrating lazily freed pages. Best Regards, Huang, Ying