All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Michal Hocko <mhocko@suse.cz>, Hugh Dickins <hughd@google.com>,
	David Rientjes <rientjes@google.com>,
	Wanpeng Li <liwp.linux@gmail.com>,
	linux-mm@kvack.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [patch 08/10] mm: memcg: split swapin charge function into private and public part
Date: Wed, 11 Jul 2012 19:02:20 +0200	[thread overview]
Message-ID: <1342026142-7284-9-git-send-email-hannes@cmpxchg.org> (raw)
In-Reply-To: <1342026142-7284-1-git-send-email-hannes@cmpxchg.org>

When shmem is charged upon swapin, it does not need to check twice
whether the memory controller is enabled.

Also, shmem pages do not have to be checked for everything that
regular anon pages have to be checked for, so let shmem use the
internal version directly and allow future patches to move around
checks that are only required when swapping in anon pages.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
---
 mm/memcontrol.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c6bcaaa..36e6d73 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2802,18 +2802,14 @@ int mem_cgroup_newpage_charge(struct page *page,
  * struct page_cgroup is acquired. This refcnt will be consumed by
  * "commit()" or removed by "cancel()"
  */
-int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
-				 struct page *page,
-				 gfp_t mask, struct mem_cgroup **memcgp)
+static int __mem_cgroup_try_charge_swapin(struct mm_struct *mm,
+					  struct page *page,
+					  gfp_t mask,
+					  struct mem_cgroup **memcgp)
 {
 	struct mem_cgroup *memcg;
 	int ret;
 
-	*memcgp = NULL;
-
-	if (mem_cgroup_disabled())
-		return 0;
-
 	if (!do_swap_account)
 		goto charge_cur_mm;
 	/*
@@ -2840,6 +2836,15 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
 	return ret;
 }
 
+int mem_cgroup_try_charge_swapin(struct mm_struct *mm, struct page *page,
+				 gfp_t gfp_mask, struct mem_cgroup **memcgp)
+{
+	*memcgp = NULL;
+	if (mem_cgroup_disabled())
+		return 0;
+	return __mem_cgroup_try_charge_swapin(mm, page, gfp_mask, memcgp);
+}
+
 void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg)
 {
 	if (mem_cgroup_disabled())
@@ -2901,7 +2906,8 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
 	if (!PageSwapCache(page))
 		ret = mem_cgroup_charge_common(page, mm, gfp_mask, type);
 	else { /* page is swapcache/shmem */
-		ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &memcg);
+		ret = __mem_cgroup_try_charge_swapin(mm, page,
+						     gfp_mask, &memcg);
 		if (!ret)
 			__mem_cgroup_commit_charge_swapin(page, memcg, type);
 	}
-- 
1.7.7.6


WARNING: multiple messages have this Message-ID (diff)
From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Michal Hocko <mhocko@suse.cz>, Hugh Dickins <hughd@google.com>,
	David Rientjes <rientjes@google.com>,
	Wanpeng Li <liwp.linux@gmail.com>,
	linux-mm@kvack.org, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [patch 08/10] mm: memcg: split swapin charge function into private and public part
Date: Wed, 11 Jul 2012 19:02:20 +0200	[thread overview]
Message-ID: <1342026142-7284-9-git-send-email-hannes@cmpxchg.org> (raw)
In-Reply-To: <1342026142-7284-1-git-send-email-hannes@cmpxchg.org>

When shmem is charged upon swapin, it does not need to check twice
whether the memory controller is enabled.

