Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp507150ybf; Fri, 28 Feb 2020 02:17:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyMc/ojYpHUB9jp7kh6ZPZgFh4Tx4mOT2M4qAUKG7tEtt9tbNo2+zQNa20KrxR3SbZrW8Hg X-Received: by 2002:aca:47c8:: with SMTP id u191mr2604722oia.17.1582885019890; Fri, 28 Feb 2020 02:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582885019; cv=none; d=google.com; s=arc-20160816; b=00vroSEionpy4kT8unep/QyLgkdODvoEosiJxu8Ra+xd4+IGqcCHIZOEkrNdqS4TwU hBhRVHqXoTTTJj0oj8Dg5WLw4wB33QxAMMCGX7uH6Kv3k1gJp69RVQk+oDQvEaotk2dV pqNMMwH51HvJyk8KK7nZmjjFhHSRE08T3dv0v6ewzAC1pnet/uoGceRmyhJlC71gf3cx 62vuvQ0CKf1+trWC56Qnde7ZXssudA68hEI4SJAyCV2Z2cBTJ0eTuNyOE9kDz1GoxETF 1z5ejF9uVo5Io9oUAP9nE6Buv3AHNLkPn43sO/+6aGBsljUdqNy6fcjKhj5I7ElCFzAK uC7g== 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; bh=N1sfoWU8RpBx2/Ft/g0pxbyKx3NRAm+lIucU0nBhEa4=; b=UHZA38LTv5eo5hdXqnK4OT6DjJiCnwTSAVVhC60SurAzA8pbksHWYcAzXPiYFMZw7+ CArHoEloh5MjKX5wkq7QkuAA9EuHTqmbR6A+mLkTGe0HsCysh/zOOOQMH6e3Ioe1bi4P LoP8hBlSZaHounKHz4ps7VWzxHChORWwt0/0ZXV1Hi3ylAKBuTqGn0NNZJzyrPpLZVWP 27vEaYGrcdZksdzbQqZsq+7KCzP82ha4l3pxd3rQaawK8jbnIY/2CH3Y9I2ptsu6fEmV Uwbpd3/cSmUTya4E5oK+cVPSzM+DjHQ3e82krNLmyJhP3PeVsPUeDVwBSIatm/LW/Q/7 yzwg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si1284417otd.245.2020.02.28.02.16.48; Fri, 28 Feb 2020 02:16:59 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbgB1KPU (ORCPT + 99 others); Fri, 28 Feb 2020 05:15:20 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38750 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgB1KPU (ORCPT ); Fri, 28 Feb 2020 05:15:20 -0500 Received: by mail-wr1-f68.google.com with SMTP id e8so2306153wrm.5 for ; Fri, 28 Feb 2020 02:15:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=N1sfoWU8RpBx2/Ft/g0pxbyKx3NRAm+lIucU0nBhEa4=; b=JcM2rwwQFW4ECHFkXe/GQ+99/RoEycOKrZUjchhbGrXe7m9Bg0PdS9G82laTqXSC+Y wadd9u7bZAAOIqe+3es59GTYoDeK1uX3Hs3AndNk4PPTt43WckA7zLKfWP4ndYgeagvT gE80ctihoTawUuIZ3MaE2P+gzyLkXozkYUUlJ0t1p2v6MAwHaOx+1snhhez7fF65oLeA 7EJoAmPag3S85UM3vWZNwqO2rE36cXU1exM/T97ljSCiDgRsPxqnIhdjslf548Ugs58N 8x2kRI7Tyu6cwiD0tZxdqV0GIhuKOi8U4dW8d4fuWIxGhdvSt6oonUDmjAiyEnFn4ZBc OeWw== X-Gm-Message-State: APjAAAVMAua1hAQdLsUteHrp73CJ5/J9Yfo7EX6BaFjBWWxVIWCEin6A C3Mq3lIlyiRXlGTuwXae3ZM= X-Received: by 2002:a5d:69d1:: with SMTP id s17mr4146926wrw.339.1582884918770; Fri, 28 Feb 2020 02:15:18 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id g14sm12501588wrv.58.2020.02.28.02.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 02:15:17 -0800 (PST) Date: Fri, 28 Feb 2020 11:15:17 +0100 From: Michal Hocko To: "Huang, Ying" Cc: David Hildenbrand , Matthew Wilcox , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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 Message-ID: <20200228101517.GM3771@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200228095048.GK3771@dhcp22.suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 28-02-20 10:50:50, Michal Hocko wrote: > 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. And MADV_FREE > pages are a kind of cache as well. If the target node is short on memory > then those will be reclaimed as a cache so a pro-active freeing sounds > counter productive as you do not have any idea whether that cache is > going to be used in future. In other words you are not going to free a > clean page cache if you want to use that memory as a migration target sorry I meant to say that you are not going to clean page cache when migrating it. > right? So you should make a clear case about why MADV_FREE cache is less > important than the clean page cache and ideally have a good > justification backed by real workloads. -- Michal Hocko SUSE Labs