[RFC] Restrict size of page_cgroup->flags

From: Balbir Singh
Date: Wed Oct 06 2010 - 10:23:33 EST


I propose restricting page_cgroup.flags to 16 bits. The patch for the
same is below. Comments?


Restrict the bits usage in page_cgroup.flags

From: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx>

Restricting the flags helps control growth of the flags unbound.
Restriciting it to 16 bits gives us the possibility of merging
cgroup id with flags (atomicity permitting) and saving a whole
long word in page_cgroup

Signed-off-by: Balbir Singh <balbir@xxxxxxxxxxxxxxxxxx>
---

include/linux/page_cgroup.h | 3 +++
mm/page_cgroup.c | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)


diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
index 872f6b1..10c37b4 100644
--- a/include/linux/page_cgroup.h
+++ b/include/linux/page_cgroup.h
@@ -44,8 +44,11 @@ enum {
PCG_FILE_WRITEBACK, /* page is under writeback */
PCG_FILE_UNSTABLE_NFS, /* page is NFS unstable */
PCG_MIGRATION, /* under page migration */
+ PCG_MAX_NR,
};

+#define PCG_MAX_BIT_SIZE 16
+
#define TESTPCGFLAG(uname, lname) \
static inline int PageCgroup##uname(struct page_cgroup *pc) \
{ return test_bit(PCG_##lname, &pc->flags); }
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 5bffada..e16ad2e 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -258,6 +258,7 @@ void __init page_cgroup_init(void)
unsigned long pfn;
int fail = 0;

+ BUILD_BUG_ON(PCG_MAX_NR >= PCG_MAX_BIT_SIZE);
if (mem_cgroup_disabled())
return;


--
Three Cheers,
Balbir
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/