Revert "lowmemorykiller: make default lowmemorykiller debug message useful"

This reverts commit fa09273d77d4444a69dd6885e258bbeaf286d103.
Revert "lowmemorykiller.c: Update to Linux v3.4"

This reverts commit 6c1439da450c2fd12bca6940ac69165b2c4929f1.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "lowmemorykiller.c: Fix error negative width in bit-field"

This reverts commit 3c8fdbfca12025fde74a79a75cc06752008d6c7b.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "staging: android: lowmemorykiller: Change default debug_level to 1"

This reverts commit 86649ef2cd0e87a0e94cb69254aa6afcbad384a0.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "staging: android: lowmemorykiller: Don't count reserved free memory"

This reverts commit d9c46e3df7c328e23eba6c55c250cb15558decd1.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "staging: android: lowmemorykiller: Add config option to support oom_adj values"

This reverts commit 87449c7a45662bea5a215b3863d40ad0cdfcafb3.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
arch:arm:configs: remove ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "staging: android: lowmemorykiller: Fix task_struct leak"

This reverts commit 97883ddedb955976db008b67e18f5d3ea92f8a13.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "staging: android: lowmemorykiller: Don't try to kill the same pid over and over"

This reverts commit 5ffdce3163b57aa8ca5e7587e9228e5269522aee.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
lowmemorykiller: Account for ZONE_MOVABLE during hotplug.

When a memory section is offlined, lmk would be invoked to
create room to migrate pages if required. When this happens
lmk should discount any free memory in the section being
offlined for its heuristics.

Change-Id: I79d8e332451cbb6d51735836b6a19bded01dfad9
Signed-off-by: Naveen Ramaraj <nramaraj@codeaurora.org>
Staging: android: fixed 80 characters warnings in lowmemorykiller.c

This patch fixes some 80 chatacters limit warnings in the lowmemorykiller.c file

Signed-off-by: Marco Navarra <fromenglish@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
staging: android/lowmemorykiller: Don't grab tasklist_lock

Grabbing tasklist_lock has its disadvantages, i.e. it blocks
process creation and destruction. If there are lots of processes,
blocking doesn't sound as a great idea.

For LMK, it is sufficient to surround tasks list traverse with
rcu_read_{,un}lock().

>From now on using force_sig() is not safe, as it can race with an
already exiting task, so we use send_sig() now. As a downside, it
won't kill PID namespace init processes, but that's not what we
want anyway.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
staging: android/lowmemorykiller: Better mm handling

LMK should not directly check for task->mm. The reason is that the
process' threads may exit or detach its mm via use_mm(), but other
threads may still have a valid mm. To catch this we use
find_lock_task_mm(), which walks up all threads and returns an
appropriate task (with lock held).

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
staging: android/lowmemorykiller: No need for task->signal check

task->signal == NULL is not possible, so no need for these checks.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
staging: android/lowmemorykiller: Do not kill kernel threads

LMK should not try killing kernel threads.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
staging: android, lowmemorykiller: convert to use
 oom_score_adj

/proc/pid/oom_adj is deprecated and will be removed in August 2012
according to Documentation/feature-removal-schedule.txt.  Convert its
usage in the lowmemorykiller to use the new interface, oom_score_adj,
instead.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
Staging: android: lowmemorykiller.c

Fix compiler warning about the type of the module parameter.

Cc: San Mehat <san@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
modified for tuna board from Linux 3.4+ by faux123

Signed-off-by: Dan Trifan <jimsth@gmail.com>
lowmemorykiller: make default lowmemorykiller debug message useful

lowmemorykiller debug messages are inscrutable and mostly useful
for debugging the lowmemorykiller, not explaining why a process
was killed.  Make the messages more useful by prefixing them
with "lowmemorykiller: " and explaining in more readable terms
what was killed, who it was killed for, and why it was killed.

The messages now look like:
[   76.997631] lowmemorykiller: Killing 'droid.gallery3d' (2172), adj 1000,
[   76.997635]    to free 27436kB on behalf of 'kswapd0' (29) because
[   76.997638]    cache 122624kB is below limit 122880kB for oom_score_adj 1000
[   76.997641]    Free memory is -53356kB above reserved

A negative number for free memory above reserved means some of the
reserved memory has been used and is being regenerated by kswapd,
which is likely what called the shrinkers.

Change-Id: I1fe983381e73e124b90aa5d91cb66e55eaca390f
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>