Skip to content
Browse files

lowmemorykiller: don't unregister notifier from atomic context

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.

Change-Id: I1577b04e617bc2b2e39dcb490fcfc9ce660eb7ec
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
  • Loading branch information...
1 parent 1ea2a5d commit f18f676471e51f7315dae2b5eea4dadb687718b1 @rabinv rabinv committed with Sep 9, 2010
Showing with 3 additions and 4 deletions.
  1. +3 −4 Kernel/drivers/staging/android/victory/lowmemorykiller.c
View
7 Kernel/drivers/staging/android/victory/lowmemorykiller.c
@@ -71,10 +71,8 @@ static int
task_notify_func(struct notifier_block *self, unsigned long val, void *data)
{
struct task_struct *task = data;
- if (task == lowmem_deathpending) {
+ if (task == lowmem_deathpending)
lowmem_deathpending = NULL;
- task_free_unregister(&task_nb);
- }
return NOTIFY_OK;
}
@@ -182,7 +180,6 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
selected->pid, selected->comm,
selected_oom_adj, selected_tasksize);
lowmem_deathpending = selected;
- task_free_register(&task_nb);
force_sig(SIGKILL, selected);
rem -= selected_tasksize;
}
@@ -201,13 +198,15 @@ static struct shrinker lowmem_shrinker = {
static int __init lowmem_init(void)
{
+ task_free_register(&task_nb);
register_shrinker(&lowmem_shrinker);
return 0;
}
static void __exit lowmem_exit(void)
{
unregister_shrinker(&lowmem_shrinker);
+ task_free_unregister(&task_nb);
}
module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);

0 comments on commit f18f676

Please sign in to comment.
Something went wrong with that request. Please try again.