This is a note to let you know that I've just added the patch titled

    staging: android/lowmemorykiller: Don't unregister notifier from

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-next branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will also will be merged in the next major kernel release
during the merge window.

If you have any questions about this process, please let me know.


>From 1eda5166c7640092f512138be6899d050c3d62ed Mon Sep 17 00:00:00 2001
From: "Paul E. McKenney" <[email protected]>
Date: Wed, 7 Mar 2012 17:54:00 +0400
Subject: staging: android/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.

Rebased to -next by Paul E. McKenney.
Rebased to -next again by Anton Vorontsov.

Signed-off-by: Rabin Vincent <[email protected]>
Signed-off-by: Christian Bejram <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
Reported-by: John Stultz <[email protected]>
Signed-off-by: Anton Vorontsov <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 drivers/staging/android/lowmemorykiller.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/android/lowmemorykiller.c 
b/drivers/staging/android/lowmemorykiller.c
index cf4c6f7..03d1de2 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -75,10 +75,10 @@ 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_handoff_unregister(&task_nb);
-       }
+
        return NOTIFY_OK;
 }
 
@@ -175,14 +175,12 @@ static int lowmem_shrink(struct shrinker *s, struct 
shrink_control *sc)
                             selected->pid, selected->comm,
                             selected_oom_score_adj, selected_tasksize);
                /*
-                * If CONFIG_PROFILING is off, then task_handoff_register()
-                * is a nop. In that case we don't want to stall the killer
-                * by setting lowmem_deathpending.
+                * If CONFIG_PROFILING is off, then we don't want to stall
+                * the killer by setting lowmem_deathpending.
                 */
 #ifdef CONFIG_PROFILING
                lowmem_deathpending = selected;
                lowmem_deathpending_timeout = jiffies + HZ;
-               task_handoff_register(&task_nb);
 #endif
                send_sig(SIGKILL, selected, 0);
                rem -= selected_tasksize;
@@ -200,6 +198,7 @@ static struct shrinker lowmem_shrinker = {
 
 static int __init lowmem_init(void)
 {
+       task_handoff_register(&task_nb);
        register_shrinker(&lowmem_shrinker);
        return 0;
 }
@@ -207,6 +206,7 @@ static int __init lowmem_init(void)
 static void __exit lowmem_exit(void)
 {
        unregister_shrinker(&lowmem_shrinker);
+       task_handoff_unregister(&task_nb);
 }
 
 module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
-- 
1.7.9


--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to