Re: [PATCH] oom: handle overflow in mem_cgroup_out_of_memory()

From: KAMEZAWA Hiroyuki
Date: Wed Jan 26 2011 - 19:30:44 EST

On Wed, 26 Jan 2011 14:29:09 -0800
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:

> On Wed, 26 Jan 2011 12:32:04 -0800
> Greg Thelen <gthelen@xxxxxxxxxx> wrote:
> > > That being said, does this have any practical impact at all? I mean,
> > > this code runs when the cgroup limit is breached. But if the number
> > > of allowed pages (not bytes!) can not fit into 32 bits, it means you
> > > have a group of processes using more than 16T. On a 32-bit machine.
> >
> > The value of this patch is up for debate. I do not have an example
> > situation where this truncation causes the wrong thing to happen. I
> > suppose it might be possible for a racing update to
> > memory.limit_in_bytes which grows the limit from a reasonable (example:
> > 100M) limit to a large limit (example 1<<45) could benefit from this
> > patch. I admit that this case seems pathological and may not be likely
> > or even worth bothering over. If neither the memcg nor the oom
> > maintainers want the patch, then feel free to drop it. I just noticed
> > the issue and thought it might be worth addressing.
> Ah. I was scratching my head over that.
> In zillions of places the kernel assumes that a 32-bit kernel has less
> than 2^32 pages of memory, so the code as it stands is, umm, idiomatic.

I think we can assume that.

> But afaict the only way the patch makes a real-world difference is if
> res_counter_read_u64() is busted?
> And, as you point out, res_counter_read_u64() is indeed busted on
> 32-bit machines. It has 25 callsites in mm/memcontrol.c - has anyone
> looked at the implications of this? What happens in all those
> callsites if the counter is read during a count rollover?

I'll review. Against the roll-over, I think we just need to take lock.
So, res_counter_read_u64() implementation was wrong. It should take lock.
Please give me time.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at