android, lowmemorykiller: remove task handoff notifier
authorDavid Rientjes <rientjes@google.com>
Mon, 9 Apr 2012 23:56:18 +0000 (16:56 -0700)
committerGrazvydas Ignotas <notasas@gmail.com>
Wed, 25 Apr 2012 22:25:14 +0000 (01:25 +0300)
commit38838e8ef1905cad3f655c58b2d38687bfb2d309
treef2392c0eb956c574fd433b38fc7223efeb969f27
parent079e437e92d5212b8dffb671bba888b41c52365a
android, lowmemorykiller: remove task handoff notifier

The task handoff notifier leaks task_struct since it never gets freed
after the callback returns NOTIFY_OK, which means it is responsible for
doing so.

It turns out the lowmemorykiller actually doesn't need this notifier at
all.  It's used to prevent unnecessary killing by waiting for a thread
to exit as a result of lowmem_shrink(), however, it's possible to do
this in the same way the kernel oom killer works by setting TIF_MEMDIE
and avoid killing if we're still waiting for it to exit.

The kernel oom killer will already automatically set TIF_MEMDIE for
threads that are attempting to allocate memory that have a fatal signal.
The thread selected by lowmem_shrink() will have such a signal after the
lowmemorykiller sends it a SIGKILL, so this won't result in an
unnecessary use of memory reserves for the thread to exit.

This has the added benefit that we don't have to rely on
CONFIG_PROFILING to prevent needlessly killing tasks.

Reported-by: Werner Landgraf <w.landgraf@ru.ru>
Cc: stable@vger.kernel.org
Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: Colin Cross <ccross@android.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/staging/android/lowmemorykiller.c