From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>, Ying Han <yinghan@google.com>
Subject: [PATCH 1/4] memcg: simplify page cache charging.
Date: Wed, 14 Dec 2011 16:49:22 +0900 [thread overview]
Message-ID: <20111214164922.05fb4afe.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20111214164734.4d7d6d97.kamezawa.hiroyu@jp.fujitsu.com>
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
This patch is a clean up. No functional/logical changes.
Because of commit ef6a3c6311, FUSE uses replace_page_cache() instead
of add_to_page_cache(). Then, mem_cgroup_cache_charge() is not
called against FUSE's pages from splice.
So, Now, mem_cgroup_cache_charge() doesn't receive a page on LRU
unless it's not SwapCache.
For checking, WARN_ON_ONCE(PageLRU(page)) is added.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
mm/memcontrol.c | 31 +++++++++----------------------
1 files changed, 9 insertions(+), 22 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a9e92a6..947c62c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2710,6 +2710,7 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask)
{
struct mem_cgroup *memcg = NULL;
+ enum charge_type type = MEM_CGROUP_CHARGE_TYPE_CACHE;
int ret;
if (mem_cgroup_disabled())
@@ -2719,31 +2720,17 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
if (unlikely(!mm))
mm = &init_mm;
+ if (!page_is_file_cache(page))
+ type = MEM_CGROUP_CHARGE_TYPE_SHMEM;
- if (page_is_file_cache(page)) {
- ret = __mem_cgroup_try_charge(mm, gfp_mask, 1, &memcg, true);
- if (ret || !memcg)
- return ret;
-
- /*
- * FUSE reuses pages without going through the final
- * put that would remove them from the LRU list, make
- * sure that they get relinked properly.
- */
- __mem_cgroup_commit_charge_lrucare(page, memcg,
- MEM_CGROUP_CHARGE_TYPE_CACHE);
- return ret;
- }
- /* shmem */
- if (PageSwapCache(page)) {
+ if (!PageSwapCache(page)) {
+ ret = mem_cgroup_charge_common(page, mm, gfp_mask, type);
+ WARN_ON_ONCE(PageLRU(page));
+ } else { /* page is swapcache/shmem */
ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &memcg);
if (!ret)
- __mem_cgroup_commit_charge_swapin(page, memcg,
- MEM_CGROUP_CHARGE_TYPE_SHMEM);
- } else
- ret = mem_cgroup_charge_common(page, mm, gfp_mask,
- MEM_CGROUP_CHARGE_TYPE_SHMEM);
-
+ __mem_cgroup_commit_charge_swapin(page, memcg, type);
+ }
return ret;
}
--
1.7.4.1
--
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:[~2011-12-14 7:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 7:47 [PATCH 0/4] memcg: simplify LRU handling KAMEZAWA Hiroyuki
2011-12-14 7:49 ` KAMEZAWA Hiroyuki [this message]
2011-12-16 22:28 ` [PATCH 1/4] memcg: simplify page cache charging Andrew Morton
2011-12-19 0:01 ` KAMEZAWA Hiroyuki
2011-12-20 21:58 ` Andrew Morton
2011-12-21 0:01 ` KAMEZAWA Hiroyuki
2011-12-19 15:04 ` Johannes Weiner
2011-12-20 15:33 ` Michal Hocko
2011-12-14 7:50 ` [PATCH 2/4] memcg: simplify corner case handling of LRU KAMEZAWA Hiroyuki
2011-12-19 15:14 ` Johannes Weiner
2011-12-20 15:05 ` Michal Hocko
2011-12-14 7:51 ` [PATCH 3/4] memcg: clear pc->mem_cgorup if necessary KAMEZAWA Hiroyuki
2011-12-16 22:30 ` Andrew Morton
2011-12-19 15:37 ` Johannes Weiner
2011-12-20 0:35 ` Hiroyuki Kamezawa
2011-12-20 15:56 ` Michal Hocko
2011-12-14 7:52 ` [PATCH 4/4] memcg: simplify LRU handling by new rule KAMEZAWA Hiroyuki
2011-12-19 15:48 ` Johannes Weiner
2011-12-20 16:16 ` Michal Hocko
2011-12-21 0:09 ` KAMEZAWA Hiroyuki
2011-12-21 6:56 ` Michal Hocko
2011-12-19 15:56 ` [PATCH 0/4] memcg: simplify LRU handling Johannes Weiner
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=20111214164922.05fb4afe.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--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