From: Andrew Morton <akpm@linux-foundation.org>
To: Minchan Kim <minchan@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hugh Dickins <hughd@google.com>,
Bongkyu Kim <bongkyu.kim@lge.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH v2] mm: show proportional swap share of the mapping
Date: Tue, 14 Jul 2015 14:07:08 -0700 [thread overview]
Message-ID: <20150714140708.c7a406aa2bf43ecf73844e96@linux-foundation.org> (raw)
In-Reply-To: <1434373614-1041-1-git-send-email-minchan@kernel.org>
On Mon, 15 Jun 2015 22:06:54 +0900 Minchan Kim <minchan@kernel.org> wrote:
> We want to know per-process workingset size for smart memory management
> on userland and we use swap(ex, zram) heavily to maximize memory efficiency
> so workingset includes swap as well as RSS.
>
> On such system, if there are lots of shared anonymous pages, it's
> really hard to figure out exactly how many each process consumes
> memory(ie, rss + wap) if the system has lots of shared anonymous
> memory(e.g, android).
>
> This patch introduces SwapPss field on /proc/<pid>/smaps so we can get
> more exact workingset size per process.
>
> ...
>
> +int swp_swapcount(swp_entry_t entry)
> +{
> + int count, tmp_count, n;
> + struct swap_info_struct *p;
> + struct page *page;
> + pgoff_t offset;
> + unsigned char *map;
> +
> + p = swap_info_get(entry);
> + if (!p)
> + return 0;
> +
> + count = swap_count(p->swap_map[swp_offset(entry)]);
> + if (!(count & COUNT_CONTINUED))
> + goto out;
> +
> + count &= ~COUNT_CONTINUED;
> + n = SWAP_MAP_MAX + 1;
> +
> + offset = swp_offset(entry);
> + page = vmalloc_to_page(p->swap_map + offset);
> + offset &= ~PAGE_MASK;
> + VM_BUG_ON(page_private(page) != SWP_CONTINUED);
> +
> + do {
> + page = list_entry(page->lru.next, struct page, lru);
> + map = kmap_atomic(page) + offset;
> + tmp_count = *map;
> + kunmap_atomic(map);
A little thing: I've never liked the way that kunmap_atomic() accepts
any address within the page. It's weird, and it makes the reviewer
have to scramble around to make sure the offset can never be >=
PAGE_SIZE.
We can easily avoid doing it here:
--- a/mm/swapfile.c~mm-show-proportional-swap-share-of-the-mapping-fix
+++ a/mm/swapfile.c
@@ -904,8 +904,8 @@ int swp_swapcount(swp_entry_t entry)
do {
page = list_entry(page->lru.next, struct page, lru);
- map = kmap_atomic(page) + offset;
- tmp_count = *map;
+ map = kmap_atomic(page);
+ tmp_count = map[offset];
kunmap_atomic(map);
count += (tmp_count & ~COUNT_CONTINUED) * n;
> + count += (tmp_count & ~COUNT_CONTINUED) * n;
> + n *= (SWAP_CONT_MAX + 1);
> + } while (tmp_count & COUNT_CONTINUED);
> +out:
> + spin_unlock(&p->lock);
> + return count;
> +}
>
> ...
>
--
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-07-14 21:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-15 13:06 [PATCH v2] mm: show proportional swap share of the mapping Minchan Kim
2015-07-07 13:47 ` Minchan Kim
2015-07-14 21:07 ` Andrew Morton [this message]
2015-07-15 23:49 ` Minchan Kim
2015-07-29 8:33 ` Jerome Marchand
2015-07-29 10:30 ` Minchan Kim
2015-07-29 11:56 ` Jerome Marchand
2015-08-05 11:38 ` 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=20150714140708.c7a406aa2bf43ecf73844e96@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bongkyu.kim@lge.com \
--cc=corbet@lwn.net \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
/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).