Skip to contentSkip to conversation

memcg: drop type MEM_CGROUP_CHARGE_TYPE_DROP

PATCH NAK Bob Liu 3 participants 6 messages Dec 7, 2011 – Dec 8, 2011

Subsystems (2)
lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH 1/1 memcg: drop type MEM_CGROUP_CHARGE_TYPE_DROP

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

---
 mm/memcontrol.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
mm/memcontrol.c +0 -5
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {
 	MEM_CGROUP_CHARGE_TYPE_SHMEM,	/* used by page migration of shmem */
 	MEM_CGROUP_CHARGE_TYPE_FORCE,	/* used by force_empty */
 	MEM_CGROUP_CHARGE_TYPE_SWAPOUT,	/* for accounting swapcache */
-	MEM_CGROUP_CHARGE_TYPE_DROP,	/* a page was unused swap cache */
 	NR_CHARGE_TYPE,
 };
 
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
 	switch (ctype) {
 	case MEM_CGROUP_CHARGE_TYPE_MAPPED:
-	case MEM_CGROUP_CHARGE_TYPE_DROP:
 		/* See mem_cgroup_prepare_migration() */
 		if (page_mapped(page) || PageCgroupMigration(pc))
 			goto unlock_out;
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
 	struct mem_cgroup *memcg;
 	int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
-	if (!swapout) /* this was a swap cache but the swap is unused ! */
-		ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-
 	memcg = __mem_cgroup_uncharge_common(page, ctype);
 
 	/*
Signature · 9 lines
1.7.0.4


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  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:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 5 lines · On Wed, 7 Dec 2011 18:30:46 +0800 Bob Liu <[email protected]> wrote:

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

I think you didn't test at all.

Quoted 25 lines
---
 mm/memcontrol.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
mm/memcontrol.c +0 -2
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {
 	MEM_CGROUP_CHARGE_TYPE_SHMEM,	/* used by page migration of shmem */
 	MEM_CGROUP_CHARGE_TYPE_FORCE,	/* used by force_empty */
 	MEM_CGROUP_CHARGE_TYPE_SWAPOUT,	/* for accounting swapcache */
-	MEM_CGROUP_CHARGE_TYPE_DROP,	/* a page was unused swap cache */
 	NR_CHARGE_TYPE,
 };
 
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
 	switch (ctype) {
 	case MEM_CGROUP_CHARGE_TYPE_MAPPED:
-	case MEM_CGROUP_CHARGE_TYPE_DROP:
 		/* See mem_cgroup_prepare_migration() */
 		if (page_mapped(page) || PageCgroupMigration(pc))
 			goto unlock_out;

mm/memcontrol.c mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) · line 3126

Quoted 6 lines
mm/memcontrol.c +0 -3
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
 	struct mem_cgroup *memcg;
 	int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
-	if (!swapout) /* this was a swap cache but the swap is unused ! */
-		ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-

Then, here , what ctype must be if !swapout ?

Nack.

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 39 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · On Wed, 7 Dec 2011 18:30:46 +0800 Bob Liu <[email protected]> wrote:

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

I think you didn't test at all.

Quoted 28 lines

---
 mm/memcontrol.c |    5 -----

 1 files changed, 0 insertions(+), 5 deletions(-)
mm/memcontrol.c +0 -0
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {

      MEM_CGROUP_CHARGE_TYPE_SHMEM,   /* used by page migration of shmem */ MEM_CGROUP_CHARGE_TYPE_FORCE,   /* used by force_empty */ MEM_CGROUP_CHARGE_TYPE_SWAPOUT, /* for accounting swapcache */
-     MEM_CGROUP_CHARGE_TYPE_DROP,    /* a page was unused swap cache */ NR_CHARGE_TYPE,
 };

mm/memcontrol.c +0 -0
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
       switch (ctype) {

      case MEM_CGROUP_CHARGE_TYPE_MAPPED:
-     case MEM_CGROUP_CHARGE_TYPE_DROP:
              /* See mem_cgroup_prepare_migration() */ if (page_mapped(page) || PageCgroupMigration(pc)) goto unlock_out;

mm/memcontrol.c +0 -0
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
       struct mem_cgroup *memcg;
       int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
Quoted 6 lines

mm/memcontrol.c mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) · line 3126

Quoted 3 lines
mm/memcontrol.c +0 -3
-     if (!swapout) /* this was a swap cache but the swap is unused ! */
-             ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-

