From: Michal Hocko <mhocko@kernel.org>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jerome Marchand <jmarchan@redhat.com>,
Hugh Dickins <hughd@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Oleg Nesterov <oleg@redhat.com>,
linux-api@vger.kernel.org, linux-doc@vger.kernel.org,
Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Subject: Re: [PATCH v5 3/6] mm, proc: reduce cost of /proc/pid/smaps for shmem mappings
Date: Thu, 19 Nov 2015 11:04:55 +0100 [thread overview]
Message-ID: <20151119100455.GB8494@dhcp22.suse.cz> (raw)
In-Reply-To: <1447838976-17607-4-git-send-email-vbabka@suse.cz>
On Wed 18-11-15 10:29:33, Vlastimil Babka wrote:
> The previous patch has improved swap accounting for shmem mapping, which
> however made /proc/pid/smaps more expensive for shmem mappings, as we consult
> the radix tree for each pte_none entry, so the overal complexity is
> O(n*log(n)).
>
> We can reduce this significantly for mappings that cannot contain COWed pages,
> because then we can either use the statistics tha shmem object itself tracks
> (if the mapping contains the whole object, or the swap usage of the whole
> object is zero), or use the radix tree iterator, which is much more effective
> than repeated find_get_entry() calls.
>
> This patch therefore introduces a function shmem_swap_usage(vma) and makes
> /proc/pid/smaps use it when possible. Only for writable private mappings of
> shmem objects (i.e. tmpfs files) with the shmem object itself (partially)
> swapped outwe have to resort to the find_get_entry() approach. Hopefully
> such mappings are relatively uncommon.
>
> To demonstrate the diference, I have measured this on a process that creates
> a 2GB mapping and dirties single pages with a stride of 2MB, and time how long
> does it take to cat /proc/pid/smaps of this process 100 times.
>
> Private writable mapping of a /dev/shm/file (the most complex case):
>
> real 0m3.831s
> user 0m0.180s
> sys 0m3.212s
>
> Shared mapping of an almost full mapping of a partially swapped /dev/shm/file
> (which needs to employ the radix tree iterator).
>
> real 0m1.351s
> user 0m0.096s
> sys 0m0.768s
>
> Same, but with /dev/shm/file not swapped (so no radix tree walk needed)
>
> real 0m0.935s
> user 0m0.128s
> sys 0m0.344s
>
> Private anonymous mapping:
>
> real 0m0.949s
> user 0m0.116s
> sys 0m0.348s
>
> The cost is now much closer to the private anonymous mapping case, unless the
> shmem mapping is private and writable.
>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Looks good to me
Acked-by: Michal Hocko <mhocko@suse.com>
[...]
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-11-19 10:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 9:29 [PATCH v5 0/6] enhance shmem process and swap accounting Vlastimil Babka
[not found] ` <1447838976-17607-1-git-send-email-vbabka-AlSwsSmVLrQ@public.gmane.org>
2015-11-18 9:29 ` [PATCH v5 1/6] mm, documentation: clarify /proc/pid/status VmSwap limitations for shmem Vlastimil Babka
2015-11-18 9:29 ` [PATCH v5 2/6] mm, proc: account for shmem swap in /proc/pid/smaps Vlastimil Babka
2015-11-18 9:29 ` [PATCH v5 3/6] mm, proc: reduce cost of /proc/pid/smaps for shmem mappings Vlastimil Babka
2015-11-19 10:04 ` Michal Hocko [this message]
2015-11-18 9:29 ` [PATCH v5 4/6] mm, proc: reduce cost of /proc/pid/smaps for unpopulated " Vlastimil Babka
2015-11-19 10:13 ` Michal Hocko
2015-11-18 9:29 ` [PATCH v5 5/6] mm, shmem: add internal shmem resident memory accounting Vlastimil Babka
2015-11-18 9:29 ` [PATCH v5 6/6] mm, procfs: breakdown RSS for anon, shmem and file in /proc/pid/status Vlastimil Babka
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=20151119100455.GB8494@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=jmarchan@redhat.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-api@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).