Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3820062ybh; Tue, 6 Aug 2019 01:57:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpsAQn5w5Nq6aX5T4ol9urJfAtutxbZJ3PHW8CWJg264en9rW4oKNcFgWrssYhKfzUa5T6 X-Received: by 2002:a17:902:b789:: with SMTP id e9mr2079487pls.294.1565081836624; Tue, 06 Aug 2019 01:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565081836; cv=none; d=google.com; s=arc-20160816; b=rkFfoNwZLDcabqSnc5nr1f5eX1hqXFGQPyoBkgJRsBUJiqWtxMRPeSUHz/+TkN2iD9 NNhUr/GTHTpu0E+vh4ayuQ1RoLVrjsGXz1bGLs1VR5QyZDpPexm22HSBL1vWnQoP43up 4OCtj83iQ9LrAWFC6Hm/Ft3sNWZSuTMVbRzWgRvoVSXxjmzYOysa70M2I/Q/kg6opbQn DW/iaHHShUbx0fK4xOIJ3E0SSUbZexOplExg3xVM3PpgMdLoAubI5hXg/FuR9f3VO+1H 82fMAO6OTKjRVXTrCXkWsbMx6I8OxsM+uzzbqbnq7AXlUkNwuwzBEhq1gTly1gyg6YI+ C/dA== 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=BZlqMb+QyegauaZukyQF7oO5hMid9fvH6tiqPMt0jfc=; b=Z8jFVfLlDL0QC1Luskg+Wot1/jxJ0oWc6L/XgELtfNJMNKX7G9hVuyO9NJdL7V96eb 39V/wBUqO2GsSKEFT0cotRzOmf6C2s8ssnhJZc9jdFEsFg5YKZa1kV2iiTluCasQtDfP FzEWj+IewRio4EcgJK9KcZIe72c0LygpGiz1IxxUtZ0KObDBhw6IEmFhMCOueCpFVI9k c8ZckBd3GrjTlgF75pD57G/bAu+nWOzbqJCtEyjsGx3HIODenH3Esdt4gPFTyZMvaENY kAbf0NtV0IBzJ1vWGuVg1CHIfarD7giN8yUQwc0n0cO16ijtVTOyeVqrNitBmaianKJP z4Gw== 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 t34si7524098plb.29.2019.08.06.01.57.01; Tue, 06 Aug 2019 01:57:16 -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 S1732368AbfHFI4K (ORCPT + 99 others); Tue, 6 Aug 2019 04:56:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:36676 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726713AbfHFI4K (ORCPT ); Tue, 6 Aug 2019 04:56:10 -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 86300ACA0; Tue, 6 Aug 2019 08:56:08 +0000 (UTC) Date: Tue, 6 Aug 2019 10:56:05 +0200 From: Michal Hocko To: "Joel Fernandes (Google)" 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 , joelaf@google.com, 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: <20190806085605.GL11812@dhcp22.suse.cz> References: <20190805170451.26009-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190805170451.26009-1-joel@joelfernandes.org> 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 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. 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. I will try to go through the patch more carefully later as time allows. > Signed-off-by: Joel Fernandes (Google) -- Michal Hocko SUSE Labs