Also, shmem pages do not have to be checked for everything that
regular anon pages have to be checked for, so let shmem use the
internal version directly and allow future patches to move around
checks that are only required when swapping in anon pages.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
---
 mm/memcontrol.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c6bcaaa..36e6d73 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2802,18 +2802,14 @@ int mem_cgroup_newpage_charge(struct page *page,
  * struct page_cgroup is acquired. This refcnt will be consumed by
  * "commit()" or removed by "cancel()"
  */
-int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
-				 struct page *page,
-				 gfp_t mask, struct mem_cgroup **memcgp)
+static int __mem_cgroup_try_charge_swapin(struct mm_struct *mm,
+					  struct page *page,
+					  gfp_t mask,
+					  struct mem_cgroup **memcgp)
 {
 	struct mem_cgroup *memcg;
 	int ret;
 
-	*memcgp = NULL;
-
-	if (mem_cgroup_disabled())
-		return 0;
-
 	if (!do_swap_account)
 		goto charge_cur_mm;
 	/*
@@ -2840,6 +2836,15 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
 	return ret;
 }
 
+int mem_cgroup_try_charge_swapin(struct mm_struct *mm, struct page *page,
+				 gfp_t gfp_mask, struct mem_cgroup **memcgp)
+{
+	*memcgp = NULL;
+	if (mem_cgroup_disabled())
+		return 0;
+	return __mem_cgroup_try_charge_swapin(mm, page, gfp_mask, memcgp);
+}
+
 void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg)
 {
 	if (mem_cgroup_disabled())
@@ -2901,7 +2906,8 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
 	if (!PageSwapCache(page))
 		ret = mem_cgroup_charge_common(page, mm, gfp_mask, type);
 	else { /* page is swapcache/shmem */
-		ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &memcg);
+		ret = __mem_cgroup_try_charge_swapin(mm, page,
+						     gfp_mask, &memcg);
 		if (!ret)
 			__mem_cgroup_commit_charge_swapin(page, memcg, type);
 	}
-- 
1.7.7.6

--
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>

  parent reply	other threads:[~2012-07-11 17:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 17:02 [patch 00/10] mm: memcg: charge/uncharge improvements v2 Johannes Weiner
2012-07-11 17:02 ` Johannes Weiner
2012-07-11 17:02 ` Johannes Weiner
2012-07-11 17:02 ` [patch 01/10] mm: memcg: fix compaction/migration failing due to memcg limits Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-12  8:54   ` Wanpeng Li
2012-07-12  8:54     ` Wanpeng Li
2012-07-12  9:10     ` Wanpeng Li
2012-07-12  9:10       ` Wanpeng Li
2012-07-12  9:42       ` Johannes Weiner
2012-07-12  9:42         ` Johannes Weiner
2012-07-12  9:12     ` Johannes Weiner
2012-07-12  9:12       ` Johannes Weiner
2012-07-11 17:02 ` [patch 02/10] mm: swapfile: clean up unuse_pte race handling Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` [patch 03/10] mm: memcg: push down PageSwapCache check into uncharge entry functions Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-19  9:57   ` Kamezawa Hiroyuki
2012-07-19  9:57     ` Kamezawa Hiroyuki
2012-07-19  9:57     ` Kamezawa Hiroyuki
2012-07-11 17:02 ` [patch 04/10] mm: memcg: only check for PageSwapCache when uncharging anon Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` [patch 05/10] mm: memcg: move swapin charge functions above callsites Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` [patch 06/10] mm: memcg: remove unneeded shmem charge type Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` [patch 07/10] mm: memcg: remove needless !mm fixup to init_mm when charging Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` Johannes Weiner [this message]
2012-07-11 17:02   ` [patch 08/10] mm: memcg: split swapin charge function into private and public part Johannes Weiner
2012-07-11 17:02 ` [patch 09/10] mm: memcg: only check swap cache pages for repeated charging Johannes Weiner
2012-07-11 17:02   ` Johannes Weiner
2012-07-11 17:02 ` [patch 10/10] mm: memcg: only check anon swapin page charges for swap cache Johannes Weiner
2012-07-11 17:02   ` 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=1342026142-7284-9-git-send-email-hannes@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hughd@google.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liwp.linux@gmail.com \
    --cc=mhocko@suse.cz \
    --cc=rientjes@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.