From: Hugh Dickins <hugh@veritas.com>
To: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Hirokazu Takahashi <taka@valinux.co.jp>,
YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
linux-mm@kvack.org
Subject: [PATCH 08/15] memcg: remove mem_cgroup_uncharge
Date: Mon, 25 Feb 2008 23:42:05 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.64.0802252341250.27067@blonde.site> (raw)
In-Reply-To: <Pine.LNX.4.64.0802252327490.27067@blonde.site>
Nothing uses mem_cgroup_uncharge apart from mem_cgroup_uncharge_page,
(a trivial wrapper around it) and mem_cgroup_end_migration (which does
the same as mem_cgroup_uncharge_page). And it often ends up having to
lock just to let its caller unlock. Remove it (but leave the silly
locking until a later patch).
Moved mem_cgroup_cache_charge next to mem_cgroup_charge in memcontrol.h.
Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
I'd happily rename mem_cgroup_uncharge_page to mem_cgroup_uncharge later,
matching mem_cgroup_charge: that patch would touch more, what do you think?
include/linux/memcontrol.h | 20 +++++++-------------
mm/memcontrol.c | 23 ++++++++---------------
2 files changed, 15 insertions(+), 28 deletions(-)
--- memcg07/include/linux/memcontrol.h 2008-02-25 14:05:55.000000000 +0000
+++ memcg08/include/linux/memcontrol.h 2008-02-25 14:06:02.000000000 +0000
@@ -35,7 +35,8 @@ extern void mm_free_cgroup(struct mm_str
extern struct page_cgroup *page_get_page_cgroup(struct page *page);
extern int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
gfp_t gfp_mask);
-extern void mem_cgroup_uncharge(struct page_cgroup *pc);
+extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
+ gfp_t gfp_mask);
extern void mem_cgroup_uncharge_page(struct page *page);
extern void mem_cgroup_move_lists(struct page *page, bool active);
extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
@@ -45,8 +46,6 @@ extern unsigned long mem_cgroup_isolate_
struct mem_cgroup *mem_cont,
int active);
extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
-extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
- gfp_t gfp_mask);
int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
#define mm_match_cgroup(mm, cgroup) \
@@ -92,14 +91,16 @@ static inline struct page_cgroup *page_g
return NULL;
}
-static inline int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
- gfp_t gfp_mask)
+static inline int mem_cgroup_charge(struct page *page,
+ struct mm_struct *mm, gfp_t gfp_mask)
{
return 0;
}
-static inline void mem_cgroup_uncharge(struct page_cgroup *pc)
+static inline int mem_cgroup_cache_charge(struct page *page,
+ struct mm_struct *mm, gfp_t gfp_mask)
{
+ return 0;
}
static inline void mem_cgroup_uncharge_page(struct page *page)
@@ -110,13 +111,6 @@ static inline void mem_cgroup_move_lists
{
}
-static inline int mem_cgroup_cache_charge(struct page *page,
- struct mm_struct *mm,
- gfp_t gfp_mask)
-{
- return 0;
-}
-
static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
{
return 1;
--- memcg07/mm/memcontrol.c 2008-02-25 14:05:58.000000000 +0000
+++ memcg08/mm/memcontrol.c 2008-02-25 14:06:02.000000000 +0000
@@ -697,20 +697,22 @@ int mem_cgroup_cache_charge(struct page
/*
* Uncharging is always a welcome operation, we never complain, simply
- * uncharge. This routine should be called with lock_page_cgroup held
+ * uncharge.
*/
-void mem_cgroup_uncharge(struct page_cgroup *pc)
+void mem_cgroup_uncharge_page(struct page *page)
{
+ struct page_cgroup *pc;
struct mem_cgroup *mem;
struct mem_cgroup_per_zone *mz;
- struct page *page;
unsigned long flags;
/*
* Check if our page_cgroup is valid
*/
+ lock_page_cgroup(page);
+ pc = page_get_page_cgroup(page);
if (!pc)
- return;
+ goto unlock;
if (atomic_dec_and_test(&pc->ref_cnt)) {
page = pc->page;
@@ -731,12 +733,8 @@ void mem_cgroup_uncharge(struct page_cgr
}
lock_page_cgroup(page);
}
-}
-void mem_cgroup_uncharge_page(struct page *page)
-{
- lock_page_cgroup(page);
- mem_cgroup_uncharge(page_get_page_cgroup(page));
+unlock:
unlock_page_cgroup(page);
}
@@ -759,12 +757,7 @@ int mem_cgroup_prepare_migration(struct
void mem_cgroup_end_migration(struct page *page)
{
- struct page_cgroup *pc;
-
- lock_page_cgroup(page);
- pc = page_get_page_cgroup(page);
- mem_cgroup_uncharge(pc);
- unlock_page_cgroup(page);
+ mem_cgroup_uncharge_page(page);
}
/*
* We know both *page* and *newpage* are now not-on-LRU and Pg_locked.
--
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:[~2008-02-25 23:42 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-25 23:34 [PATCH 00/15] memcg: fixes and cleanups Hugh Dickins
2008-02-25 23:35 ` [PATCH 01/15] memcg: mm_match_cgroup not vm_match_cgroup Hugh Dickins
2008-02-26 0:39 ` David Rientjes
2008-02-26 3:27 ` Hugh Dickins
2008-02-26 2:41 ` Balbir Singh
2008-02-26 23:46 ` KAMEZAWA Hiroyuki
2008-02-28 3:47 ` Andrew Morton
2008-02-28 7:19 ` David Rientjes
2008-02-28 7:26 ` Andrew Morton
2008-02-28 8:08 ` Hugh Dickins
2008-02-25 23:36 ` [PATCH 02/15] memcg: move_lists on page not page_cgroup Hugh Dickins
2008-02-26 15:52 ` Balbir Singh
2008-02-26 23:45 ` KAMEZAWA Hiroyuki
2008-02-25 23:37 ` [PATCH 03/15] memcg: page_cache_release not __free_page Hugh Dickins
2008-02-26 16:02 ` Balbir Singh
2008-02-26 23:38 ` KAMEZAWA Hiroyuki
2008-02-25 23:38 ` [PATCH 04/15] memcg: when do_swap's do_wp_page fails Hugh Dickins
2008-02-26 23:41 ` KAMEZAWA Hiroyuki
2008-02-27 5:08 ` Balbir Singh
2008-02-27 12:57 ` Hugh Dickins
2008-02-25 23:39 ` [PATCH 05/15] memcg: fix VM_BUG_ON from page migration Hugh Dickins
2008-02-26 1:30 ` KAMEZAWA Hiroyuki
2008-02-27 5:52 ` Balbir Singh
2008-02-27 13:23 ` Hugh Dickins
2008-02-27 13:43 ` Balbir Singh
2008-02-25 23:40 ` [PATCH 06/15] memcg: bad page if page_cgroup when free Hugh Dickins
2008-02-26 23:44 ` KAMEZAWA Hiroyuki
2008-02-27 8:38 ` Balbir Singh
2008-02-25 23:41 ` [PATCH 07/15] memcg: mem_cgroup_charge never NULL Hugh Dickins
2008-02-26 1:32 ` KAMEZAWA Hiroyuki
2008-02-27 8:42 ` Balbir Singh
2008-02-25 23:42 ` Hugh Dickins [this message]
2008-02-26 1:34 ` [PATCH 08/15] memcg: remove mem_cgroup_uncharge KAMEZAWA Hiroyuki
2008-02-28 18:22 ` Balbir Singh
2008-02-25 23:43 ` [PATCH 09/15] memcg: memcontrol whitespace cleanups Hugh Dickins
2008-02-25 23:44 ` [PATCH 10/15] memcg: memcontrol uninlined and static Hugh Dickins
2008-02-26 1:36 ` KAMEZAWA Hiroyuki
2008-02-25 23:46 ` [PATCH 11/15] memcg: remove clear_page_cgroup and atomics Hugh Dickins
2008-02-26 1:38 ` KAMEZAWA Hiroyuki
2008-02-25 23:47 ` [PATCH 12/15] memcg: css_put after remove_list Hugh Dickins
2008-02-26 1:39 ` KAMEZAWA Hiroyuki
2008-02-25 23:49 ` [PATCH 13/15] memcg: fix mem_cgroup_move_lists locking Hugh Dickins
2008-02-26 1:43 ` KAMEZAWA Hiroyuki
2008-02-26 2:56 ` Hugh Dickins
2008-02-25 23:50 ` [PATCH 14/15] memcg: simplify force_empty and move_lists Hugh Dickins, Hirokazu Takahashi
2008-02-26 1:48 ` KAMEZAWA Hiroyuki
2008-02-26 3:23 ` Hugh Dickins
2008-02-26 4:09 ` KAMEZAWA Hiroyuki
2008-02-25 23:51 ` [PATCH 15/15] memcg: fix oops on NULL lru list Hugh Dickins
2008-02-26 1:26 ` [PATCH 00/15] memcg: fixes and cleanups KAMEZAWA Hiroyuki
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=Pine.LNX.4.64.0802252341250.27067@blonde.site \
--to=hugh@veritas.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=taka@valinux.co.jp \
--cc=yamamoto@valinux.co.jp \
/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;
as well as URLs for NNTP newsgroup(s).