From: Pavel Emelianov <xemul@openvz.org>
To: Balbir Singh <balbir@in.ibm.com>
Cc: Linux MM <linux-mm@kvack.org>,
dev@openvz.org, ckrm-tech@lists.sourceforge.net,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
haveblue@us.ibm.com, rohitseth@google.com
Subject: Re: [RFC][PATCH 4/8] RSS controller accounting
Date: Fri, 10 Nov 2006 12:06:52 +0300 [thread overview]
Message-ID: <4554412C.3070904@openvz.org> (raw)
In-Reply-To: <20061109193600.21437.74220.sendpatchset@balbir.in.ibm.com>
Balbir Singh wrote:
> Account RSS usage of a task and the associated container. The definition
> of RSS was debated and discussed in the following thread
>
> http://lkml.org/lkml/2006/10/10/130
>
>
> The code tracks all resident pages (including shared pages) as RSS. This patch
> can easily adapt to the definition of RSS that will be agreed upon. This
> implementation provides a proof of concept RSS controller.
>
> The accounting is inspired from Rohit Seth's container patches.
>
> TODO's
>
> 1. Merge file_rss and anon_rss tracking with the current rss tracking to
> maximize code reuse
> 2. Add/remove RSS tracking as the definition of RSS evolves
>
>
> Signed-off-by: Balbir Singh <balbir@in.ibm.com>
> ---
>
[snip]
> --- linux-2.6.19-rc2/kernel/res_group/memctlr.c~container-memctlr-acct 2006-11-09 21:46:22.000000000 +0530
> +++ linux-2.6.19-rc2-balbir/kernel/res_group/memctlr.c 2006-11-09 21:47:06.000000000 +0530
> @@ -37,6 +37,8 @@ static struct resource_group *root_rgrou
> static const char version[] = "0.01";
> static struct memctlr *memctlr_root;
>
> +#define MEMCTLR_MAGIC 0xdededede
> +
> struct mem_counter {
> atomic_long_t rss;
> };
> @@ -49,6 +51,7 @@ struct memctlr {
> /* Statistics */
> int successes;
> int failures;
> + int magic;
What is this magic for? Is it just for debugging?
[snip]
> +static inline struct memctlr *get_memctlr_from_page(struct page *page)
> +{
> + struct resource_group *rgroup;
> + struct memctlr *res;
> +
> + /*
> + * Is the resource groups infrastructure initialized?
> + */
> + if (!memctlr_root)
> + return NULL;
> +
> + rcu_read_lock();
> + rgroup = (struct resource_group *)rcu_dereference(current->container);
> + rcu_read_unlock();
> +
> + res = get_memctlr(rgroup);
> + if (!res)
> + return NULL;
> +
> + BUG_ON(res->magic != MEMCTLR_MAGIC);
> + return res;
> +}
I don't see how page passed to this function is involved into
'struct memctlr *res' determining. Could you comment this?
[snip]
> --- linux-2.6.19-rc2/mm/rmap.c~container-memctlr-acct 2006-11-09 21:46:22.000000000 +0530
> +++ linux-2.6.19-rc2-balbir/mm/rmap.c 2006-11-09 21:46:22.000000000 +0530
> @@ -537,6 +537,7 @@ void page_add_anon_rmap(struct page *pag
> if (atomic_inc_and_test(&page->_mapcount))
> __page_set_anon_rmap(page, vma, address);
> /* else checking page index and mapping is racy */
> + memctlr_inc_rss(page);
> }
>
> /*
> @@ -553,6 +554,7 @@ void page_add_new_anon_rmap(struct page
> {
> atomic_set(&page->_mapcount, 0); /* elevate count by 1 (starts at -1) */
> __page_set_anon_rmap(page, vma, address);
> + memctlr_inc_rss(page);
> }
>
> /**
> @@ -565,6 +567,7 @@ void page_add_file_rmap(struct page *pag
> {
> if (atomic_inc_and_test(&page->_mapcount))
> __inc_zone_page_state(page, NR_FILE_MAPPED);
> + memctlr_inc_rss(page);
Consider a task maps one file page 100 times in different places
and touches 'all of them'. In this case I see that you'll get
100 in rss counter while real rss will be just 1.
> }
>
> /**
> @@ -596,8 +599,9 @@ void page_remove_rmap(struct page *page)
> if (page_test_and_clear_dirty(page))
> set_page_dirty(page);
> __dec_zone_page_state(page,
> - PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
> + PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
What is this extra space after a question-mark for?
> }
> + memctlr_dec_rss(page, mm);
> }
>
> /*
> diff -puN include/linux/rmap.h~container-memctlr-acct include/linux/rmap.h
> --- linux-2.6.19-rc2/include/linux/rmap.h~container-memctlr-acct 2006-11-09 21:46:22.000000000 +0530
> +++ linux-2.6.19-rc2-balbir/include/linux/rmap.h 2006-11-09 21:46:22.000000000 +0530
> @@ -8,6 +8,7 @@
> #include <linux/slab.h>
> #include <linux/mm.h>
> #include <linux/spinlock.h>
> +#include <linux/memctlr.h>
>
> /*
> * The anon_vma heads a list of private "related" vmas, to scan if
> @@ -84,6 +85,7 @@ void page_remove_rmap(struct page *);
> static inline void page_dup_rmap(struct page *page)
> {
> atomic_inc(&page->_mapcount);
> + memctlr_inc_rss(page);
> }
I'm not sure this is correct. page_dup_rmap() happens in the context
of forking process and thus you'll increment rss counter on current.
But this must be incremented at new task's counter, mustn't it?
--
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:[~2006-11-10 9:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-09 19:35 [RFC][PATCH 0/8] RSS controller for containers Balbir Singh
2006-11-09 19:35 ` [RFC][PATCH 1/8] Fix resource groups parsing, while assigning shares Balbir Singh
2006-11-09 19:35 ` [RFC][PATCH 2/8] RSS controller setup Balbir Singh
2006-11-09 19:35 ` [RFC][PATCH 3/8] RSS controller add callbacks Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 4/8] RSS controller accounting Balbir Singh
2006-11-10 9:06 ` Pavel Emelianov [this message]
2006-11-10 9:29 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 5/8] RSS controller task migration support Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 6/8] RSS controller shares allocation Balbir Singh
2006-11-10 9:11 ` Pavel Emelianov
2006-11-10 10:27 ` [ckrm-tech] " Balbir Singh
2006-11-10 10:32 ` Pavel Emelianov
2006-11-10 12:55 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 7/8] RSS controller fix resource groups parsing Balbir Singh
2006-11-10 9:13 ` Pavel Emelianov
2006-11-10 9:32 ` Balbir Singh
2006-11-09 19:36 ` [RFC][PATCH 8/8] RSS controller support reclamation Balbir Singh
2006-11-09 19:45 ` Arjan van de Ven
2006-11-10 1:56 ` [ckrm-tech] " Balbir Singh
2006-11-10 8:54 ` Pavel Emelianov
2006-11-10 9:16 ` Balbir Singh
2006-11-10 9:29 ` Pavel Emelianov
2006-11-10 12:42 ` Balbir Singh
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=4554412C.3070904@openvz.org \
--to=xemul@openvz.org \
--cc=balbir@in.ibm.com \
--cc=ckrm-tech@lists.sourceforge.net \
--cc=dev@openvz.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rohitseth@google.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