linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH mmotm] memcg: unmap KM_USER0 at shmem_map_and_free_swp if do_swap_account
@ 2008-11-18  9:07 Daisuke Nishimura
  2008-11-18  9:26 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 13+ messages in thread
From: Daisuke Nishimura @ 2008-11-18  9:07 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, KAMEZAWA Hiroyuki, Balbir Singh, Pavel Emelianov,
	Hugh Dickins, Li Zefan, nishimura

memswap controller uses KM_USER0 at swap_cgroup_record and lookup_swap_cgroup.

But delete_from_swap_cache, which eventually calls swap_cgroup_record, can be
called with KM_USER0 mapped in case of shmem.

So it should be unmapped before calling it.

Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
---
After this patch, I think memswap controller of x86_32 will be
on the same level with that of x86_64.

 mm/shmem.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index bee8612..7aebc1b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -171,6 +171,28 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
 		vm_unacct_memory(VM_ACCT(size));
 }
 
+#if defined(CONFIG_CGROUP_MEM_RES_CTLR_SWAP) && defined(CONFIG_HIGHMEM)
+/*
+ * memswap controller uses KM_USER0, so dir should be unmapped
+ * before calling delete_from_swap_cache.
+ */
+static inline void swap_cgroup_map_prepare(struct page ***dir)
+{
+	if (!do_swap_account)
+		return;
+
+	if (*dir) {
+		shmem_dir_unmap(*dir);
+		*dir = NULL;
+	}
+}
+#else
+static inline void swap_cgroup_map_prepare(struct page ***dir)
+{
+	return;
+}
+#endif
+
 /*
  * ... whereas tmpfs objects are accounted incrementally as
  * pages are allocated, in order to allow huge sparse files.
@@ -479,6 +501,7 @@ static int shmem_map_and_free_swp(struct page *subdir, int offset,
 		int size = limit - offset;
 		if (size > LATENCY_LIMIT)
 			size = LATENCY_LIMIT;
+		swap_cgroup_map_prepare(dir);
 		freed += shmem_free_swp(ptr+offset, ptr+offset+size,
 							punch_lock);
 		if (need_resched()) {

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-11-21  9:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-18  9:07 [PATCH mmotm] memcg: unmap KM_USER0 at shmem_map_and_free_swp if do_swap_account Daisuke Nishimura
2008-11-18  9:26 ` KAMEZAWA Hiroyuki
2008-11-18 10:21   ` Daisuke Nishimura
2008-11-18 12:08     ` Daisuke Nishimura
2008-11-18 12:48       ` Hugh Dickins
2008-11-18 15:17         ` Daisuke Nishimura
2008-11-18 16:12           ` [PATCH mmotm] memcg: avoid using buggy kmap at swap_cgroup KAMEZAWA Hiroyuki
2008-11-18 16:40             ` Hugh Dickins
2008-11-18 16:56               ` Hugh Dickins
2008-11-19 12:44                 ` KAMEZAWA Hiroyuki
2008-11-21  5:54                   ` [PATCH] memcg-swap-cgroup-for-remembering-usage-v2.patch KAMEZAWA Hiroyuki
2008-11-21  6:16                     ` Daisuke Nishimura
2008-11-21  9:42                     ` Daisuke Nishimura

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox