Skip to contentSkip to conversation

memcg: replace unsigned long by u64 to avoid overflow

PATCH Superseded Wanpeng Li 3 participants 6 messages Jun 23, 2012 – Jun 25, 2012

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/6 memcg: replace unsigned long by u64 to avoid overflow

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

---
 mm/memcontrol.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/memcontrol.c +2 -3
index a2677e0..724bd02 100644
@@ -776,8 +776,7 @@ mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, int nid, int zid,
 	return ret;
 }
 
-static unsigned long
-mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
+static u64 mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
 			int nid, unsigned int lru_mask)
 {
 	u64 total = 0;
@@ -790,7 +789,7 @@ mem_cgroup_node_nr_lru_pages(struct mem_cgroup *memcg,
 	return total;
 }
 
-static unsigned long mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg,
+static u64 mem_cgroup_nr_lru_pages(struct mem_cgroup *memcg,
 			unsigned int lru_mask)
 {
 	int nid;
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

I wonder what 16 TB of memory must think running on a 32-bit kernel... "What is this, an address space for ants?"

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#2 lore raw
Quoted 9 lines · Johannes Weiner
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

I wonder what 16 TB of memory must think running on a 32-bit kernel... "What is this, an address space for ants?"

Hi Johannes,

You mean change all u64 in memcg to unsigned long? or something I miss....

Regards,
Wanpeng Li

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#3 lore raw
Quoted 8 lines · Wanpeng Li
Quoted 7 lines · Johannes Weiner
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

Quoted 7 lines
Quoted 2 lines

I wonder what 16 TB of memory must think running on a 32-bit kernel... "What is this, an address space for ants?"

Hi Johannes,

You mean change all u64 in memcg to unsigned long? or something I miss....

Not _all_ of them, we have some that count bytes. But those counting pages should probably be ulong, yes.

I think Kame added the ones that you wanted to adjust the surroundings for in particular, so let's ask him. 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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 14 lines · Johannes Weiner
Quoted 13 lines · Wanpeng Li
Quoted 9 lines · Johannes Weiner
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

I wonder what 16 TB of memory must think running on a 32-bit kernel... "What is this, an address space for ants?"

Hi Johannes,

Quoted 9 lines
Quoted 2 lines

You mean change all u64 in memcg to unsigned long? or something I miss....

Not _all_ of them, we have some that count bytes. But those counting pages should probably be ulong, yes.

I think Kame added the ones that you wanted to adjust the surroundings for in particular, so let's ask him. Kame?

I've been using 'unsigned long' for the number of pages and 'u64' for the number of bytes. I think it's enough and it should be. I don't have any reason to use u64 for the number of pages on 32bit archs.
If 'bytes' are handled by 'unsigned long', please fix it.

BTW, zone_page_state()::/include/linux/vmstat.h returns 'unsigned long'. If you want to change this in memcg, please change zone's ones first.

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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#5 lore raw
Quoted 25 lines · Kamezawa Hiroyuki
Quoted 14 lines · Johannes Weiner
Quoted 13 lines · Wanpeng Li
Quoted 9 lines · Johannes Weiner
Quoted 5 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Since the return value variable in mem_cgroup_zone_nr_lru_pages and mem_cgroup_node_nr_lru_pages functions are u64, so replace the return value of funtions by u64 to avoid overflow.

I wonder what 16 TB of memory must think running on a 32-bit kernel... "What is this, an address space for ants?"

Hi Johannes,

Quoted 9 lines
Quoted 2 lines

You mean change all u64 in memcg to unsigned long? or something I miss....

Not _all_ of them, we have some that count bytes. But those counting pages should probably be ulong, yes.

I think Kame added the ones that you wanted to adjust the surroundings for in particular, so let's ask him. Kame?

Quoted 7 lines

I've been using 'unsigned long' for the number of pages and 'u64' for the number of bytes. I think it's enough and it should be. I don't have any reason to use u64 for the number of pages on 32bit archs.
If 'bytes' are handled by 'unsigned long', please fix it.

BTW, zone_page_state()::/include/linux/vmstat.h returns 'unsigned long'. If you want to change this in memcg, please change zone's ones first.

Thank you for your comments Kame! :-) I will do this in next version. Is any suggestion about patches in this patchset.

Regards,
Wanpeng Li

Quoted 4 lines

Thanks,
-Kame