Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3150659ybf; Tue, 3 Mar 2020 00:11:09 -0800 (PST) X-Google-Smtp-Source: ADFU+vvmO9bbPx/VRROVlOvSdLyWTaxWXLoFdIrzJGXaA3l9NBbx3SvlmvBRMrenEDa+ECeeRz3M X-Received: by 2002:a9d:6c9:: with SMTP id 67mr2570719otx.363.1583223069462; Tue, 03 Mar 2020 00:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583223069; cv=none; d=google.com; s=arc-20160816; b=c0C5WBLTSpFElWPxErE22rNvXUmM8uK06sx5Bgd/9SK7a9jhYBQtnGwl04u5Vs+oKR xOjDVSDD9nBzZjz0IJ2KlDILjaYTRy/z1gHtzI4ztCiN7A2l4ahIu3jpzN6E8Z5+YqLY OPqZdFbf465FRLoz9rbTCvfKAmPpFHEXH3O3myn6HagAXdPwIYKiF04qNCof2DRZfd9B tA3IBd9BPTQcAEJxqc/NA8GnRbTSHfwZPy6Kn6EGS9Ms+LbcxlE/Ro9+fyKs0QjAVNvq zfff1jH9LAtIqJPmtOrLZtzXU8dX1naccOCotj1vfCApiSXIInpj/yMR/9yc6oS4HsH+ at+w== 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=1rZb3JfiJUNf5SBeSXRzrX8hWQKOCLyxoGXM0AHXnvQ=; b=k+3m/qq2ovV02e221xyCbODysUs3AhTCcNJbHB0zRNnuusSijuHB5DLU/n60iVEGLS P+sKRtYjbsXaKRI+pJl/NO147x/z5olk+u9Nhcwr+rI9U0zQ2eSxNeRMg4FxXk20F+xJ s3Utn3BBdJZ4mYn5Q+hN0XaXM1rD4KoIY/D5CtDDnhYscCdRR7pij8rcNzRZi1bwBfAK aY0LPHZwsYI7y29Aiqao/gdIQb3sek48xJdRrD2IuICsOQconjHC9j8mp6Fz9mzUejcc epWSr4hf4+N1VaKyTPNd+IRjHBhsQGiXc1qJtG0ZiS6OA7FfRzN49sijs8CHyyNdlAJa txGw== 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 z10si7029004oix.235.2020.03.03.00.10.57; Tue, 03 Mar 2020 00:11:09 -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 S1727718AbgCCIJt (ORCPT + 99 others); Tue, 3 Mar 2020 03:09:49 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43992 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727594AbgCCIJs (ORCPT ); Tue, 3 Mar 2020 03:09:48 -0500 Received: by mail-wr1-f66.google.com with SMTP id h9so2144223wrr.10 for ; Tue, 03 Mar 2020 00:09:47 -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=1rZb3JfiJUNf5SBeSXRzrX8hWQKOCLyxoGXM0AHXnvQ=; b=HfpAoJwA+5LhBLbEdeGePnKn31zXDDrl99DerIi8DFX/pbVgH0u3lo/9qG9btIphEf YNe9IM4222TSKmxmR9p3XzF+F3VZXYe/UYqEzMDEsnUoUJ71FgKFrr9xSYytnJiRrwR6 CNoHEM2CzsA9WklZE0aITJfpzoxz2D18MpGCto0uMKmU7nL3H2KXFfsL7NJGtwNMMMq1 7e7qNAEDBJBTP7NVeQxZVWNE+60xUsIYFQ0oTQbxjdOT4lEeWmJ3zibaPgHob/TVPghS PSLz2Ra1mhKguSyeoxIFq0sY8AhijQQi2nSepcoCv8ns+E0m4KW/wz7yXqylwpgxwU5B zhoQ== X-Gm-Message-State: ANhLgQ30Q4uBRzwn5GfbHFN2YRADM9d0oebXyMBtfVCWsOL52hDUMFwQ dnH1H3Hd7yfVL3HXrnJr8zM= X-Received: by 2002:a5d:608e:: with SMTP id w14mr4420860wrt.201.1583222986799; Tue, 03 Mar 2020 00:09:46 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id j66sm2752586wmb.21.2020.03.03.00.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 00:09:46 -0800 (PST) Date: Tue, 3 Mar 2020 09:09:45 +0100 From: Michal Hocko To: "Huang, Ying" Cc: Mel Gorman , 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: <20200303080945.GX4380@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> <20200228094954.GB3772@suse.de> <87h7z76lwf.fsf@yhuang-dev.intel.com> <20200302151607.GC3772@suse.de> <87zhcy5hoj.fsf@yhuang-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87zhcy5hoj.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 Tue 03-03-20 09:51:56, Huang, Ying wrote: > Mel Gorman writes: > > On Mon, Mar 02, 2020 at 07:23:12PM +0800, Huang, Ying wrote: > >> If some applications cannot tolerate the latency incurred by the memory > >> allocation and zeroing. Then we cannot discard instead of migrate > >> always. While in some situations, less memory pressure can help. So > >> it's better to let the administrator and the application choose the > >> right behavior in the specific situation? > >> > > > > Is there an application you have in mind that benefits from discarding > > MADV_FREE pages instead of migrating them? > > > > Allowing the administrator or application to tune this would be very > > problematic. An application would require an update to the system call > > to take advantage of it and then detect if the running kernel supports > > it. An administrator would have to detect that MADV_FREE pages are being > > prematurely discarded leading to a slowdown and that is hard to detect. > > It could be inferred from monitoring compaction stats and checking > > if compaction activity is correlated with higher minor faults in the > > target application. Proving the correlation would require using the perf > > software event PERF_COUNT_SW_PAGE_FAULTS_MIN and matching the addresses > > to MADV_FREE regions that were freed prematurely. That is not an obvious > > debugging step to take when an application detects latency spikes. > > > > Now, you could add a counter specifically for MADV_FREE pages freed for > > reasons other than memory pressure and hope the administrator knows about > > the counter and what it means. That type of knowledge could take a long > > time to spread so it's really very important that there is evidence of > > an application that suffers due to the current MADV_FREE and migration > > behaviour. > > OK. I understand that this patchset isn't a universal win, so we need > some way to justify it. I will try to find some application for that. > > Another thought, as proposed by David Hildenbrand, it's may be a > universal win to discard clean MADV_FREE pages when migrating if there are > already memory pressure on the target node. For example, if the free > memory on the target node is lower than high watermark? This is already happening because if the target node is short on memory it will start to reclaim and if MADV_FREE pages are at the tail of inactive file LRU list then they will be dropped. Please note how that follows proper aging and doesn't introduce any special casing. Really MADV_FREE is an inactive cache for anonymous memory and we treat it like inactive page cache. This is not carved in stone of course but it really requires very good justification to change. -- Michal Hocko SUSE Labs