Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3177107ybf; Tue, 3 Mar 2020 00:48:24 -0800 (PST) X-Google-Smtp-Source: ADFU+vvAs69TJ7yL1QpWQb5VuJASayYXhXUouWueV6dsAN7k128opeR60pq22wv7yZaJWOdcllWb X-Received: by 2002:a9d:4d8f:: with SMTP id u15mr2587249otk.261.1583225304061; Tue, 03 Mar 2020 00:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583225304; cv=none; d=google.com; s=arc-20160816; b=b0R0Fq6kpww+wSZNYdvHGm4fCQ6QF9S/ymtObl65zU3J8VH/k6R2EH0D6O+yhbK+XR nT92t6M8wns8B3vjIWOziAkZaIDG44C4Ij0aH3DOEiWEuMtmN33stQS9spfEWoyKuLzY zJsw//1Evn15TyzqmXrRhGip9kx5G4e9wt5FDb9ISHQqk7jkr52kJ9tQJqm9nU5ccaHE uT3mO8o1sBn++IxwVWVza+RlQGrP8/hreGk6Ral5tJLswZVDcvgH0H7yJXK9aK+o6yZV euK6dOC3Bs31Ro+NiWZAYj6XscH8++G5f+k9Pe6HyUqdkKkZcMJsTqiJCSd/ih4RhbDk 5e/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=vO0aIRw743hYshMTJP1judbpkq/VE6oakQZRI4fw4aQ=; b=NXgqd8w2cLg0drxZctoJMNRufUQprKS+kyMjjNhewwVOEIDWbPP7piXNwy5cctYTLJ yyTGb2hKeWIe5M9XGliKWEucFOEBNG4JPBy8U40a/3IA+Avn9M+fQ840v2nd7scAuSFt aufBOK/G40gOM1bb2q7SX+uG48Dxork50cXa9FZq/WOx/84Fs+B4eR5wkd9/Xq1XlUrF qEHXwDGXjvfuJ4lH7XjcwXeSAsk3q1FCG//NeHWruW26rPCDowBx/n4/3jn8OBAWv6Zm +C0iLVuRYZXe8AyoUFDp0noVs/PDLQCzTWPT532h92MKKQPrKbgCt/UCCEcUOYPeAwch wrfQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si7630122otc.308.2020.03.03.00.48.11; Tue, 03 Mar 2020 00:48:24 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727587AbgCCIsA (ORCPT + 99 others); Tue, 3 Mar 2020 03:48:00 -0500 Received: from mga18.intel.com ([134.134.136.126]:50095 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbgCCIr7 (ORCPT ); Tue, 3 Mar 2020 03:47:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 00:47:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,510,1574150400"; d="scan'208";a="233551170" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga008.jf.intel.com with ESMTP; 03 Mar 2020 00:47:55 -0800 From: "Huang\, Ying" To: Michal Hocko Cc: Mel Gorman , David Hildenbrand , Johannes Weiner , Matthew Wilcox , Andrew Morton , , , 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 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> <20200303080945.GX4380@dhcp22.suse.cz> Date: Tue, 03 Mar 2020 16:47:54 +0800 In-Reply-To: <20200303080945.GX4380@dhcp22.suse.cz> (Michal Hocko's message of "Tue, 3 Mar 2020 09:09:45 +0100") Message-ID: <87o8td4yf9.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko writes: > 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. If my understanding were correct, the newly migrated clean MADV_FREE pages will be put at the head of inactive file LRU list instead of the tail. So it's possible that some useful file cache pages will be reclaimed. Best Regards, Huang, Ying