From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05A78C31E40 for ; Tue, 6 Aug 2019 10:47:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D186E20818 for ; Tue, 6 Aug 2019 10:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=joelfernandes.org header.i=@joelfernandes.org header.b="e1W5PQo6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726877AbfHFKrT (ORCPT ); Tue, 6 Aug 2019 06:47:19 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33974 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730868AbfHFKrS (ORCPT ); Tue, 6 Aug 2019 06:47:18 -0400 Received: by mail-pl1-f194.google.com with SMTP id i2so37737925plt.1 for ; Tue, 06 Aug 2019 03:47:18 -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=781gQFojuZXlLR9f0Rnz2BsSQ1xNulNQY/lDauCDdSA=; b=e1W5PQo6UI3vE5fsYo9GNTQns85aj/gUpDhLx9+3D64tPpFl02X83oJkMy9XzTBNmf x7k9LQX1mYX3Ou3y4IWdZK6NAO3h5S7a8ijztUPEK9VYoOKSdCKcExDxxqYFFPD7vS3L s8MA9DjsMd/kXQN1m2atBXnvStSWMRuGddxJk= 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=781gQFojuZXlLR9f0Rnz2BsSQ1xNulNQY/lDauCDdSA=; b=UOkiR12BtduCC5wsWbbF4oTl/Cd6Dgf5Xxur/FTmuB1CH7cYpQ8fX33MG9dRA4AQ3Y HYHp+2tOZWSgrd9j76mzs4UP5FeJ8nUil+8syIh0y3rWQApxhN+tHEZMrDGMcI0+643g 8KnRoUvpp+OpmowmTlvKYHtNNwRWo/m0XfJz3GdqgTvUKbWfi6VsWEO/duSxFe1zCL3L XDYTeIlJidC8aEh5Ot7aV8djg/voADwZNZar5+9shvcUqncuP4Mm8j+dy2Gmy/uqrvtj ZE9dat5tAVbdNi/i1AoFZMjlSt++njZ89GjddnLgChgXKIHaqpIKOa3BjE0rXfPCzwxf itVA== X-Gm-Message-State: APjAAAVzSysvCsGwQbSvIORU2dTqJKnMvQvGGMlBFYvDo86jRNaJ4BcA Ll59CXKf9HpsShGTCWHELPoAtw== X-Google-Smtp-Source: APXvYqyckGHtBm2UKAu71b4v/ySxM/JXAjxm9Txb7Dg6O/cihgtEDSFSoalvYdEzzWgdgOHwA+AgNw== X-Received: by 2002:a17:902:654f:: with SMTP id d15mr2365106pln.253.1565088438061; Tue, 06 Aug 2019 03:47:18 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id a21sm95934459pfi.27.2019.08.06.03.47.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 06 Aug 2019 03:47:17 -0700 (PDT) Date: Tue, 6 Aug 2019 06:47:15 -0400 From: Joel Fernandes To: Michal Hocko Cc: linux-kernel@vger.kernel.org, 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, Robin Murphy , Roman Gushchin , Stephen Rothwell , surenb@google.com, Thomas Gleixner , tkjos@google.com, Vladimir Davydov , Vlastimil Babka , Will Deacon Subject: Re: [PATCH v4 1/5] mm/page_idle: Add per-pid idle page tracking using virtual indexing Message-ID: <20190806104715.GC218260@google.com> References: <20190805170451.26009-1-joel@joelfernandes.org> <20190806085605.GL11812@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190806085605.GL11812@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Aug 06, 2019 at 10:56:05AM +0200, Michal Hocko wrote: > On Mon 05-08-19 13:04:47, Joel Fernandes (Google) wrote: > > The page_idle tracking feature currently requires looking up the pagemap > > for a process followed by interacting with /sys/kernel/mm/page_idle. > > Looking up PFN from pagemap in Android devices is not supported by > > unprivileged process and requires SYS_ADMIN and gives 0 for the PFN. > > > > This patch adds support to directly interact with page_idle tracking at > > the PID level by introducing a /proc//page_idle file. It follows > > the exact same semantics as the global /sys/kernel/mm/page_idle, but now > > looking up PFN through pagemap is not needed since the interface uses > > virtual frame numbers, and at the same time also does not require > > SYS_ADMIN. > > > > In Android, we are using this for the heap profiler (heapprofd) which > > profiles and pin points code paths which allocates and leaves memory > > idle for long periods of time. This method solves the security issue > > with userspace learning the PFN, and while at it is also shown to yield > > better results than the pagemap lookup, the theory being that the window > > where the address space can change is reduced by eliminating the > > intermediate pagemap look up stage. In virtual address indexing, the > > process's mmap_sem is held for the duration of the access. > > As already mentioned in one of the previous versions. The interface > seems sane and the usecase as well. So I do not really have high level > objections. That is great to know. > From a quick look at the patch I would just object to pulling swap idle > tracking into this patch because it makes the review harder and it is > essentially a dead code until a later patch. I am also not sure whether > that is really necessary and it really begs for an explicit > justification. Ok I will split it out, and also expand on the need for it a bit more. > > I will try to go through the patch more carefully later as time allows. Thanks a lot. > > Signed-off-by: Joel Fernandes (Google) > -- > Michal Hocko > SUSE Labs - Joel