oom_kill.c badness() correction for shared memory

From: Jeff Davis
Date: Fri Feb 09 2007 - 14:00:40 EST



In oom_kill.c, badness() takes into account many factors, including half
the total_vm of all the children.

The problem with this calculation is that, if the parent and children
share memory, the shared memory segment is counted many times for the
parent.

I don't think we need to count the shared memory at all when calculating
badness, because there's already a hard limit on the amount of shared
memory, so it's unlikely that process is runaway due to shared memory
consumption.

Would it be better to just use (total_vm-shared_vm) in the badness
function in each instance it currently uses total_vm? At a minimum, we
should do that for the loop that counts each child's vm against the
parent.

An example of a practical problem is with PostgreSQL. PostgreSQL
installations often have very large shared memory regions shared between
the parent and all the child processes. If the OOM killer is invoked,
it's almost guaranteed to kill the PostgreSQL parent process first, even
if the PostgreSQL processes all combined use much less memory than the
"real" bad process (because the same shared memory is counted many
times).

Regards,
Jeff Davis

-
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/