Skip to contentSkip to conversation

memcg: renaming of mem variable to memcg

PATCH In review Raghavendra K T 3 participants 3 messages Aug 12, 2011 – Aug 19, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 memcg: renaming of mem variable to memcg

The memcg code sometimes uses "struct mem_cgroup *mem" and sometimes uses "struct mem_cgroup *memcg". This patch renames all mem variables to memcg in source file.

Testing : Compile tested with following configurations.
1) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y

Binary size Before patch
========================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

Binary Size After patch
=======================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

2) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

3) make defconfig ARCH=i386 CONFIG_CGROUP_MEM_RES_CTLR=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

Other sanity check:
Bootable configuration on x86 (T60p) with CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y is tesed with basic mounting of memcgroup, creation of child and parallel fault. mkdir -p /cgroup
mount -t cgroup none /cgroup -o memory
mkdir /cgroup/0
echo $$ > /cgroup/0/tasks
time ./parallel_fault 2 100000 32

real 0m0.025s
user 0m0.001s
sys 0m0.033s

From: Raghavendra K T <[email protected]>

---
Reference to previous posting :
https://lkml.org/lkml/2011/8/10/363

include/linux/memcontrol.h +18 -16
index 5633f51..fb1ed1c 100644
@@ -88,8 +88,8 @@ extern void mem_cgroup_uncharge_end(void);
 extern void mem_cgroup_uncharge_page(struct page *page);
 extern void mem_cgroup_uncharge_cache_page(struct page *page);
 
-extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
-int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
+extern void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask);
+int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg);
 
 extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
@@ -98,19 +98,19 @@ extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
 static inline
 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
 {
-	struct mem_cgroup *mem;
+	struct mem_cgroup *memcg;
 	rcu_read_lock();
-	mem = mem_cgroup_from_task(rcu_dereference((mm)->owner));
+	memcg = mem_cgroup_from_task(rcu_dereference((mm)->owner));
 	rcu_read_unlock();
-	return cgroup == mem;
+	return cgroup == memcg;
 }
 
-extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem);
+extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg);
 
 extern int
 mem_cgroup_prepare_migration(struct page *page,
 	struct page *newpage, struct mem_cgroup **ptr, gfp_t gfp_mask);
