From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Ying Han <yinghan@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/10] mm/memcg: remove mem_cgroup_reset_owner
Date: Mon, 20 Feb 2012 15:35:38 -0800 (PST) [thread overview]
Message-ID: <alpine.LSU.2.00.1202201534340.23274@eggly.anvils> (raw)
In-Reply-To: <alpine.LSU.2.00.1202201518560.23274@eggly.anvils>
With mem_cgroup_reset_uncharged_to_root() now making sure that freed
pages point to root_mem_cgroup (instead of to a stale and perhaps
long-deleted memcg), we no longer need to initialize page memcg to
root in those odd places which put a page on lru before charging.
Delete mem_cgroup_reset_owner().
But: we have no init_page_cgroup() nowadays (and even when we had,
it was called before root_mem_cgroup had been allocated); so until
a struct page has once entered the memcg lru cycle, its page_cgroup
->mem_cgroup will be NULL instead of root_mem_cgroup.
That could be fixed by reintroducing init_page_cgroup(), and ordering
properly: in future we shall probably want root_mem_cgroup in kernel
bss or data like swapper_space; but let's not get into that right now.
Instead allow for this in page_relock_lruvec(): treating NULL as
root_mem_cgroup, and correcting pc->mem_cgroup before going further.
What? Before even taking the zone->lru_lock? Is that safe?
Yes, because compaction and lumpy reclaim use __isolate_lru_page(),
which refuses unless it sees PageLRU - which may be cleared at any
instant, but we only need it to have been set once in the past for
pc->mem_cgroup to be initialized properly.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/memcontrol.h | 5 -----
mm/ksm.c | 11 -----------
mm/memcontrol.c | 23 ++++++-----------------
mm/migrate.c | 2 --
mm/swap_state.c | 10 ----------
5 files changed, 6 insertions(+), 45 deletions(-)
--- mmotm.orig/include/linux/memcontrol.h 2012-02-18 11:57:49.103524745 -0800
+++ mmotm/include/linux/memcontrol.h 2012-02-18 11:57:55.551524898 -0800
@@ -120,7 +120,6 @@ extern void mem_cgroup_print_oom_info(st
extern void mem_cgroup_replace_page_cache(struct page *oldpage,
struct page *newpage);
-extern void mem_cgroup_reset_owner(struct page *page);
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
extern int do_swap_account;
#endif
@@ -383,10 +382,6 @@ static inline void mem_cgroup_replace_pa
struct page *newpage)
{
}
-
-static inline void mem_cgroup_reset_owner(struct page *page)
-{
-}
#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
#if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
--- mmotm.orig/mm/ksm.c 2012-02-18 11:56:23.435522709 -0800
+++ mmotm/mm/ksm.c 2012-02-18 11:57:55.551524898 -0800
@@ -28,7 +28,6 @@
#include <linux/kthread.h>
#include <linux/wait.h>
#include <linux/slab.h>
-#include <linux/memcontrol.h>
#include <linux/rbtree.h>
#include <linux/memory.h>
#include <linux/mmu_notifier.h>
@@ -1572,16 +1571,6 @@ struct page *ksm_does_need_to_copy(struc
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
if (new_page) {
- /*
- * The memcg-specific accounting when moving
- * pages around the LRU lists relies on the
- * page's owner (memcg) to be valid. Usually,
- * pages are assigned to a new owner before
- * being put on the LRU list, but since this
- * is not the case here, the stale owner from
- * a previous allocation cycle must be reset.
- */
- mem_cgroup_reset_owner(new_page);
copy_user_highpage(new_page, page, address, vma);
SetPageDirty(new_page);
--- mmotm.orig/mm/memcontrol.c 2012-02-18 11:57:49.107524745 -0800
+++ mmotm/mm/memcontrol.c 2012-02-18 11:57:55.551524898 -0800
@@ -1053,6 +1053,12 @@ void page_relock_lruvec(struct page *pag
else {
pc = lookup_page_cgroup(page);
memcg = pc->mem_cgroup;
+ /*
+ * At present we start up with all page_cgroups initialized
+ * to zero: correct that to root_mem_cgroup once we see it.
+ */
+ if (unlikely(!memcg))
+ memcg = pc->mem_cgroup = root_mem_cgroup;
mz = page_cgroup_zoneinfo(memcg, page);
lruvec = &mz->lruvec;
}
@@ -3038,23 +3044,6 @@ void mem_cgroup_uncharge_end(void)
batch->memcg = NULL;
}
-/*
- * A function for resetting pc->mem_cgroup for newly allocated pages.
- * This function should be called if the newpage will be added to LRU
- * before start accounting.
- */
-void mem_cgroup_reset_owner(struct page *newpage)
-{
- struct page_cgroup *pc;
-
- if (mem_cgroup_disabled())
- return;
-
- pc = lookup_page_cgroup(newpage);
- VM_BUG_ON(PageCgroupUsed(pc));
- pc->mem_cgroup = root_mem_cgroup;
-}
-
#ifdef CONFIG_SWAP
/*
* called after __delete_from_swap_cache() and drop "page" account.
--- mmotm.orig/mm/migrate.c 2012-02-18 11:56:23.435522709 -0800
+++ mmotm/mm/migrate.c 2012-02-18 11:57:55.551524898 -0800
@@ -839,8 +839,6 @@ static int unmap_and_move(new_page_t get
if (!newpage)
return -ENOMEM;
- mem_cgroup_reset_owner(newpage);
-
if (page_count(page) == 1) {
/* page was freed from under us. So we are done. */
goto out;
--- mmotm.orig/mm/swap_state.c 2012-02-18 11:56:23.435522709 -0800
+++ mmotm/mm/swap_state.c 2012-02-18 11:57:55.551524898 -0800
@@ -300,16 +300,6 @@ struct page *read_swap_cache_async(swp_e
new_page = alloc_page_vma(gfp_mask, vma, addr);
if (!new_page)
break; /* Out of memory */
- /*
- * The memcg-specific accounting when moving
- * pages around the LRU lists relies on the
- * page's owner (memcg) to be valid. Usually,
- * pages are assigned to a new owner before
- * being put on the LRU list, but since this
- * is not the case here, the stale owner from
- * a previous allocation cycle must be reset.
- */
- mem_cgroup_reset_owner(new_page);
}
/*
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-02-20 23:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 23:26 [PATCH 0/10] mm/memcg: per-memcg per-zone lru locking Hugh Dickins
2012-02-20 23:28 ` [PATCH 1/10] mm/memcg: scanning_global_lru means mem_cgroup_disabled Hugh Dickins
2012-02-21 8:03 ` KAMEZAWA Hiroyuki
2012-02-20 23:29 ` [PATCH 2/10] mm/memcg: move reclaim_stat into lruvec Hugh Dickins
2012-02-21 8:05 ` KAMEZAWA Hiroyuki
2012-02-20 23:30 ` [PATCH 3/10] mm/memcg: add zone pointer " Hugh Dickins
2012-02-21 8:08 ` KAMEZAWA Hiroyuki
2012-02-20 23:32 ` [PATCH 4/10] mm/memcg: apply add/del_page to lruvec Hugh Dickins
2012-02-21 8:20 ` KAMEZAWA Hiroyuki
2012-02-21 22:25 ` Hugh Dickins
2012-02-20 23:33 ` [PATCH 5/10] mm/memcg: introduce page_relock_lruvec Hugh Dickins
2012-02-21 8:38 ` KAMEZAWA Hiroyuki
2012-02-21 22:36 ` Hugh Dickins
2012-02-20 23:34 ` [PATCH 6/10] mm/memcg: take care over pc->mem_cgroup Hugh Dickins
2012-02-21 5:55 ` Konstantin Khlebnikov
2012-02-21 19:37 ` Hugh Dickins
2012-02-21 20:40 ` Konstantin Khlebnikov
2012-02-21 22:05 ` Hugh Dickins
2012-02-21 6:05 ` Konstantin Khlebnikov
2012-02-21 20:00 ` Hugh Dickins
2012-02-21 9:13 ` KAMEZAWA Hiroyuki
2012-02-21 23:03 ` Hugh Dickins
2012-02-22 4:05 ` Konstantin Khlebnikov
2012-02-20 23:35 ` Hugh Dickins [this message]
2012-02-21 9:17 ` [PATCH 7/10] mm/memcg: remove mem_cgroup_reset_owner KAMEZAWA Hiroyuki
2012-02-20 23:36 ` [PATCH 8/10] mm/memcg: nest lru_lock inside page_cgroup lock Hugh Dickins
2012-02-21 9:48 ` KAMEZAWA Hiroyuki
2012-02-20 23:38 ` [PATCH 9/10] mm/memcg: move lru_lock into lruvec Hugh Dickins
2012-02-21 7:08 ` Konstantin Khlebnikov
2012-02-21 20:12 ` Hugh Dickins
2012-02-21 21:35 ` Konstantin Khlebnikov
2012-02-21 22:12 ` Hugh Dickins
2012-02-22 3:43 ` Konstantin Khlebnikov
2012-02-22 6:09 ` Hugh Dickins
2012-02-23 14:21 ` Konstantin Khlebnikov
2012-02-20 23:39 ` [PATCH 10/10] mm/memcg: per-memcg per-zone lru locking Hugh Dickins
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=alpine.LSU.2.00.1202201534340.23274@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=khlebnikov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=yinghan@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