Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3933402ybh; Tue, 6 Aug 2019 03:48:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ8jYbT2NYohpSpaXC3+Dg4XoFFVF+7uPNY/Zt2HREPEyV3vukJMkZKOguWM4rvy8pIhzX X-Received: by 2002:a17:90a:3ae8:: with SMTP id b95mr2509442pjc.68.1565088492719; Tue, 06 Aug 2019 03:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565088492; cv=none; d=google.com; s=arc-20160816; b=TWID7KyWhUiYEK5otnfS6hZVc6uBZKIgiC+/fi9zMQcrkiE3LSrb4zN1L1o1HF0i9V onxs5U4E0+A2uOWmhmRQong6AMWbquEepcqbn17T9mzTGFl54iqZPkLYPkR47vHxwdM+ DhR0SzSdj2kWNdGR2iIpsdsawjDlNZ8msfjPkOqm4malB+Xji+KMfNIUjJInASmVAkC5 2REZHV0+yD6TGk/BEm8i7h52xzHsLEV1wOGTcoChhz9bQu22L+CjF5hnSOgF3ORBVCd1 Llsv8uoimpDWIDxNIlUDE623QOq3fRi+T4hghtll47eKLCOJ+IXRJmCkivZ/f2873QYj FfKA== 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=781gQFojuZXlLR9f0Rnz2BsSQ1xNulNQY/lDauCDdSA=; b=xurVodcMbz4D9iwRXQ24FNqbfmFB0vImK8FpF2JHV59+0Ei3KjNI1v0LrPXRwY//Gi OivOKmyqhBFSp+lUNjL3kg1MTj8EghPUxzALDB71ALzBFVL6FZgge+80/TSrZu5ikZtK h26TJg0LTRa1jGF8tg5wZMi6FkXMUavkWUOehdKsCiH7JYC+Wh2BMWPopiteaMMy0TnT TT9ZT/PN5soRHU0vS2uhgYD0/I1OPtxPpzl+RE65GccPdmKzB2MGAxu6DJo6pVf5al7T INA3Dt+RX8Nxn5xWGknJEkKwcr8xBhhgIMb3b56rZm0O8CbkbvGHC4xFlwHZs7QV1HJR tVWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=e1W5PQo6; 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 a21si46015497pfo.249.2019.08.06.03.47.57; Tue, 06 Aug 2019 03:48:12 -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=e1W5PQo6; 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 S1732669AbfHFKrT (ORCPT + 99 others); Tue, 6 Aug 2019 06:47:19 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35030 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730068AbfHFKrS (ORCPT ); Tue, 6 Aug 2019 06:47:18 -0400 Received: by mail-pl1-f196.google.com with SMTP id w24so37717088plp.2 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=D/OBf9lhZSKqtQH3+vvsOCnnuz9ADmjoplOTi7EbNvYZoFvn91VOGjI0jjPZMOzEhw qm2K/ufCVpSyJTch5ueqxb3Z5WyAyTzx/UX/XI95jTm1XNdnCJqnHHDCh33aTd2AUj7/ O/PD8iOOMY6TR8RxLa8QFtJLwo/gy4zFVYvI6R3lLDQI9uyW1vRHoeKQedQ8CuUBYFqL gKNV6aepM0LSLFhhTIs2Rk+5cOuzMNWnFF8Y+6TQ1eF6ac7Pw/BAPKWardR/17kaMQK5 2mUpbNIG9M8hjJGm+/F/6aLKMKh4yFI8pHq4Zo7OEeI2jRyFMGk/0q9mKXOcexwFMtV5 CGZw== X-Gm-Message-State: APjAAAUDxICGbt/nz3m+lnYtUWeh5Uu2Babj+ZAmWfKtNMih7zK+q4G5 FrU5My7Q5OrlaFvtxiqAgDCHYQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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