Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2323410ybf; Mon, 2 Mar 2020 06:26:19 -0800 (PST) X-Google-Smtp-Source: APXvYqyE9pXFZ+wh2+xY/KwcoEidMRpWe5JTCKlZeFEhFqftukD2X1GI5R6x1T7FPxB/BtoAq9aQ X-Received: by 2002:a9d:12a2:: with SMTP id g31mr13851450otg.283.1583159178910; Mon, 02 Mar 2020 06:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583159178; cv=none; d=google.com; s=arc-20160816; b=MYUKegci7WQOFVO08thG5PzeI/8Hr8/WKt37ZLkefZgT28nRxYfY/B8vdlFDjBRSG7 MZhuwqM9b+b30hQK+4VURhMahOnUXlYgfmSHjK2SoBGSde5I1D6hUtRjwRp2Nbt57euh 5JgaQ2jq6HQatTIgaW0KrmT/WQp2C/yR3JTfKQyUg9U5T1SxUR3oAVqboGbkpXPJ/Fys kyhdnNvNxiB2Y5ZBSA6eOSpdIhRJfePpZtMScM4tDPR7zIncjNFFv4OdTl+ZuVJAMaID 0af6KjbfJ/MBbd+J0DHktXNFB69I68RAK/zIkQoVgM5z7GGa75Y4kd1ZSeeOoW9nmPbU byyQ== 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=91i00x+r3ObU17/Jn02LmIVt8253x20peMqSjQ89ikI=; b=twRkdpBGQ1idbCJROQbqGYzCjUDsDORPJCf4AkmDjqgP8u3icPTd/pbSO07a7yTMzU FzhoKwjBaySFgUac3jcilJ6DcHcHw9oKjvxRmRmJVFlQjdOVJBi9r5PHPiQWSvS2roEx pr57u63ep154CQoRW6609ga069v58ECmv5oUwIjiSmMI5GFn6hNp/xWHRDJaw8fyRX34 ApkKGDtK0ZXVNwQpa47TcWID9jvoev+HevXopaYoMppROWlDygssh5OuhgwGIWWvjhSr sD2/DDj1MQCWQtT/Pw8gS93R5OjHUF4Z5uW6fYMEx4bpK6/i88myO28DSL5oSe2secuc 4XOA== 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 v21si5981064otp.189.2020.03.02.06.26.06; Mon, 02 Mar 2020 06:26:18 -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 S1727316AbgCBOZy (ORCPT + 99 others); Mon, 2 Mar 2020 09:25:54 -0500 Received: from mail-wr1-f48.google.com ([209.85.221.48]:46326 "EHLO mail-wr1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727306AbgCBOZx (ORCPT ); Mon, 2 Mar 2020 09:25:53 -0500 Received: by mail-wr1-f48.google.com with SMTP id j7so12749099wrp.13 for ; Mon, 02 Mar 2020 06:25:51 -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=91i00x+r3ObU17/Jn02LmIVt8253x20peMqSjQ89ikI=; b=uP9ETzMp5LSht6suRXGaPQBDmuKMfa42FlUlgv2DAi77X5ZjtiQ9/mE3L+YAhpKJx8 fh+TgBtTR9xv5GVWSZSb04hVxppKC8sa+nwhGRldsO3Wb7piMkfRqC3g1FjBDN6IDezT 1Q+f4K6/HGKVfZfu+mtWa8U8ZFTVk8QCD6XptNDjNZ8XbAaLuVfsWtlvYWrFDCRS/pcY YEN2XQ/Z8YmCQQuWPgtybiFlVB3/M1JQ0r+qEArlT83AU1C3q6BJ2YjVCf1y0FcuCEfc hBBxMvHFciJ89p92YvfHqc0KhAqNh3XV7YpxHg4iO5/kfRUqofFqmCpqKrkPgxWXGHss RAug== X-Gm-Message-State: APjAAAXN0Y83Ai6f84GCScSFYsiuMwOslSJeq2eiEkMoiqFOCK5vv70J APcyLg/dKid1QBobmhSpTrQ= X-Received: by 2002:a5d:5286:: with SMTP id c6mr16208977wrv.418.1583159151203; Mon, 02 Mar 2020 06:25:51 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id q12sm30065989wrg.71.2020.03.02.06.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 06:25:50 -0800 (PST) Date: Mon, 2 Mar 2020 15:25:49 +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: <20200302142549.GO4380@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> <87d09u7sm2.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d09u7sm2.fsf@yhuang-dev.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 02-03-20 22:12:53, Huang, Ying wrote: > Michal Hocko writes: [...] > > 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 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. > > Clean page cache still have valid contents, while clean MADV_FREE pages > has no valid contents. So penalty of discarding the clean page cache is > reading from disk, while the penalty of discarding clean MADV_FREE pages > is just page allocation and zeroing. And "just page allocation and zeroing" overhead is the primary motivation to keep the page in memory. It is a decision of the workload to use MADV_FREE because chances are that this will speed things up. All that with a contract that the memory goes away under memory pressure so with a good workload/memory sizing you do not really lose that optimization. Now you want to make decision on behalf of the consumer of the MADV_FREE memory. > I understand that MADV_FREE is another kind of cache and has its value. > But in the original implementation, during migration, we have already > freed the original "cache", then reallocate the cache elsewhere and > copy. This appears more like all pages are populated in mmap() always. > I know there's value to populate all pages in mmap(), but does that need > to be done always by default? It is not. You have to explicitly request MAP_POPULATE to initialize mmap. -- Michal Hocko SUSE Labs