Re: [PATCH V4 4/6] memcg: add per cgroup writeback pages accounting

Started by Sha Zhengju on Jul 11, 2013

open the first message on its own page

Message details and related content
On Thu, Jul 11, 2013 at 10:40 PM, Michal Hocko [off-list ref] wrote:
On Sat 06-07-13 01:32:57, Sha Zhengju wrote:
quoted
From: Sha Zhengju <redacted>

Similar to dirty page, we add per cgroup writeback pages accounting. The lock
rule still is:
        mem_cgroup_begin_update_page_stat()
        modify page WRITEBACK stat
        mem_cgroup_update_page_stat()
        mem_cgroup_end_update_page_stat()

There're two writeback interfaces to modify: test_{clear/set}_page_writeback().

Signed-off-by: Sha Zhengju <redacted>
Acked-by: Michal Hocko <redacted>
Acked-by: KAMEZAWA Hiroyuki <redacted>
cc: Greg Thelen <redacted>
cc: Andrew Morton <redacted>
cc: Fengguang Wu <redacted>
cc: Mel Gorman <redacted>
---
 include/linux/memcontrol.h |    1 +
 mm/memcontrol.c            |    5 +++++
 mm/page-writeback.c        |   15 +++++++++++++++
 3 files changed, 21 insertions(+)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index f952be6..ccd35d8 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -43,6 +43,7 @@ enum mem_cgroup_stat_index {
      MEM_CGROUP_STAT_RSS_HUGE,       /* # of pages charged as anon huge */
      MEM_CGROUP_STAT_FILE_MAPPED,    /* # of pages charged as file rss */
      MEM_CGROUP_STAT_FILE_DIRTY,     /* # of dirty pages in page cache */
+     MEM_CGROUP_STAT_WRITEBACK,      /* # of pages under writeback */
      MEM_CGROUP_STAT_SWAP,           /* # of pages, swapped out */
      MEM_CGROUP_STAT_NSTATS,
 };
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 1d31851..9126abc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -92,6 +92,7 @@ static const char * const mem_cgroup_stat_names[] = {
      "mapped_file",
      "swap",
      "dirty",
+     "writeback",
Ordering issue again (see mem_cgroup_stat_index)
Yes, you're right.
quoted
 };

 enum mem_cgroup_events_index {
[...]
quoted
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 3900e62..85de9a0 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2008,11 +2008,17 @@ EXPORT_SYMBOL(account_page_dirtied);

 /*
  * Helper function for set_page_writeback family.
+ *
+ * The caller must hold mem_cgroup_begin/end_update_page_stat() lock
+ * while modifying struct page state and accounting writeback pages.
I guess "while calling this function" would be sufficient
Thanks for the advice.
quoted
+ * See test_set_page_writeback for example.
+ *
  * NOTE: Unlike account_page_dirtied this does not rely on being atomic
  * wrt interrupts.
  */
 void account_page_writeback(struct page *page)
 {
+     mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_WRITEBACK);
      inc_zone_page_state(page, NR_WRITEBACK);
 }
 EXPORT_SYMBOL(account_page_writeback);
[...]
--
Michal Hocko
SUSE Labs


--
Thanks,
Sha
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help