Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4218641ybh; Tue, 6 Aug 2019 08:08:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqy24atPr/43npjfOkiYwsgH2BKM+DgX7K6RQjfI7lPqLFJJH72Ltcp5yqSwX9+llIQI75e9 X-Received: by 2002:aa7:9834:: with SMTP id q20mr4228829pfl.196.1565104125180; Tue, 06 Aug 2019 08:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565104125; cv=none; d=google.com; s=arc-20160816; b=QTChEh0m241dtRYc6m2EbFdsHR4iR7aqg/8Rw1Xn7jsWomxKtQuhO9us2l72XcadrX 9sLFSpQG3j2Ml7AX8cgONrcuOuXK4YmxlakzfGMxLtJJYm9jrzvIByMu4E0aAS5s2uS7 is1HDiMykLgGcNtvs4Q5tHRGQkqGPUmJF0PIsWcYTL+TuOGVf7uK0Rh8HsnXsgID8Eqk oHZ3w+8vKEDadYKUl1wo0/InY69oLEj4qk0vKn8RggYd3p2HJ50wxzScruwZht6C1jwL 0SjQoIwvjBBe3sPcFbk+zwjgqb/OGZMlmoJfnAP40y3gKWrAYQmRSA/HkkaD9eZpWQhs Tupg== 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=Gx41ZMg0//phFLDjHBZyZ1xbTAuE05DSPUqWAaNSjbw=; b=YdxOtIYI5wid7B+OmtryQVr3mADqyHn5dCi4eM/7HQbmCpusGioVQqMam+5MtQq7pN 2JRJjF672YkJS9B1vMtQomvEU/f7JF0nSTnWbxzNYGDCWdOPPHAFvINpq1+la2zarQg+ ujjITHvcIYNKwcXJohfcoWH+61Hf8PHqz3Od1kA0mI016AczxK3lzjqqW/8/r4PUO+Io AqB0UitU0Hdby+YRIUwGPuQEHixyGO0W+SjNUJ6ObggfOoJishck/85XecZ4u/zXIIRl NiGxcz0JTcAP/WWS9pKaPm4l1OWh/MUzm/RX5lMQSk2zM9FaoxV88XaGO7CI/YxoSMTi wyFw== 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 v9si9394685plg.222.2019.08.06.08.08.26; Tue, 06 Aug 2019 08:08:45 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732837AbfHFOKF (ORCPT + 99 others); Tue, 6 Aug 2019 10:10:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:52522 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728259AbfHFOKE (ORCPT ); Tue, 6 Aug 2019 10:10:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 01A6BAD43; Tue, 6 Aug 2019 14:10:01 +0000 (UTC) Date: Tue, 6 Aug 2019 16:09:59 +0200 From: Michal Hocko To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Robin Murphy , Alexey Dobriyan , Andrew Morton , Borislav Petkov , Brendan Gregg , Catalin Marinas , Christian Hansen , dancol@google.com, fmayer@google.com, "H. Peter Anvin" , Ingo Molnar , Jonathan Corbet , Kees Cook , kernel-team@android.com, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Mike Rapoport , minchan@kernel.org, namhyung@google.com, paulmck@linux.ibm.com, Roman Gushchin , Stephen Rothwell , surenb@google.com, Thomas Gleixner , tkjos@google.com, Vladimir Davydov , Vlastimil Babka , Will Deacon Subject: Re: [PATCH v4 3/5] [RFC] arm64: Add support for idle bit in swap PTE Message-ID: <20190806140959.GD11812@dhcp22.suse.cz> References: <20190805170451.26009-1-joel@joelfernandes.org> <20190805170451.26009-3-joel@joelfernandes.org> <20190806084203.GJ11812@dhcp22.suse.cz> <20190806103627.GA218260@google.com> <20190806104755.GR11812@dhcp22.suse.cz> <20190806111446.GA117316@google.com> <20190806115703.GY11812@dhcp22.suse.cz> <20190806134321.GA15167@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806134321.GA15167@google.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 Tue 06-08-19 09:43:21, Joel Fernandes wrote: > On Tue, Aug 06, 2019 at 01:57:03PM +0200, Michal Hocko wrote: > > On Tue 06-08-19 07:14:46, Joel Fernandes wrote: > > > On Tue, Aug 06, 2019 at 12:47:55PM +0200, Michal Hocko wrote: > > > > On Tue 06-08-19 06:36:27, Joel Fernandes wrote: > > > > > On Tue, Aug 06, 2019 at 10:42:03AM +0200, Michal Hocko wrote: > > > > > > On Mon 05-08-19 13:04:49, Joel Fernandes (Google) wrote: > > > > > > > This bit will be used by idle page tracking code to correctly identify > > > > > > > if a page that was swapped out was idle before it got swapped out. > > > > > > > Without this PTE bit, we lose information about if a page is idle or not > > > > > > > since the page frame gets unmapped. > > > > > > > > > > > > And why do we need that? Why cannot we simply assume all swapped out > > > > > > pages to be idle? They were certainly idle enough to be reclaimed, > > > > > > right? Or what does idle actualy mean here? > > > > > > > > > > Yes, but other than swapping, in Android a page can be forced to be swapped > > > > > out as well using the new hints that Minchan is adding? > > > > > > > > Yes and that is effectivelly making them idle, no? > > > > > > That depends on how you think of it. > > > > I would much prefer to have it documented so that I do not have to guess ;) > > Sure :) > > > > If you are thinking of a monitoring > > > process like a heap profiler, then from the heap profiler's (that only cares > > > about the process it is monitoring) perspective it will look extremely odd if > > > pages that are recently accessed by the process appear to be idle which would > > > falsely look like those processes are leaking memory. The reality being, > > > Android forced those pages into swap because of other reasons. I would like > > > for the swapping mechanism, whether forced swapping or memory reclaim, not to > > > interfere with the idle detection. > > > > Hmm, but how are you going to handle situation when the page is unmapped > > and refaulted again (e.g. a normal reclaim of a pagecache)? You are > > losing that information same was as in the swapout case, no? Or am I > > missing something? > > Yes you are right, it would have the same issue, thanks for bringing it up. > Should we rename this bit to PTE_IDLE and do the same thing that we are doing > for swap? What if we decide to tear the page table down as well? E.g. because we can reclaim file backed mappings and free some memory used for page tables. We do not do that right now but I can see that really large mappings might push us that direction. Sure this is mostly a theoretical concern but I am wondering whether promissing to keep the idle bit over unmapping is not too much. I am not sure how to deal with this myself, TBH. In any case the current semantic - via pfn - will lose the idle bit already so can we mimic it as well? We only have 1 bit for each address which makes it challenging. The easiest way would be to declare that the idle bit might disappear on activating or reclaiming the page. How well that suits different usecases is a different question. I would be interested in hearing from other people about this of course. -- Michal Hocko SUSE Labs