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 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 C5406C3F2CD for ; Tue, 3 Mar 2020 00:25:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 915982465E for ; Tue, 3 Mar 2020 00:25:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 915982465E 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 436BF6B0008; Mon, 2 Mar 2020 19:25:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E7B26B000A; Mon, 2 Mar 2020 19:25:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 324766B000C; Mon, 2 Mar 2020 19:25:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 1B2DE6B0008 for ; Mon, 2 Mar 2020 19:25:49 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EF69D10F86 for ; Tue, 3 Mar 2020 00:25:48 +0000 (UTC) X-FDA: 76552157976.17.route97_159686339ab22 X-HE-Tag: route97_159686339ab22 X-Filterd-Recvd-Size: 4305 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Mar 2020 00:25:48 +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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 16:25:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,509,1574150400"; d="scan'208";a="273968558" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by fmsmga002.fm.intel.com with ESMTP; 02 Mar 2020 16:25:43 -0800 From: "Huang\, Ying" To: David Hildenbrand Cc: Michal Hocko , Matthew Wilcox , Andrew Morton , , , Mel Gorman , Vlastimil Babka , Zi Yan , Peter Zijlstra , Dave Hansen , "Minchan Kim" , Johannes Weiner , Hugh Dickins , Alexander Duyck 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> <87a7538977.fsf@yhuang-dev.intel.com> <871rqf850z.fsf@yhuang-dev.intel.com> <20200228095048.GK3771@dhcp22.suse.cz> <87d09u7sm2.fsf@yhuang-dev.intel.com> <8005e5a1-e2f2-1e57-ccb4-0cb9371b080d@redhat.com> Date: Tue, 03 Mar 2020 08:25:43 +0800 In-Reply-To: <8005e5a1-e2f2-1e57-ccb4-0cb9371b080d@redhat.com> (David Hildenbrand's message of "Mon, 2 Mar 2020 15:23:16 +0100") Message-ID: <878ski708o.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: David Hildenbrand writes: > On 02.03.20 15:12, Huang, Ying wrote: >> Michal Hocko writes: >> >>> On Fri 28-02-20 16:55:40, Huang, Ying wrote: >>>> David Hildenbrand writes: >>> [...] >>>>> E.g., free page reporting in QEMU wants to use MADV_FREE. The guest will >>>>> report currently free pages to the hypervisor, which will MADV_FREE the >>>>> reported memory. As long as there is no memory pressure, there is no >>>>> need to actually free the pages. Once the guest reuses such a page, it >>>>> could happen that there is still the old page and pulling in in a fresh >>>>> (zeroed) page can be avoided. >>>>> >>>>> AFAIKs, after your change, we would get more pages discarded from our >>>>> guest, resulting in more fresh (zeroed) pages having to be pulled in >>>>> when a guest touches a reported free page again. But OTOH, page >>>>> migration is speed up (avoiding to migrate these pages). >>>> >>>> Let's look at this problem in another perspective. To migrate the >>>> MADV_FREE pages of the QEMU process from the node A to the node B, we >>>> need to free the original pages in the node A, and (maybe) allocate the >>>> same number of pages in the node B. So the question becomes >>>> >>>> - we may need to allocate some pages in the node B >>>> - these pages may be accessed by the application or not >>>> - we should allocate all these pages in advance or allocate them lazily >>>> when they are accessed. >>>> >>>> We thought the common philosophy in Linux kernel is to allocate lazily. >>> >>> The common philosophy is to cache as much as possible. >> >> Yes. This is another common philosophy. And MADV_FREE pages is >> different from caches such as the page caches because it has no valid >> contents. > > Side note: It might contain valid content until discarded/zeroed out. > E.g., an application could use a marker bit (e.g., first bit) to detect > if the page still contains valid data or not. If the data is still > marked valid, the content could be reuse immediately. Not sure if there > is any such application, though :) I don't think this is the typical use case. But I admit that this is possible. Best Regards, Huang, Ying