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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 CC343C3F2D8 for ; Thu, 5 Mar 2020 10:49:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A50E2073D for ; Thu, 5 Mar 2020 10:49:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A50E2073D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB5986B0003; Thu, 5 Mar 2020 05:49:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C65796B0005; Thu, 5 Mar 2020 05:49:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B56EC6B0007; Thu, 5 Mar 2020 05:49:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 9AB6D6B0003 for ; Thu, 5 Mar 2020 05:49:08 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 920DE181AC9C6 for ; Thu, 5 Mar 2020 10:49:08 +0000 (UTC) X-FDA: 76560986376.02.bean69_32ac7d1b82a1b X-HE-Tag: bean69_32ac7d1b82a1b X-Filterd-Recvd-Size: 3320 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Mar 2020 10:49:08 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DE45BB1FF; Thu, 5 Mar 2020 10:49:05 +0000 (UTC) Date: Thu, 5 Mar 2020 10:48:59 +0000 From: Mel Gorman To: "Huang, Ying" Cc: Michal Hocko , David Hildenbrand , Johannes Weiner , Matthew Wilcox , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Zi Yan , Peter Zijlstra , Dave Hansen , Minchan Kim , Hugh Dickins , Alexander Duyck Subject: Re: [RFC 0/3] mm: Discard lazily freed pages when migrating Message-ID: <20200305104859.GG3772@suse.de> References: <20200228094954.GB3772@suse.de> <87h7z76lwf.fsf@yhuang-dev.intel.com> <20200302151607.GC3772@suse.de> <87zhcy5hoj.fsf@yhuang-dev.intel.com> <20200303080945.GX4380@dhcp22.suse.cz> <87o8td4yf9.fsf@yhuang-dev.intel.com> <20200303085805.GB4380@dhcp22.suse.cz> <87ftep4pzy.fsf@yhuang-dev.intel.com> <20200304095802.GE16139@dhcp22.suse.cz> <87blpc2wxj.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <87blpc2wxj.fsf@yhuang-dev.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Wed, Mar 04, 2020 at 07:15:20PM +0800, Huang, Ying wrote: > In which situation the cost to reconstruct MADV_FREE pages can be higher > than the cost to allocate file cache page and read from disk? Heavy > contention on mmap_sem? > MADV_FREE should be anonymous only if (behavior == MADV_FREE) return madvise_free_single_vma(vma, start, end); ..... static int madvise_free_single_vma(struct vm_area_struct *vma, unsigned long start_addr, unsigned long end_addr) { struct mm_struct *mm = vma->vm_mm; struct mmu_notifier_range range; struct mmu_gather tlb; /* MADV_FREE works for only anon vma at the moment */ if (!vma_is_anonymous(vma)) return -EINVAL So the question is not applicable. For anonymous memory, the cost of updating a PTE is lower than allocating a page, zeroing it and updating the PTE. It has been repeatedly stated now for almost a week that a semantic change to MADV_FREE should be based on a problem encountered by a real application that can benefit from the new semantics. I think the only concrete outcome has been that userspace potentially benefits if the total number of MADV_FREE pages is reported globally. Even that is marginal as smaps has the information to tell the difference between high RSS due to a memory leak and high RSS usage due to MADV_FREE. The /proc/vmstats for MADV_FREE are of marginal benefit given that they do not tell us much about the current number of MADV_FREE pages in the system. -- Mel Gorman SUSE Labs