Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3923595ybh; Tue, 6 Aug 2019 03:37:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNZUNy6PQrdJJZ5boPrNIVjxDwN1Ls5TC9iiLa0BRFNU2nCMcxYxjyRqecx0Ae02EXPVU5 X-Received: by 2002:a62:3103:: with SMTP id x3mr2894966pfx.107.1565087853111; Tue, 06 Aug 2019 03:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565087853; cv=none; d=google.com; s=arc-20160816; b=Vf0Vbr3hT16edj6/m0I+fz91E75SbN3K0ZVs2H5H2RhGOe85nlm4/qbc/cDRRC47uX cru0emwz5z5wkK2zXw4wBPHmIsx+a/71crjNHJ8ZRzAEGyaih9fk57cFu2zbFDxdTa23 w1ceDgImhZDbjHJqUeOzPMh8gQzUZ/UQ98P4d+yxGXA4uWvCv5AD6teUh/OKdJRKAFTo KBTllIbpO+NZITH7MzXPe2UTpBejqdN2IrDhXCxio9E+NHEBs2ZdO9sJqYJ5mvcd0/W7 KroXLtFgI8vePSvbt91gTBh8j82a7mkA6b1rFlJCBWw1nLRriQDsWJT2RWaoBvKgLTyc iJNg== 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:dkim-signature; bh=q0Wilp6roBIsdQ40Pa0gikkfrKuFSJkj9vHJ430JGZ8=; b=y42IAhFn4ZCfYUoLH4ZEFQEoK0j6WHkZn9NCAUtJPeb2toZTwMdYRyHyYF0aqwrZka MIFc9Wzn5JTjnX1u51GaNHvNQ6MSQj5zIyoTlpordeWNL1pz+Z6S6y0NGEq7shhEBEnE ewm79HioLWDr/Kar0zPcBmyiVLFfFNHoAXCJyqtzZ2d66J+Tl1fZbr7QEEMTpxxoSk3K ixuBftkpzyd7HGEx2Fz6SlKokTSx00cSMaq2x8HKDG0anIA+RkQfxGZxHKPSZ34MPY6g hVQ6EfdEbOEyUlCf9QErQjfMLPPaccjZnkH9r3NrmUeAAvJL2OpgINAe149hE+ETeXRs RjEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=yBSWChLq; 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 d67si46552232pgc.62.2019.08.06.03.37.14; Tue, 06 Aug 2019 03:37: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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=yBSWChLq; 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 S1732583AbfHFKgc (ORCPT + 99 others); Tue, 6 Aug 2019 06:36:32 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46357 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732494AbfHFKgb (ORCPT ); Tue, 6 Aug 2019 06:36:31 -0400 Received: by mail-pl1-f196.google.com with SMTP id c2so37677468plz.13 for ; Tue, 06 Aug 2019 03:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q0Wilp6roBIsdQ40Pa0gikkfrKuFSJkj9vHJ430JGZ8=; b=yBSWChLqbeoq5PRv1NFDpgqkTe+IWZ0NXp3UXkWOdUFbznL4X5s9a4jX9e7zqwGMsP 7siDaILd0QUW2OiwTs2TBkA2nguDPr7Gw3/0ZiosrM67X3yu5+zmOU8YxJM9GNeOlYRi FWNYZppcftyNVxczw/mmMiQOjJeqjapSl9VBI= 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:user-agent; bh=q0Wilp6roBIsdQ40Pa0gikkfrKuFSJkj9vHJ430JGZ8=; b=H2orD++o1EbswnCIjOUtLidk1kweuUzVKkHesFpVVjVZHDzkWLiF6MbRoLgCfwxzJA 7xAScoeRmuunHznJbAN+arEyl8PtI1IveqLXGd4CZb3xY4KE0OdBEUwrMmTsT2zonT1i 21RIzEXiSbSkfVRdUI2RTf3p/w13pSdB0U8OI1PzdBn3kqGE19Vm8EyzHXR/YY4Ef2Ml zocnLg0Bt1wl7elj//HI/5y8wI+j6R4YS62Ox1gt/FvS+yUPgOKBtqvOPKMJSrx/MHku 3Q9G2nEN7BzarL55AKZd0s1Dt58/2rXDdLYdvMzVIRH/biTRLPwXhJgcJ4XJmpCvUklq IeAQ== X-Gm-Message-State: APjAAAVhVQ/S2+++hZCRAcFf7I/uf9Pni61WVdesjAzT79m7Z5Pb99NM LQesgkxKsoP4Qwa2aWLDtYh4zw== X-Received: by 2002:a17:902:ac85:: with SMTP id h5mr2564494plr.198.1565087790447; Tue, 06 Aug 2019 03:36:30 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id j15sm99017998pfe.3.2019.08.06.03.36.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 03:36:29 -0700 (PDT) Date: Tue, 6 Aug 2019 06:36:27 -0400 From: Joel Fernandes To: Michal Hocko 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: <20190806103627.GA218260@google.com> References: <20190805170451.26009-1-joel@joelfernandes.org> <20190805170451.26009-3-joel@joelfernandes.org> <20190806084203.GJ11812@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806084203.GJ11812@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 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? Also, even if they were idle enough to be swapped, there is a chance that they were marked as idle and *accessed* before the swapping. Due to swapping, the "page was accessed since we last marked it as idle" information is lost. I am able to verify this. Idle in this context means the same thing as in page idle tracking terms, the page was not accessed by userspace since we last marked it as idle (using /proc//page_idle). thanks, - Joel > > In this patch we reuse PTE_DEVMAP bit since idle page tracking only > > works on user pages in the LRU. Device pages should not consitute those > > so it should be unused and safe to use. > > > > Cc: Robin Murphy > > Signed-off-by: Joel Fernandes (Google) > > --- > > arch/arm64/Kconfig | 1 + > > arch/arm64/include/asm/pgtable-prot.h | 1 + > > arch/arm64/include/asm/pgtable.h | 15 +++++++++++++++ > > 3 files changed, 17 insertions(+) > > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 3adcec05b1f6..9d1412c693d7 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -128,6 +128,7 @@ config ARM64 > > select HAVE_ARCH_MMAP_RND_BITS > > select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT > > select HAVE_ARCH_PREL32_RELOCATIONS > > + select HAVE_ARCH_PTE_SWP_PGIDLE > > select HAVE_ARCH_SECCOMP_FILTER > > select HAVE_ARCH_STACKLEAK > > select HAVE_ARCH_THREAD_STRUCT_WHITELIST > > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h > > index 92d2e9f28f28..917b15c5d63a 100644 > > --- a/arch/arm64/include/asm/pgtable-prot.h > > +++ b/arch/arm64/include/asm/pgtable-prot.h > > @@ -18,6 +18,7 @@ > > #define PTE_SPECIAL (_AT(pteval_t, 1) << 56) > > #define PTE_DEVMAP (_AT(pteval_t, 1) << 57) > > #define PTE_PROT_NONE (_AT(pteval_t, 1) << 58) /* only when !PTE_VALID */ > > +#define PTE_SWP_PGIDLE PTE_DEVMAP /* for idle page tracking during swapout */ > > > > #ifndef __ASSEMBLY__ > > > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > > index 3f5461f7b560..558f5ebd81ba 100644 > > --- a/arch/arm64/include/asm/pgtable.h > > +++ b/arch/arm64/include/asm/pgtable.h > > @@ -212,6 +212,21 @@ static inline pte_t pte_mkdevmap(pte_t pte) > > return set_pte_bit(pte, __pgprot(PTE_DEVMAP)); > > } > > > > +static inline int pte_swp_page_idle(pte_t pte) > > +{ > > + return 0; > > +} > > + > > +static inline pte_t pte_swp_mkpage_idle(pte_t pte) > > +{ > > + return set_pte_bit(pte, __pgprot(PTE_SWP_PGIDLE)); > > +} > > + > > +static inline pte_t pte_swp_clear_page_idle(pte_t pte) > > +{ > > + return clear_pte_bit(pte, __pgprot(PTE_SWP_PGIDLE)); > > +} > > + > > static inline void set_pte(pte_t *ptep, pte_t pte) > > { > > WRITE_ONCE(*ptep, pte); > > -- > > 2.22.0.770.g0f2c4a37fd-goog > > -- > Michal Hocko > SUSE Labs