-extern void mem_cgroup_end_migration(struct mem_cgroup *mem,
+extern void mem_cgroup_end_migration(struct mem_cgroup *memcg,
 	struct page *oldpage, struct page *newpage, bool migration_ok);
 
 /*
@@ -167,7 +167,7 @@ static inline void mem_cgroup_dec_page_stat(struct page *page,
 unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 						gfp_t gfp_mask,
 						unsigned long *total_scanned);
-u64 mem_cgroup_get_limit(struct mem_cgroup *mem);
+u64 mem_cgroup_get_limit(struct mem_cgroup *memcg);
 
 void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx);
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -263,18 +263,20 @@ static inline struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm
 	return NULL;
 }
 
-static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
+static inline int mm_match_cgroup(struct mm_struct *mm,
+		struct mem_cgroup *memcg)
 {
 	return 1;
 }
 
 static inline int task_in_mem_cgroup(struct task_struct *task,
-				     const struct mem_cgroup *mem)
+				     const struct mem_cgroup *memcg)
 {
 	return 1;
 }
 
-static inline struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem)
+static inline struct cgroup_subsys_state
+		*mem_cgroup_css(struct mem_cgroup *memcg)
 {
 	return NULL;
 }
@@ -286,22 +288,22 @@ mem_cgroup_prepare_migration(struct page *page, struct page *newpage,
 	return 0;
 }
 
-static inline void mem_cgroup_end_migration(struct mem_cgroup *mem,
+static inline void mem_cgroup_end_migration(struct mem_cgroup *memcg,
 		struct page *oldpage, struct page *newpage, bool migration_ok)
 {
 }
 
-static inline int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem)
+static inline int mem_cgroup_get_reclaim_priority(struct mem_cgroup *memcg)
 {
 	return 0;
 }
 
-static inline void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem,
+static inline void mem_cgroup_note_reclaim_priority(struct mem_cgroup *memcg,
 						int priority)
 {
 }
 
-static inline void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem,
+static inline void mem_cgroup_record_reclaim_priority(struct mem_cgroup *memcg,
 						int priority)
 {
 }
@@ -367,7 +369,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
 }
 
 static inline
-u64 mem_cgroup_get_limit(struct mem_cgroup *mem)
+u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
 {
 	return 0;
 }
mm/memcontrol.c +486 -479

2,387 lines not on this page · raw message

#1 lore raw

Sorry for late reply

Quoted 13 lines · Raghavendra K T

The memcg code sometimes uses "struct mem_cgroup *mem" and sometimes uses "struct mem_cgroup *memcg". This patch renames all mem variables to memcg in source file.

Testing : Compile tested with following configurations.
1) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y

Binary size Before patch
========================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

Quoted 4 lines

Binary Size After patch
=======================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

It would be much nicer to see unchanged md5sum. I am not sure how much possible is this with current gcc or whether special command line parameters have to be used (at least !CONFIG_DEBUG_INFO* is necessary) but simple variable rename shouldn't be binary visible.
I guess that a similar approach was used during 32b and 64b x86 unification.

Quoted 3 lines

2) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

I would assume the same testing results as above

Quoted 3 lines

3) make defconfig ARCH=i386 CONFIG_CGROUP_MEM_RES_CTLR=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

ditto.

Quoted 11 lines

Other sanity check:
Bootable configuration on x86 (T60p) with CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y is tesed with basic mounting of memcgroup, creation of child and parallel fault. mkdir -p /cgroup
mount -t cgroup none /cgroup -o memory
mkdir /cgroup/0
echo $$ > /cgroup/0/tasks
time ./parallel_fault 2 100000 32

Quoted 3 lines

real 0m0.025s
user 0m0.001s
sys 0m0.033s

This looks like a random test. I wouldn't add it to the changelog.

Signature · 6 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic
#2 lore raw
Quoted 21 lines · Michal Hocko

Sorry for late reply

Quoted 13 lines · Raghavendra K T

The memcg code sometimes uses "struct mem_cgroup *mem" and sometimes uses "struct mem_cgroup *memcg". This patch renames all mem variables to memcg in source file.

Testing : Compile tested with following configurations.
1) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y

Binary size Before patch
========================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

Quoted 4 lines

Binary Size After patch
=======================
text data bss dec hex filename
8911169 520464 1884160 11315793 acaa51 vmlinux

Quoted 7 lines

It would be much nicer to see unchanged md5sum. I am not sure how much possible is this with current gcc or whether special command line parameters have to be used (at least !CONFIG_DEBUG_INFO* is necessary) but simple variable rename shouldn't be binary visible.
I guess that a similar approach was used during 32b and 64b x86 unification.

I agree, I could get same MD5 sum only in N N N config case (3rd config).
I am not sure whether we can get same Md5 after lines have been split.
Here is what I tried: static KBUILD_BUILD_TIMESTAMP KBUILD_BUILD_VERSION, initramfs source. strip vmlinux. (could not disable CONFIG_BUG). I referred to 32nb 64b unification also, did not get much insight from there on same MD5.

Quoted 5 lines
Quoted 3 lines

2) make defconfig ARCH=i386 + CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

I would assume the same testing results as above

Yes
8908671 519808 1884160 11312639 ac9dff vmlinux

Quoted 6 lines
Quoted 4 lines

3) make defconfig ARCH=i386 CONFIG_CGROUP_MEM_RES_CTLR=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP=n CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=n

ditto.

8878794 517632 1880064 11276490 ac10ca vmlinux before and after

Quoted 12 lines
Quoted 12 lines

Other sanity check:
Bootable configuration on x86 (T60p) with CONFIG_CGROUP_MEM_RES_CTLR=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y is tesed with basic mounting of memcgroup, creation of child and parallel fault. mkdir -p /cgroup
mount -t cgroup none /cgroup -o memory
mkdir /cgroup/0
echo $$> /cgroup/0/tasks
time ./parallel_fault 2 100000 32

Quoted 5 lines
Quoted 3 lines

real 0m0.025s
user 0m0.001s
sys 0m0.033s

This looks like a random test. I wouldn't add it to the changelog.

Agree.