Then, here , what ctype must be if !swapout ?

I think MEM_CGROUP_CHARGE_TYPE_SWAPOUT is okay, i didn't get the point that the benefit of using MEM_CGROUP_CHARGE_TYPE_DROP.

If use MEM_CGROUP_CHARGE_TYPE_SWAPOUT, page_mapped(page) also checked in __mem_cgroup_uncharge_common().

Maybe i missed something. Thanks.

3003 case MEM_CGROUP_CHARGE_TYPE_DROP:
3004 /* See mem_cgroup_prepare_migration() */
3005 if (page_mapped(page) || PageCgroupMigration(pc))
3006 goto unlock_out;
3007 break;
3008 case MEM_CGROUP_CHARGE_TYPE_SWAPOUT:
3009 if (!PageAnon(page)) { /* Shared memory */
3010 if (page->mapping && !page_is_file_cache(page))
3011 goto unlock_out;
3012 } else if (page_mapped(page)) /* Anon */
3013 goto unlock_out;
3014 break;

Quoted 5 lines

Nack.

Thanks,
-Kame

Signature · 9 lines
Regards,
--Bob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  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:"[email protected]"> [email protected] </a>
#5 lore raw
In reply to Bob Liu
Quoted 30 lines · Bob Liu

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

---
 mm/memcontrol.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
mm/memcontrol.c +0 -2
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {
 	MEM_CGROUP_CHARGE_TYPE_SHMEM,	/* used by page migration of shmem */
 	MEM_CGROUP_CHARGE_TYPE_FORCE,	/* used by force_empty */
 	MEM_CGROUP_CHARGE_TYPE_SWAPOUT,	/* for accounting swapcache */
-	MEM_CGROUP_CHARGE_TYPE_DROP,	/* a page was unused swap cache */
 	NR_CHARGE_TYPE,
 };
 
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
 	switch (ctype) {
 	case MEM_CGROUP_CHARGE_TYPE_MAPPED:
-	case MEM_CGROUP_CHARGE_TYPE_DROP:
 		/* See mem_cgroup_prepare_migration() */
 		if (page_mapped(page) || PageCgroupMigration(pc))
 			goto unlock_out;

mm/memcontrol.c mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) · line 3126

Quoted 6 lines
mm/memcontrol.c +0 -3
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
 	struct mem_cgroup *memcg;
 	int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
-	if (!swapout) /* this was a swap cache but the swap is unused ! */
-		ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-

Pages are in swap cache for swapping in as well as for swapping out. When a page is removed from swap cache and memory, the accounting needs to know about the direction. See the other checks against TYPE_SWAPOUT.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>

#3 lore raw
In reply to Bob Liu
Quoted 48 lines · On Wed, 7 Dec 2011 20:29:24 +0800 Bob Liu <[email protected]> wrote:
Quoted 39 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · On Wed, 7 Dec 2011 18:30:46 +0800 Bob Liu <[email protected]> wrote:

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

I think you didn't test at all.

Quoted 28 lines

---
A mm/memcontrol.c | A A 5 -----
A 1 files changed, 0 insertions(+), 5 deletions(-)

mm/memcontrol.c +0 -0
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {
A  A  A  MEM_CGROUP_CHARGE_TYPE_SHMEM, A  /* used by page migration of shmem */
A  A  A  MEM_CGROUP_CHARGE_TYPE_FORCE, A  /* used by force_empty */
A  A  A  MEM_CGROUP_CHARGE_TYPE_SWAPOUT, /* for accounting swapcache */

- A A MEM_CGROUP_CHARGE_TYPE_DROP, A A /* a page was unused swap cache */ A A A NR_CHARGE_TYPE,
A };

mm/memcontrol.c +0 -0
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
 A  A  A  switch (ctype) {

A A A case MEM_CGROUP_CHARGE_TYPE_MAPPED:
- A A case MEM_CGROUP_CHARGE_TYPE_DROP:

A  A  A  A  A  A  A  /* See mem_cgroup_prepare_migration() */
A  A  A  A  A  A  A  if (page_mapped(page) || PageCgroupMigration(pc))
A  A  A  A  A  A  A  A  A  A  A  goto unlock_out;
mm/memcontrol.c +0 -0
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
 A  A  A  struct mem_cgroup *memcg;
 A  A  A  int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
Quoted 6 lines

mm/memcontrol.c mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) · line 3126

