Thread (21 messages) 21 messages, 5 authors, 2012-03-23

Re: [RFC][PATCH 2/3] memcg: reduce size of struct page_cgroup.

From: Suleiman Souhlal <hidden>
Date: 2012-03-19 22:21:00
Also in: linux-mm

2012/3/19 KAMEZAWA Hiroyuki [off-list ref]:
quoted hunk ↗ jump to hunk
Now, page_cgroup->flags has only 3bits. Considering alignment of
struct mem_cgroup, which is allocated by kmalloc(), we can encode
pointer to mem_cgroup and flags into a word.

After this patch, pc->flags is encoded as

 63                           2     0
 | pointer to memcg..........|flags|

Signed-off-by: KAMEZAWA Hiroyuki <redacted>
---
 include/linux/page_cgroup.h |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
index 92768cb..bca5447 100644
--- a/include/linux/page_cgroup.h
+++ b/include/linux/page_cgroup.h
@@ -1,6 +1,10 @@
 #ifndef __LINUX_PAGE_CGROUP_H
 #define __LINUX_PAGE_CGROUP_H

+/*
+ * Because these flags are encoded into ->flags with a pointer,
+ * we cannot have too much flags.
+ */
 enum {
       /* flags for mem_cgroup */
       PCG_LOCK,  /* Lock for pc->mem_cgroup and following bits. */
@@ -9,6 +13,8 @@ enum {
       __NR_PCG_FLAGS,
 };

+#define PCG_FLAGS_MASK ((1 << __NR_PCG_FLAGS) - 1)
+
 #ifndef __GENERATING_BOUNDS_H
 #include <generated/bounds.h>
@@ -21,10 +27,12 @@ enum {
 * page_cgroup helps us identify information about the cgroup
 * All page cgroups are allocated at boot or memory hotplug event,
 * then the page cgroup for pfn always exists.
+ *
+ * flags and a pointer to memory cgroup are encoded into ->flags.
+ * Lower 3bits are used for flags and others are used for a pointer to memcg.
Would it be worth adding a BUILD_BUG_ON(__NR_PCG_FLAGS > 3) ?

-- Suleiman

--
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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help