From: Robert Foss <robert.foss@collabora.com>
To: Mateusz Guzik <mguzik@redhat.com>
Cc: akpm@linux-foundation.org, keescook@chromium.org,
viro@zeniv.linux.org.uk, gorcunov@openvz.org,
john.stultz@linaro.org, plaguedbypenguins@gmail.com,
sonnyrao@chromium.org, adobriyan@gmail.com, jdanis@google.com,
calvinowens@fb.com, jann@thejh.net, mhocko@suse.com,
koct9i@gmail.com, vbabka@suse.cz, n-horiguchi@ah.jp.nec.com,
kirill.shutemov@linux.intel.com, ldufour@linux.vnet.ibm.com,
hannes@cmpxchg.org, linux-kernel@vger.kernel.org,
Ben Zhang <benzh@chromium.org>, Bryan Freed <bfreed@chromium.org>,
Filipe Brandenburger <filbranden@chromium.org>
Subject: Re: [PACTH v1] mm, proc: Implement /proc/<pid>/totmaps
Date: Wed, 10 Aug 2016 11:50:56 -0400 [thread overview]
Message-ID: <940e10e8-248a-ea94-32cc-8f75ed39a92c@collabora.com> (raw)
In-Reply-To: <20160810154253.zcf2lmydewxifeat@mguzik>
On 2016-08-10 11:42 AM, Mateusz Guzik wrote:
> On Wed, Aug 10, 2016 at 11:39:12AM -0400, Robert Foss wrote:
>>
>>
>> On 2016-08-09 04:17 PM, Robert Foss wrote:
>>>>> +static int totmaps_proc_show(struct seq_file *m, void *data)
>>>>> +{
>>>>> + struct proc_maps_private *priv = m->private;
>>>>> + struct mm_struct *mm;
>>>>> + struct vm_area_struct *vma;
>>>>> + struct mem_size_stats *mss_sum = priv->mss;
>>>>> +
>>>>> + /* reference to priv->task already taken */
>>>>> + /* but need to get the mm here because */
>>>>> + /* task could be in the process of exiting */
>>>>> + mm = get_task_mm(priv->task);
>>>>> + if (!mm || IS_ERR(mm))
>>>>> + return -EINVAL;
>>>>> +
>>>>
>>>> That's not how it's done in smaps.
>>>
>>> Alright, I'll have to look into the difference between this approach and
>>> the smaps one.
>>
>>
>> I had a look at show_smaps(), and it's not entirely clear to me what the
>> advantage of doing it show_smaps() way.
>>
>> mm = get_task_mm(priv->task) is needed to iterate through all of the
>> mappings. Is there a preferable way of doing that?
>
> In the other part of the mail I stated smaps goes to proc_maps_open
> which has:
> priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
>
> This gives you stable access to mm and all needed permission checks.
>
> Then, in the read routine you can just:
> if (!atomic_inc_not_zero(&mm->mm_users))
> goto thats_it;
>
> See smaps routines or e.g. environ_read.
>
Ah! I see what you mean now. Thanks for the clarification!
Rob.
next prev parent reply other threads:[~2016-08-10 18:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 16:05 robert.foss
2016-08-09 16:29 ` Mateusz Guzik
2016-08-09 16:56 ` Sonny Rao
2016-08-09 20:17 ` Robert Foss
2016-08-10 15:39 ` Robert Foss
2016-08-10 15:42 ` Mateusz Guzik
2016-08-10 15:50 ` Robert Foss [this message]
2016-08-09 16:58 ` Alexey Dobriyan
2016-08-09 18:28 ` Sonny Rao
2016-08-09 19:16 ` Konstantin Khlebnikov
2016-08-10 0:30 ` Sonny Rao
2016-08-09 19:24 ` Jann Horn
2016-08-09 21:01 ` Robert Foss
2016-08-09 22:30 ` Jann Horn
2016-08-10 14:16 ` Robert Foss
2016-08-10 15:02 ` Jann Horn
2016-08-10 16:24 ` Robert Foss
2016-08-10 17:23 ` Sonny Rao
2016-08-10 17:37 ` Jann Horn
2016-08-10 17:45 ` Sonny Rao
2016-08-10 18:05 ` Jann Horn
2016-08-12 16:28 ` Robert Foss
2016-08-13 12:39 ` Jann Horn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=940e10e8-248a-ea94-32cc-8f75ed39a92c@collabora.com \
--to=robert.foss@collabora.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benzh@chromium.org \
--cc=bfreed@chromium.org \
--cc=calvinowens@fb.com \
--cc=filbranden@chromium.org \
--cc=gorcunov@openvz.org \
--cc=hannes@cmpxchg.org \
--cc=jann@thejh.net \
--cc=jdanis@google.com \
--cc=john.stultz@linaro.org \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=ldufour@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mguzik@redhat.com \
--cc=mhocko@suse.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=plaguedbypenguins@gmail.com \
--cc=sonnyrao@chromium.org \
--cc=vbabka@suse.cz \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®