Quoted 3 lines
mm/memcontrol.c +0 -3
- A  A  if (!swapout) /* this was a swap cache but the swap is unused ! */
- A  A  A  A  A  A  ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-

Then, here , what ctype must be if !swapout ?

Quoted 8 lines

I think MEM_CGROUP_CHARGE_TYPE_SWAPOUT is okay, i didn't get the point that the benefit of using MEM_CGROUP_CHARGE_TYPE_DROP.

If use MEM_CGROUP_CHARGE_TYPE_SWAPOUT, page_mapped(page) also checked in __mem_cgroup_uncharge_common().

Maybe i missed something. Thanks.

why you don't see 10 more lines.

If SWAPOUT,
- record swap out information to swap_cgroup
- don't decrease memcg->memsw counter
If DROP
- same as usual MAPPED anon pages.

DROP may be equal to MAPPED. But this swap realted codes are most fragile part of memcg and we used another name than MAPPED for taking care.

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>

author
#4 lore raw
Quoted 61 lines · KAMEZAWA Hiroyuki
Quoted 48 lines · On Wed, 7 Dec 2011 20:29:24 +0800 Bob Liu <[email protected]> wrote:
Quoted 39 lines · KAMEZAWA Hiroyuki
Quoted 5 lines · On Wed, 7 Dec 2011 18:30:46 +0800 Bob Liu <[email protected]> wrote:

uncharge will happen only when !page_mapped(page) no matter MEM_CGROUP_CHARGE_TYPE_DROP or MEM_CGROUP_CHARGE_TYPE_SWAPOUT when called from mem_cgroup_uncharge_swapcache(). i think it's no difference, so drop it.

I think you didn't test at all.

Quoted 28 lines

---
 mm/memcontrol.c |    5 -----

 1 files changed, 0 insertions(+), 5 deletions(-)
mm/memcontrol.c +0 -0
index 6aff93c..02a2988 100644
@@ -339,7 +339,6 @@ enum charge_type {

      MEM_CGROUP_CHARGE_TYPE_SHMEM,   /* used by page migration of shmem */ MEM_CGROUP_CHARGE_TYPE_FORCE,   /* used by force_empty */ MEM_CGROUP_CHARGE_TYPE_SWAPOUT, /* for accounting swapcache */
-     MEM_CGROUP_CHARGE_TYPE_DROP,    /* a page was unused swap cache */ NR_CHARGE_TYPE,
 };

mm/memcontrol.c +0 -0
@@ -3000,7 +2999,6 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
 
       switch (ctype) {

      case MEM_CGROUP_CHARGE_TYPE_MAPPED:
-     case MEM_CGROUP_CHARGE_TYPE_DROP:
              /* See mem_cgroup_prepare_migration() */ if (page_mapped(page) || PageCgroupMigration(pc)) goto unlock_out;

mm/memcontrol.c +0 -0
@@ -3121,9 +3119,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
       struct mem_cgroup *memcg;
       int ctype = MEM_CGROUP_CHARGE_TYPE_SWAPOUT;
 
Quoted 6 lines

mm/memcontrol.c mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout) · line 3126

Quoted 3 lines
mm/memcontrol.c +0 -3
-     if (!swapout) /* this was a swap cache but the swap is unused ! */
-             ctype = MEM_CGROUP_CHARGE_TYPE_DROP;
-

Then, here , what ctype must be if !swapout ?

Quoted 8 lines

I think MEM_CGROUP_CHARGE_TYPE_SWAPOUT is okay, i didn't get the point that the benefit of using MEM_CGROUP_CHARGE_TYPE_DROP.

If use  MEM_CGROUP_CHARGE_TYPE_SWAPOUT, page_mapped(page) also checked in __mem_cgroup_uncharge_common().

Maybe i missed something. Thanks.

why you don't see 10 more lines.

Quoted 9 lines

If SWAPOUT,
 - record swap out information to swap_cgroup
 - don't decrease memcg->memsw counter
If DROP
 - same as usual MAPPED anon pages.

DROP may be equal to MAPPED. But this swap realted codes are most fragile part of memcg and we used another name than MAPPED for taking care.

Get it.
Sorry for my noise, i didn't deep into following function.

Signature · 9 lines
Regards,
--Bob

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  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:"[email protected]"> [email protected] </a>