Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1163156

Re: [PATCH v6] procfs: Always expose /proc/<pid>/map_files/ and make it readable

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Alexey Dobriyan <adobriyan@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6] procfs: Always expose /proc/<pid>/map_files/ and make it readable
Date Thu, 11 Jun 2015 13:20:02 +0200
Message-ID <pA8GC-40B-15@gated-at.bofh.it> (permalink)
References <prGeu-1RF-5@gated-at.bofh.it> <pziI1-2ST-3@gated-at.bofh.it> <pzz6a-1SC-13@gated-at.bofh.it> <pzDjt-7Zy-5@gated-at.bofh.it> <pzVgo-Sd-47@gated-at.bofh.it>
X-Original-To Andrew Morton <akpm@linux-foundation.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Baagg19wb+HudXTw6iVQke9XvAGPr3xurAbGAQnq0KU=; b=gdsDQkM+x30Kpl/nAFg/ZUf83wGJZ5x3QQi18NojyaOYWNpXxQ2BJ5T0F8cdMBChzE AaEga9m6ivYJs1Vpx9sRgi9HtlGExS2Xc3aUJON8lQ0fugkESuJOlcw3DUUnyvRfeH54 EdZU8XTKZ+Co6AT8qHKdl/8PNcEIgDcsdTBRH3R1e4ud0M322U69/DHkbo4VGPui/rnc ZMHZc+bWq8dWvyiKm7i5f43UWFdE9AplN7yg2LagATit37xCTjn1vxGo/S3hXT6XV/4n 9e2Zalk9wCqeMAOmTlTM5ajtsjlw3PCIDhtrzPtBPfxxLU9yxNG7wFydg/OAzsa+HUfY ayiA==
MIME-Version 1.0
X-Received by 10.112.157.100 with SMTP id wl4mr9303818lbb.20.1434021045292; Thu, 11 Jun 2015 04:10:45 -0700 (PDT)
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 57
Organization linux.* mail to news gateway
X-Original-Cc Calvin Owens <calvinowens@fb.com>, "Eric W. Biederman" <ebiederm@xmission.com>, Al Viro <viro@zeniv.linux.org.uk>, Miklos Szeredi <miklos@szeredi.hu>, Zefan Li <lizefan@huawei.com>, Oleg Nesterov <oleg@redhat.com>, Joe Perches <joe@perches.com>, David Howells <dhowells@redhat.com>, Linux Kernel <linux-kernel@vger.kernel.org>, kernel-team@fb.com, Andy Lutomirski <luto@amacapital.net>, Cyrill Gorcunov <gorcunov@openvz.org>, Kees Cook <keescook@chromium.org>, "Kirill A. Shutemov" <kirill@shutemov.name>
X-Original-Date Thu, 11 Jun 2015 14:10:45 +0300
X-Original-Message-ID <CACVxJT_2hVCjg5apS-wcuFRPdZD91FUX_9drrUxDXqTq1Px7mg@mail.gmail.com>
X-Original-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>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1163156

Show key headers only | View raw


On Wed, Jun 10, 2015 at 11:58 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Tue, 9 Jun 2015 18:39:02 -0700 Calvin Owens <calvinowens@fb.com> wrote:
>
>> On Tuesday 06/09 at 14:13 -0700, Andrew Morton wrote:
>> > On Mon, 8 Jun 2015 20:39:33 -0700 Calvin Owens <calvinowens@fb.com> wrote:
>> >
>> > > Currently, /proc/<pid>/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/<pid>/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.

>> Does that all seem sensible?
>
> Spose so.  Please capture all this info in the changelog.
>
>
> It all seems a bit awkward though.  If we want to know "how much disk
> space is this process using" (or similar) then I wonder what a syscall
> (or prctl mode?) which does this would look like.

I believe something like this is needed for checkpointing,
otherwise mmaped but unlinked files could not be restored fully
(how do you reach them?).
--
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/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH v6] procfs: Always expose /proc/<pid>/map_files/ and make it readable Calvin Owens <calvinowens@fb.com> - 2015-06-09 05:50 +0200
  Re: [PATCH v6] procfs: Always expose /proc/<pid>/map_files/ and make  it readable Calvin Owens <calvinowens@fb.com> - 2015-06-10 03:50 +0200
    Re: [PATCH v6] procfs: Always expose /proc/<pid>/map_files/ and make  it readable Alexey Dobriyan <adobriyan@gmail.com> - 2015-06-11 13:20 +0200

csiph-web