From: Minchan Kim <minchan@kernel.org>
To: Michal Hocko <mhocko@kernel.org>
Cc: Sonny Rao <sonnyrao@chromium.org>, Jann Horn <jann@thejh.net>,
Robert Foss <robert.foss@collabora.com>, <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
Konstantin Khlebnikov <koct9i@gmail.com>,
Hugh Dickins <hughd@google.com>,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
John Stultz <john.stultz@linaro.org>,
<ross.zwisler@linux.intel.com>, <jmarchan@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Kees Cook <keescook@chromium.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Robin Humble <plaguedbypenguins@gmail.com>,
David Rientjes <rientjes@google.com>, <eric.engestrom@imgtec.com>,
Janis Danisevskis <jdanis@google.com>, <calvinowens@fb.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<ldufour@linux.vnet.ibm.com>, <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ben Zhang <benzh@chromium.org>, Bryan Freed <bfreed@chromium.org>,
Filipe Brandenburger <filbranden@chromium.org>,
Mateusz Guzik <mguzik@redhat.com>
Subject: Re: [PACTH v2 0/3] Implement /proc/<pid>/totmaps
Date: Mon, 22 Aug 2016 09:07:45 +0900 [thread overview]
Message-ID: <20160822000745.GA21441@bbox> (raw)
In-Reply-To: <20160819080532.GC32619@dhcp22.suse.cz>
On Fri, Aug 19, 2016 at 10:05:32AM +0200, Michal Hocko wrote:
> On Fri 19-08-16 11:26:34, Minchan Kim wrote:
> > Hi Michal,
> >
> > On Thu, Aug 18, 2016 at 08:01:04PM +0200, Michal Hocko wrote:
> > > On Thu 18-08-16 10:47:57, Sonny Rao wrote:
> > > > On Thu, Aug 18, 2016 at 12:44 AM, Michal Hocko <mhocko@kernel.org> wrote:
> > > > > On Wed 17-08-16 11:57:56, Sonny Rao wrote:
> > > [...]
> > > > >> 2) User space OOM handling -- we'd rather do a more graceful shutdown
> > > > >> than let the kernel's OOM killer activate and need to gather this
> > > > >> information and we'd like to be able to get this information to make
> > > > >> the decision much faster than 400ms
> > > > >
> > > > > Global OOM handling in userspace is really dubious if you ask me. I
> > > > > understand you want something better than SIGKILL and in fact this is
> > > > > already possible with memory cgroup controller (btw. memcg will give
> > > > > you a cheap access to rss, amount of shared, swapped out memory as
> > > > > well). Anyway if you are getting close to the OOM your system will most
> > > > > probably be really busy and chances are that also reading your new file
> > > > > will take much more time. I am also not quite sure how is pss useful for
> > > > > oom decisions.
> > > >
> > > > I mentioned it before, but based on experience RSS just isn't good
> > > > enough -- there's too much sharing going on in our use case to make
> > > > the correct decision based on RSS. If RSS were good enough, simply
> > > > put, this patch wouldn't exist.
> > >
> > > But that doesn't answer my question, I am afraid. So how exactly do you
> > > use pss for oom decisions?
> >
> > My case is not for OOM decision but I agree it would be great if we can get
> > *fast* smap summary information.
> >
> > PSS is really great tool to figure out how processes consume memory
> > more exactly rather than RSS. We have been used it for monitoring
> > of memory for per-process. Although it is not used for OOM decision,
> > it would be great if it is speed up because we don't want to spend
> > many CPU time for just monitoring.
> >
> > For our usecase, we don't need AnonHugePages, ShmemPmdMapped, Shared_Hugetlb,
> > Private_Hugetlb, KernelPageSize, MMUPageSize because we never enable THP and
> > hugetlb. Additionally, Locked can be known via vma flags so we don't need it,
> > either. Even, we don't need address range for just monitoring when we don't
> > investigate in detail.
> >
> > Although they are not severe overhead, why does it emit the useless
> > information? Even bloat day by day. :( With that, userspace tools should
> > spend more time to parse which is pointless.
>
> So far it doesn't really seem that the parsing is the biggest problem.
> The major cycles killer is the output formatting and that doesn't sound
I cannot understand how kernel space is more expensive.
Hmm. I tested your test program on my machine.
#!/bin/sh
./smap_test &
pid=$!
for i in $(seq 25)
do
cat /proc/$pid/smaps > /dev/null
done
kill $pid
root@bbox:/home/barrios/test/smap# time ./s_v.sh
pid:21925
real 0m3.365s
user 0m0.031s
sys 0m3.046s
vs.
#!/bin/sh
./smap_test &
pid=$!
for i in $(seq 25)
do
awk '/^Rss/{rss+=$2} /^Pss/{pss+=$2} END {}' \
/proc/$pid/smaps
done
kill $pid
root@bbox:/home/barrios/test/smap# time ./s.sh
pid:21973
real 0m17.812s
user 0m12.612s
sys 0m5.187s
perf report says
39.56% awk gawk [.] dfaexec
7.61% awk [kernel.kallsyms] [k] format_decode
6.37% awk gawk [.] avoid_dfa
5.85% awk gawk [.] interpret
5.69% awk [kernel.kallsyms] [k] __memcpy
4.37% awk [kernel.kallsyms] [k] vsnprintf
2.69% awk [kernel.kallsyms] [k] number.isra.13
2.10% awk gawk [.] research
1.91% awk gawk [.] 0x00000000000351d0
1.49% awk gawk [.] free_wstr
1.27% awk gawk [.] unref
1.19% awk gawk [.] reset_record
0.95% awk gawk [.] set_record
0.95% awk gawk [.] get_field
0.94% awk [kernel.kallsyms] [k] show_smap
Parsing is much expensive than kernel.
Could you retest your test program?
> like a problem we are not able to address. And I would even argue that
> we want to address it in a generic way as much as possible.
Sure. What solution do you think as generic way?
>
> > Having said that, I'm not fan of creating new stat knob for that, either.
> > How about appending summary information in the end of smap?
> > So, monitoring users can just open the file and lseek to the (end - 1) and
> > read the summary only.
>
> That might confuse existing parsers. Besides that we already have
> /proc/<pid>/statm which gives cumulative numbers already. I am not sure
> how often it is used and whether the pte walk is too expensive for
> existing users but that should be explored and evaluated before a new
> file is created.
>
> The /proc became a dump of everything people found interesting just
> because we were to easy to allow those additions. Do not repeat those
> mistakes, please!
> --
> Michal Hocko
> SUSE Labs
next prev parent reply other threads:[~2016-08-22 0:07 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 22:04 [PACTH v2 0/3] Implement /proc/<pid>/totmaps robert.foss
2016-08-12 22:04 ` [PACTH v2 1/3] mm, proc: " robert.foss
2016-08-13 14:39 ` Jann Horn
2016-08-15 13:57 ` Robert Foss
2016-08-15 20:14 ` Robert Foss
2016-08-12 22:04 ` [PACTH v2 2/3] Documentation/filesystems: Fixed typo robert.foss
2016-08-12 22:04 ` [PACTH v2 3/3] Documentation/filesystems: Added /proc/PID/totmaps documentation robert.foss
2016-08-14 9:04 ` [PACTH v2 0/3] Implement /proc/<pid>/totmaps Michal Hocko
2016-08-15 13:00 ` Robert Foss
2016-08-15 13:42 ` Michal Hocko
2016-08-15 16:25 ` Robert Foss
2016-08-16 7:12 ` Michal Hocko
2016-08-16 16:46 ` Robert Foss
2016-08-17 8:22 ` Michal Hocko
2016-08-17 9:31 ` Jann Horn
2016-08-17 13:03 ` Michal Hocko
2016-08-17 16:48 ` Robert Foss
2016-08-17 18:57 ` Sonny Rao
2016-08-18 7:44 ` Michal Hocko
2016-08-18 17:47 ` Sonny Rao
2016-08-18 18:01 ` Michal Hocko
2016-08-18 21:05 ` Robert Foss
2016-08-19 6:27 ` Sonny Rao
2016-08-19 2:26 ` Minchan Kim
2016-08-19 6:47 ` Sonny Rao
2016-08-19 8:05 ` Michal Hocko
2016-08-19 18:20 ` Sonny Rao
2016-08-22 0:07 ` Minchan Kim [this message]
2016-08-22 7:40 ` Michal Hocko
2016-08-22 14:12 ` Minchan Kim
2016-08-22 14:37 ` Robert Foss
2016-08-22 16:45 ` Michal Hocko
2016-08-22 17:29 ` Michal Hocko
2016-08-22 17:47 ` Michal Hocko
2016-08-23 8:26 ` Michal Hocko
2016-08-23 14:33 ` utime accounting regression since 4.6 (was: Re: [PACTH v2 0/3] Implement /proc/<pid>/totmaps) Michal Hocko
2016-08-23 21:46 ` Rik van Riel
2016-08-24 16:56 ` Michal Hocko
2016-09-30 9:49 ` Michal Hocko
2016-09-30 12:35 ` Rik van Riel
2016-08-19 6:43 ` [PACTH v2 0/3] Implement /proc/<pid>/totmaps Sonny Rao
2016-08-19 7:59 ` Michal Hocko
2016-08-19 17:57 ` Sonny Rao
2016-08-22 7:54 ` Michal Hocko
2016-08-22 22:44 ` Sonny Rao
2016-08-24 10:14 ` Marcin Jabrzyk
2016-08-30 8:20 ` Michal Hocko
2016-08-29 14:37 ` Michal Hocko
2016-08-30 8:15 ` Michal Hocko
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=20160822000745.GA21441@bbox \
--to=minchan@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=benzh@chromium.org \
--cc=bfreed@chromium.org \
--cc=calvinowens@fb.com \
--cc=corbet@lwn.net \
--cc=eric.engestrom@imgtec.com \
--cc=filbranden@chromium.org \
--cc=gorcunov@openvz.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jann@thejh.net \
--cc=jdanis@google.com \
--cc=jmarchan@redhat.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-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mguzik@redhat.com \
--cc=mhocko@kernel.org \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=plaguedbypenguins@gmail.com \
--cc=rientjes@google.com \
--cc=robert.foss@collabora.com \
--cc=ross.zwisler@linux.intel.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