Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp642551ybl; Fri, 9 Aug 2019 11:21:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/qqgNDl74p3vY+XLsOx09Y+kU3sQ1PRGLeEqAutVG4SjrJBjOy3RmSh2FpYiHGvb3xHEb X-Received: by 2002:a62:1ac8:: with SMTP id a191mr22834380pfa.164.1565374893510; Fri, 09 Aug 2019 11:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565374893; cv=none; d=google.com; s=arc-20160816; b=Pxdr3s0BLZHMC2DQf/+7kJAaM8Zd0pW3mre8JwThUdcnMZ+pr/AVNcj1no7zg114FN eMvhpJPQMO6r32KJtKqm49GuYsqvmnXauQCSGPMVYM9GNu/jjN3lfDhmBNlgytncW/oV ppIUIOIXh/t6tuMKgsWo0zg2CKsKHLQX7Q9KRrcrQsEaO1d1r4BQ74Kvt/zwRC27z5Fw yEtsWyruQFRLCzWmImEGhLDUFgs/vrrBKI33X2uYcwNfqDcFS373HWD+55MNJwMxZWGS BkJaaV+purPMjlyHJNGuDpNnnLKNrpv3P7nlPVQE5a+EJ9zty2OhjA/2cos77gdZYHeu fxyA== 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=tL5tZxLa+RzvMcGkhmFt47LHLw70KZgGHl3uiuIM6xY=; b=lD7bbuAJeTZvAE5czLixu22noQI6qkKSzPWzvP8g19HEygm04dO73J/wM7wrVob8oj 7qsSMIxH3w/+PZLULN++7LlUfHr70Jlwq55M//bjPNlIjnyimVhnbtOLp5Pozj5xvdZT DJ11BETZ+E2zMKygkqsLJaMygcQBO9+C6PBfVoyzUio6Wy4Gh1a5igslR6kqjVEAbtke yMP9SspZDlmQb+n5/0RvnJJP7W1Z2lG8SOBExXBI8R44rthU5rd8GUaYSMAmhpYAHXYk TzHrQ+LAf8QtIWFnuRiip/NJG36tTXYoN8GGopkzi1iWV1F7SNg5l7EeGjXokCx77NqB ZCzQ== 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 x203si54703685pgx.545.2019.08.09.11.21.18; Fri, 09 Aug 2019 11:21:33 -0700 (PDT) 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 S2436851AbfHIR5L (ORCPT + 99 others); Fri, 9 Aug 2019 13:57:11 -0400 Received: from outbound-smtp05.blacknight.com ([81.17.249.38]:34892 "EHLO outbound-smtp05.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfHIR5L (ORCPT ); Fri, 9 Aug 2019 13:57:11 -0400 Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp05.blacknight.com (Postfix) with ESMTPS id 83DE8985B6 for ; Fri, 9 Aug 2019 18:57:08 +0100 (IST) Received: (qmail 23304 invoked from network); 9 Aug 2019 17:57:08 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.18.93]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 9 Aug 2019 17:57:08 -0000 Date: Fri, 9 Aug 2019 18:57:06 +0100 From: Mel Gorman To: Michal Hocko Cc: Minchan Kim , Andrew Morton , LKML , linux-mm , Miguel de Dios , Wei Wang , Johannes Weiner , Nicholas Piggin Subject: Re: [RFC PATCH] mm: drop mark_page_access from the unmap path Message-ID: <20190809175706.GO2739@techsingularity.net> References: <20190729082052.GA258885@google.com> <20190729083515.GD9330@dhcp22.suse.cz> <20190730121110.GA184615@google.com> <20190730123237.GR9330@dhcp22.suse.cz> <20190730123935.GB184615@google.com> <20190730125751.GS9330@dhcp22.suse.cz> <20190731054447.GB155569@google.com> <20190731072101.GX9330@dhcp22.suse.cz> <20190806105509.GA94582@google.com> <20190809124305.GQ18351@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20190809124305.GQ18351@dhcp22.suse.cz> 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 Fri, Aug 09, 2019 at 02:43:24PM +0200, Michal Hocko wrote: > On Tue 06-08-19 19:55:09, Minchan Kim wrote: > > On Wed, Jul 31, 2019 at 09:21:01AM +0200, Michal Hocko wrote: > > > On Wed 31-07-19 14:44:47, Minchan Kim wrote: > [...] > > > > As Nick mentioned in the description, without mark_page_accessed in > > > > zapping part, repeated mmap + touch + munmap never acticated the page > > > > while several read(2) calls easily promote it. > > > > > > And is this really a problem? If we refault the same page then the > > > refaults detection should catch it no? In other words is the above still > > > a problem these days? > > > > I admit we have been not fair for them because read(2) syscall pages are > > easily promoted regardless of zap timing unlike mmap-based pages. > > > > However, if we remove the mark_page_accessed in the zap_pte_range, it > > would make them more unfair in that read(2)-accessed pages are easily > > promoted while mmap-based page should go through refault to be promoted. > > I have really hard time to follow why an unmap special handling is > making the overall state more reasonable. > > Anyway, let me throw the patch for further discussion. Nick, Mel, > Johannes what do you think? > I won't be able to answer follow-ups to this for a while but here is some superficial thinking. Minimally, you should test PageReferenced before setting it like mark_page_accessed does to avoid unnecessary atomics. I know it wasn't done that way before but there is no harm in addressing it now. workingset_activation is necessarily expensive. It could speculatively lookup memcg outside the RCU read lock and only acquire it if there is something interesting to lookup. Probably not much help though. Note that losing the potential workingset_activation from the patch may have consequences if we are relying on refaults to fix this up. I'm undecided as to what degree it matters. That said, I do agree that the mark_page_accessed on page zapping may be overkill given that it can be a very expensive call if the page gets activated and it's potentially being called in the zap path at a high frequency. It's also not a function that is particularly easy to optimise if you want to cover all the cases that matter. It really would be preferably to have knowledge of a workload that really cares about the activations from mmap/touch/munmap. mark_page_accessed is a hint, it's known that there are gaps with it so we shouldn't pay too much of a cost on information that only might be useful. If the system is under no memory pressure because the workloads are tuned to fit in memory (e.g. database using direct IO) then mark_page_accessed is only cost. We could avoid marking it accessed entirely if PF_EXITING given that if a task is exiting, it's not a strong indication that the page is of any interest. Even if the page is heavily shared page and one user exits, the other users will keep it referenced and prevent reclaim anyway. The benefit is too marginal too. Given the definite cost of mark_page_accessed in this path and the main corner case being tasks that access pages via mmap/touch/munmap (which is insanely expensive if done at high frequency), I think it's reasonable to rely on SetPageReferenced giving the page another lap of the LRU in most cases (the obvious exception being CMA forcing reclaim). That opinion might change if there is a known example of a realistic workload that would suffer from the lack of explicit activations from teardown context. -- Mel Gorman SUSE Labs