From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD3AC3F2CF for ; Fri, 28 Feb 2020 07:25:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD35E2469C for ; Fri, 28 Feb 2020 07:25:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD35E2469C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4984F6B0005; Fri, 28 Feb 2020 02:25:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4476F6B0006; Fri, 28 Feb 2020 02:25:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 384396B0007; Fri, 28 Feb 2020 02:25:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 20D236B0005 for ; Fri, 28 Feb 2020 02:25:39 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CC0AD2C8B for ; Fri, 28 Feb 2020 07:25:38 +0000 (UTC) X-FDA: 76538700756.07.jelly64_6b6e5bf634a40 X-HE-Tag: jelly64_6b6e5bf634a40 X-Filterd-Recvd-Size: 3502 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 28 Feb 2020 07:25:38 +0000 (UTC) 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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