Re: [patch 2/4] memcg: catch negative per-cpu sums in dirty info
From: Greg Thelen
Date: Mon Nov 08 2010 - 17:29:18 EST
Minchan Kim <minchan.kim@xxxxxxxxx> writes:
> On Mon, Nov 8, 2010 at 7:14 AM, Johannes Weiner <hannes@xxxxxxxxxxx> wrote:
>> Folding the per-cpu counters can yield a negative value in case of
>> accounting races between CPUs.
>>
>> When collecting the dirty info, the code would read those sums into an
>> unsigned variable and then check for it being negative, which can not
>> work.
>>
>> Instead, fold the counters into a signed local variable, make the
>> check, and only then assign it.
>>
>> This way, the function signals correctly when there are insane values
>> instead of leaking them out to the caller.
>>
>> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx>
Reviewed-by: Greg Thelen <gthelen@xxxxxxxxxx>
--
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/