Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933334AbbFLJ4B (ORCPT ); Fri, 12 Jun 2015 05:56:01 -0400 Received: from mail-la0-f47.google.com ([209.85.215.47]:36737 "EHLO mail-la0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932806AbbFLJzg (ORCPT ); Fri, 12 Jun 2015 05:55:36 -0400 MIME-Version: 1.0 In-Reply-To: <20150611114946.d9d259a363a86adba756bdfd@linux-foundation.org> References: <1432005006-3428-1-git-send-email-calvinowens@fb.com> <1433821173-2804704-1-git-send-email-calvinowens@fb.com> <20150609141300.b80eeec15b2c379146816c06@linux-foundation.org> <20150610013902.GA176908@mail.thefacebook.com> <20150610135832.af4e8970c45f3a40b64274e0@linux-foundation.org> <20150611114946.d9d259a363a86adba756bdfd@linux-foundation.org> Date: Fri, 12 Jun 2015 12:55:34 +0300 Message-ID: Subject: Re: [PATCH v6] procfs: Always expose /proc//map_files/ and make it readable From: Alexey Dobriyan To: Andrew Morton Cc: Calvin Owens , "Eric W. Biederman" , Al Viro , Miklos Szeredi , Zefan Li , Oleg Nesterov , Joe Perches , David Howells , Linux Kernel , kernel-team@fb.com, Andy Lutomirski , Cyrill Gorcunov , Kees Cook , "Kirill A. Shutemov" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2761 Lines: 60 On Thu, Jun 11, 2015 at 9:49 PM, Andrew Morton wrote: > On Thu, 11 Jun 2015 14:10:45 +0300 Alexey Dobriyan wrote: > >> On Wed, Jun 10, 2015 at 11:58 PM, Andrew Morton >> wrote: >> > On Tue, 9 Jun 2015 18:39:02 -0700 Calvin Owens wrote: >> > >> >> On Tuesday 06/09 at 14:13 -0700, Andrew Morton wrote: >> >> > On Mon, 8 Jun 2015 20:39:33 -0700 Calvin Owens wrote: >> >> > >> >> > > Currently, /proc//map_files/ is restricted to CAP_SYS_ADMIN, and >> >> > > is only exposed if CONFIG_CHECKPOINT_RESTORE is set. >> >> > > >> >> > > This interface very useful because it allows userspace to stat() >> >> > > deleted files that are still mapped by some process, which enables a >> >> > > much quicker and more accurate answer to the question "How much disk >> >> > > space is being consumed by files that are deleted but still mapped?" >> >> > > than is currently possible. >> >> > >> >> > Why is that information useful? >> >> > >> >> > I could perhaps think of some use for "How much disk space is being >> >> > consumed by files that are deleted but still open", but to count the >> >> > mmapped-then-unlinked files while excluding the opened-then-unlinked >> >> > files seems damned peculiar. >> >> >> >> Let's phrase the question a bit more generically: >> >> >> >> "How much disk space is being consumed by files that have been >> >> unlinked, but are still referenced by some process?" >> >> >> >> There are two pieces to this problem: >> >> 1) Unlinked files that are still open (whether mapped or not) >> >> 2) Unlinked files that are not open, but are still mapped >> >> >> >> You can track down everything in (1) using /proc//fd/*, and you >> >> can use stat() to figure out how much space they're using. >> > >> > This doesn't work if the mapped file has been unlinked? What does the >> > /proc/pid/map_files listing look like for these? >> >> It says "(deleted)" like /proc/*/exe or any other symlink. > > Actually the symlink directs at "/home/akpm/foo (deleted)". I meant exactly that: full path + (deleted). > And lo, if you do `stat -L' on the symlink, you get the info for the > unlinked-but-still-mmapped inode. I never knew that. And I wouldn't > have learned it from the documentation, which is careful to keep all > this a secret. Yes, map_files symlinks allow to reach descriptors in the very same way /proc/*/fd symlinks allow to reach descriptors. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/