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=-1.0 required=3.0 tests=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 9A578C3F2D1 for ; Mon, 2 Mar 2020 14:25:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6646B214DB for ; Mon, 2 Mar 2020 14:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6646B214DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 113A06B0003; Mon, 2 Mar 2020 09:25:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C4736B0005; Mon, 2 Mar 2020 09:25:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECDE26B0006; Mon, 2 Mar 2020 09:25:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id D70406B0003 for ; Mon, 2 Mar 2020 09:25:52 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8BB0F8245571 for ; Mon, 2 Mar 2020 14:25:52 +0000 (UTC) X-FDA: 76550646144.11.beef85_1629bff938c38 X-HE-Tag: beef85_1629bff938c38 X-Filterd-Recvd-Size: 4810 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 2 Mar 2020 14:25:52 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id q8so45885wrm.4 for ; Mon, 02 Mar 2020 06:25:52 -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=F8gIAoBE+sGZDTlnAPF8/27lCcH1T5L7MMTPdpSHF4ZZCHWancBOpKe3h09oduE0wC Ooyb3LsYxkBHxXL8hWvqogSShavRTvLx1UItFgezz8aR8sSZhEBEBXvP3Pkhy5RkaDYW Bm61W6n6jwj+597d9Cz+ZsxUj6gwu8rv881hIFLUfOsimtCCKktbGmNjoXTXPj7+pizD 3CoA6IjcM5EPFiQ/Z2195xQVNlW09MugK3cxkNMBTdgk4Yn42SJNWgExGPLYCtX5KmR2 6WEgVGf4IQRAxyPxagx8KJeIvbzzCJQ6naDq4MbHd9tUpkcvnR0LcKUaNY45LkGBGD0S F4Zw== X-Gm-Message-State: APjAAAV3Kl2/aabdeMo5lcZJZ7aj0pRQGMrba8zuR7qp3vMPmcQfRtPA P26WJ6ClBkaTd4cz40LWJ7Q= X-Google-Smtp-Source: APXvYqwdAQL3VnZNwjPeETAbUL+bLXtL8v4BUHFJcIm/NTpDVwnZDrNB/j65t032OBVc8SsE4bQMYg== 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> 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: 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