summaryrefslogtreecommitdiffstats
path: root/drivers/staging/android/lowmemorykiller.c
Commit message (Collapse)AuthorAgeFilesLines
* drivers: convert shrinkers to new count/scan APIDave Chinner2013-09-101-17/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert the driver shrinkers to the new API. Most changes are compile tested only because I either don't have the hardware or it's staging stuff. FWIW, the md and android code is pretty good, but the rest of it makes me want to claw my eyes out. The amount of broken code I just encountered is mind boggling. I've added comments explaining what is broken, but I fear that some of the code would be best dealt with by being dragged behind the bike shed, burying in mud up to it's neck and then run over repeatedly with a blunt lawn mower. Special mention goes to the zcache/zcache2 drivers. They can't co-exist in the build at the same time, they are under different menu options in menuconfig, they only show up when you've got the right set of mm subsystem options configured and so even compile testing is an exercise in pulling teeth. And that doesn't even take into account the horrible, broken code... [glommer@openvz.org: fixes for i915, android lowmem, zcache, bcache] Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Glauber Costa <glommer@openvz.org> Acked-by: Mel Gorman <mgorman@suse.de> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Kent Overstreet <koverstreet@google.com> Cc: John Stultz <john.stultz@linaro.org> Cc: David Rientjes <rientjes@google.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Carlos Maiolino <cmaiolino@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Chuck Lever <chuck.lever@oracle.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Rientjes <rientjes@google.com> Cc: Gleb Natapov <gleb@redhat.com> Cc: Greg Thelen <gthelen@google.com> Cc: J. Bruce Fields <bfields@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Jerome Glisse <jglisse@redhat.com> Cc: John Stultz <john.stultz@linaro.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Kent Overstreet <koverstreet@google.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Steven Whitehouse <swhiteho@redhat.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* staging: android: lowmemorykiller: well-marked debug printDmitry Voytik2013-03-251-1/+3
| | | | | | | | | Add "lowmemorykiller:" prefix to the debug print so it's easier to analyse LMK's debug output: dmesg | grep lowmemorykiller Signed-off-by: Dmitry Voytik <dvv.kernel@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: android: lowmemorykiller: Change default debug_level to 1Arve Hjønnevåg2013-03-051-1/+1
| | | | | | | | | | | | | | The select...to kill messages are not very useful when not debugging the lowmemorykiller itself. After the change to check TIF_MEMDIE instead of using a task notifer this message can also get very noisy. Cc: Android Kernel Team <kernel-team@android.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: android: lowmemorykiller: Don't count reserved free memoryArve Hjønnevåg2013-03-051-1/+2
| | | | | | | | | | | | | The amount of reserved memory varies between devices. Subtract it here to reduce the amount of devices specific tuning needed for the minfree values. Cc: Android Kernel Team <kernel-team@android.com> Cc: Arve Hjønnevåg <arve@android.com> Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* mm, oom: change type of oom_score_adj to shortDavid Rientjes2012-12-111-8/+8
| | | | | | | | | | | | | | | | The maximum oom_score_adj is 1000 and the minimum oom_score_adj is -1000, so this range can be represented by the signed short type with no functional change. The extra space this frees up in struct signal_struct will be used for per-thread oom kill flags in the next patch. Signed-off-by: David Rientjes <rientjes@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reviewed-by: Michal Hocko <mhocko@suse.cz> Cc: Anton Vorontsov <anton.vorontsov@linaro.org> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* android, lowmemorykiller: remove task handoff notifierDavid Rientjes2012-04-091-41/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Staging: android: lowmemorykiller.cGreg Kroah-Hartman2012-03-071-1/+1
| | | | | | | 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>
* staging: android/lowmemorykiller: Don't unregister notifier from atomic contextPaul E. McKenney2012-03-071-7/+7
| | | | | | | | | | | | | | | | | | | | | | The lowmemorykiller registers an atomic notifier for notfication of when the task is freed. From this atomic notifier callback, it removes the atomic notifier via task_free_unregister(). This is incorrect because atomic_notifier_chain_unregister() calls syncronize_rcu(), which can sleep, which shouldn't be done from an atomic notifier. Fix this by registering the notifier during init, and only unregister it if the lowmemorykiller is unloaded. Rebased to -next by Paul E. McKenney. Rebased to -next again by Anton Vorontsov. Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> Signed-off-by: Christian Bejram <christian.bejram@stericsson.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reported-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* staging: android, lowmemorykiller: convert to use oom_score_adjDavid Rientjes2012-02-131-21/+22
| | | | | | | | | | /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>
* Merge tag 'staging-3.3-rc3' into staging-nextGreg Kroah-Hartman2012-02-101-15/+15
|\ | | | | | | | | | | | | | | | | | | This was done to resolve some merge issues with the following files that had changed in both branches: drivers/staging/rtl8712/rtl871x_sta_mgt.c drivers/staging/tidspbridge/rmgr/drv_interface.c drivers/staging/zcache/zcache-main.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * staging: android/lowmemorykiller: Do not kill kernel threadsAnton Vorontsov2012-02-081-0/+3
| | | | | | | | | | | | | | | | | | | | 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>
| * staging: android/lowmemorykiller: No need for task->signal checkAnton Vorontsov2012-02-081-7/+1
| | | | | | | | | | | | | | | | | | | | 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>
| * staging: android/lowmemorykiller: Better mm handlingAnton Vorontsov2012-02-081-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * staging: android/lowmemorykiller: Don't grab tasklist_lockAnton Vorontsov2012-02-081-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | staging: android: lowmemorykiller: Don't wait more than one second for a ↵Arve Hjønnevåg2012-02-081-1/+4
|/ | | | | | | | | | | | process to die If a process forked and the child process was killed by the lowmemorykiller, the lowmemory killer would be disabled until the parent process reaped the child or it died itself. Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* Staging: android: fixed 80 characters warnings in lowmemorykiller.cMarco Navarra2011-12-221-6/+6
| | | | | | | 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>
* android: lowmemorykiller: Fix arguments to lowmem_shrinkColin Cross2011-11-301-9/+9
| | | | | | | | The arguments to shrink functions have changed, update lowmem_shrink to match. Signed-off-by: Colin Cross <ccross@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging: android: lowmemorykiller: Ignore shmem pages in page-cacheArve Hjønnevåg2011-11-301-1/+2
| | | | | Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging: android: lowmemorykiller: Update arguments of shrinker for 2.6.35Colin Cross2011-11-301-1/+1
| | | | | Signed-off-by: Colin Cross <ccross@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging: android: lowmemorykiller: Remove bitrotted codepathSan Mehat2011-11-301-6/+0
| | | | | | | | | | Now that we're murder-synchronous, this code path will never be called (and if it does, it doesn't tell us anything useful other than we killed a task that was already being killed by somebody else but hadn't gotten its' signal yet) Signed-off-by: San Mehat <san@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging: android: lowmemkiller: Substantially reduce overhead during reclaimSan Mehat2011-11-301-0/+43
| | | | | | | | | | | | This patch optimizes lowmemkiller to not do any work when it has an outstanding kill-request. This greatly reduces the pressure on the task_list lock (improving interactivity), as well as improving the vmscan performance when under heavy memory pressure (by up to 20x in tests). Note: For this enhancement to work, you need CONFIG_PROFILING Signed-off-by: San Mehat <san@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging: android: lowmemorykiller: Don't try to kill the same pid over and overSan Mehat2011-11-301-0/+6
| | | | | | | | | | | | | | | | | | | Under certain circumstances, a process can take awhile to handle a sig-kill (especially if it's in a scheduler group with a very low share ratio). When this occurs, lowmemkiller returns to vmscan indicating the process memory has been freed - even though the process is still waiting to die. Since the memory hasn't actually freed, lowmemkiller is called again shortly after, and picks the same process to die; regardless of the fact that it has already been 'scheduled' to die and the memory has already been reported to vmscan as having been freed. Solution is to check fatal_signal_pending() on the selected task, and if it's already pending destruction return; indicating to vmscan that no resources were freed on this pass. Signed-off-by: San Mehat <san@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* staging/android: fix build issuesCorentin Chary2011-11-301-2/+4
| | | | | Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Revert "Staging: android: delete android drivers"Greg Kroah-Hartman2011-11-301-0/+173
| | | | | | | | | | | | | | This reverts commit b0a0ccfad85b3657fe999805df65f5cfe634ab8a. Turns out I was wrong, we want these in the tree. Note, I've disabled the drivers from the build at the moment, so other patches can be applied to fix some build issues due to internal api changes since the code was removed from the tree. Cc: Arve Hjønnevåg <arve@android.com> Cc: Brian Swetland <swetland@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: delete android driversGreg Kroah-Hartman2009-12-111-173/+0
| | | | | | | | | | | | These drivers are no longer being developed and the original authors seem to have abandonded them and hence, do not want them in the mainline kernel tree. So sad :( Cc: Brian Swetland <swetland@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: fix module param errorsRandy Dunlap2009-09-151-7/+7
| | | | | | | | | | | | | | | Move module_params to near the end of the source file so that their references are already known/defined. Fixes build errors: drivers/staging/android/lowmemorykiller.c: In function '__check_cost': drivers/staging/android/lowmemorykiller.c:60: error: 'lowmem_shrinker' undeclared (first use in this function) drivers/staging/android/lowmemorykiller.c: At top level: drivers/staging/android/lowmemorykiller.c:60: error: 'lowmem_shrinker' undeclared here (not in a function) drivers/staging/android/lowmemorykiller.c:60: warning: type defaults to 'int' in declaration of 'type name' Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: delete the decription fileDaniel Walker2009-09-151-0/+16
| | | | | | | | | | | Move the lowmemorykiller.txt into the actual source file which is really the correct place for it, and delete lowmemorykiller.txt. Signed-off-by: Daniel Walker <dwalker@fifo99.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Brian Swetland <swetland@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: remove a predefineDaniel Walker2009-09-151-6/+5
| | | | | | | | | | I moved the struct shrinker down so that the predefine isn't needed. Signed-off-by: Daniel Walker <dwalker@fifo99.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: Brian Swetland <swetland@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller.c: fix it for "oom: move oom_adj value ↵David Rientjes2009-07-281-3/+5
| | | | | | | | | | | from task_struct to mm_struct" I'm about to merge "oom: move oom_adj value from task_struct to mm_struct", and this fixup is needed to repair linux-next's drivers/staging/android/lowmemorykiller.c. Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: fix up remaining checkpatch warningsGreg Kroah-Hartman2009-06-191-10/+16
| | | | | | | | | | | | This cleans up the last of the checkpatch warnings in the android lowmemorykiller driver. Cc: San Mehat <san@android.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: fix possible android low memory killer ↵David Rientjes2009-06-191-2/+8
| | | | | | | | | | | | | NULL pointer get_mm_rss() atomically dereferences the actual without checking for a NULL pointer, which is possible since task_lock() is not held. Cc: San Mehat <san@android.com> Cc: Arve Hjønnevåg <arve@android.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: cleanup android low memory killerDavid Rientjes2009-06-191-13/+26
| | | | | | | | | | | | | | | Clean up the code in lowmem_shrink() for the Android low memory killer so that it follows the kernel coding style. It's unnecessary to check for p->oomkilladj >= min_adj if the selected task's oomkilladj score is stored since get_mm_rss() will always be greater than zero. Cc: San Mehat <san@android.com> Cc: Arve Hjønnevåg <arve@android.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: Don't count free space unless it meets ↵Arve Hjønnevåg2009-06-191-4/+9
| | | | | | | | | | | | | | | the specified limit by itself From: Arve Hjønnevåg <arve@android.com> This allows processes to be killed when the kernel evict cache pages in an attempt to get more contiguous free memory. Signed-off-by: Arve Hjønnevåg <arve@android.com> Cc: David Rientjes <rientjes@google.com> Cc: San Mehat <san@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: lowmemorykiller: Only iterate over process list when needed.Arve Hjønnevåg2009-06-191-14/+21
| | | | | | | | | | | | | | | Use NR_ACTIVE plus NR_INACTIVE as a size estimate for our fake cache instead the sum of rss. Neither method is accurate. Also skip the process scan, if the amount of memory available is above the largest threshold set. Signed-off-by: Arve Hjønnevåg <arve@android.com> Cc: David Rientjes <rientjes@google.com> Cc: San Mehat <san@android.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
* Staging: android: add lowmemorykiller driverSan Mehat2009-01-061-0/+119
From: San Mehat <san@android.com> Cc: Brian Swetland <swetland@google.com> Cc: Robert Love <rlove@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
OpenPOWER on IntegriCloud