Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5555022ybf; Thu, 5 Mar 2020 02:50:10 -0800 (PST) X-Google-Smtp-Source: ADFU+vufPNjkqv4Nzmhi4iX5NBO3uVPQPg5/BtO/5hmNEHEnRFYcS0HAbGYE6V0knJjXED0MB/1+ X-Received: by 2002:a9d:63d2:: with SMTP id e18mr4828406otl.277.1583405410258; Thu, 05 Mar 2020 02:50:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583405410; cv=none; d=google.com; s=arc-20160816; b=VSHc6bkdXoEGR1BOvdQzWXPeB+K7MDJ/LC90VzMhZ/Rhy8T2leB5ntd9P0GrUC/0Ze N6NGqjnKVtFVj9i9IY2VifM9j4MxGoRDzkdL/GNuisMIFQb23SWoChD2ZKs4Nx3cnE+Y tkhz2eJ0KdhK0jEsph/3lJ6BhjyzWg67rsTfFK5kA6aLKQqng7y+nL/BsCkXMhg22GsX AJAkC852Fga3AFfeZjff8LKyb0/a8gElf7PYr2PmL1uI4piCUVv/KRenZvy7Zfmo6HPf fcL3kYppx55OKQYaFhsS9mSouMyHTzIc99sXRpThncX+6AHeP3ZNnQHcItW9OOiTza3e JEwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=6Aa55RjjwbhQU6UwjfIJ4dKVV5tPMuXki9QCgBhSeGo=; b=mqbJgfgYYjASmzZ+Uj5xNFNRY140EckJZ/E6YAUdbA109+kNulqtVsvFDta/MAINQ2 RiXVQ9kjjfeQaw7N2GTchoBtkg7L/32TC0EIWvqF6VmLStPreHu6bagd9ueOvjoUF2Xa ATdm9SRjiJnjk7jSg5+7+Sro6k0ANRZFr6B6Aw1nYJ6lSRTUTYQQRIkIXQFckNIPELP1 daqW4B9EGa2LvNTJXNZQnGOHudHwWVtISw4d+ukGVFgHJlzhHMw/RSdc23QtM7j4O7V6 w8n8kk8g80VTxdrdbhztC8s2P6WP+gHV8so/yRJAQqcB+OxwHGHv4Hc5SRGz3XLMWvgs X+Ig== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si3408248oig.146.2020.03.05.02.49.58; Thu, 05 Mar 2020 02:50:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgCEKtI (ORCPT + 99 others); Thu, 5 Mar 2020 05:49:08 -0500 Received: from mx2.suse.de ([195.135.220.15]:50696 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgCEKtI (ORCPT ); Thu, 5 Mar 2020 05:49:08 -0500 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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