Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1175078 > unrolled thread

[PATCH v2] PM / Sleep: Use workqueue for user space wakeup sources garbage collector

Started bySungEun Kim <cleaneye.kim@lge.com>
First post2015-07-01 10:30 +0200
Last post2015-07-03 02:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2] PM / Sleep: Use workqueue for user space wakeup sources garbage collector SungEun Kim <cleaneye.kim@lge.com> - 2015-07-01 10:30 +0200
    Re: [PATCH v2] PM / Sleep: Use workqueue for user space wakeup sources garbage collector "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-07-03 02:00 +0200

#1175078 — [PATCH v2] PM / Sleep: Use workqueue for user space wakeup sources garbage collector

FromSungEun Kim <cleaneye.kim@lge.com>
Date2015-07-01 10:30 +0200
Subject[PATCH v2] PM / Sleep: Use workqueue for user space wakeup sources garbage collector
Message-ID<pHlz4-2HQ-13@gated-at.bofh.it>
From: "SungEun Kim" <cleaneye.kim@lge.com>

The synchronous synchronize_rcu in wakeup_source_remove makes user process
which writes to /sys/kernel/wake_unlock blocked sometimes.

For example, when android eventhub tries to release wakelock,
this blocking process can occur, and eventhub can't get input event
for a while.

Using workqueue instead of direct function call at pm_wake_unlock
can prevent this unnecessary delay of an user space process.

Signed-off-by: SungEun Kim <cleaneye.kim@lge.com>
---
 kernel/power/wakelock.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
index 019069c..5df6aa2 100644
--- a/kernel/power/wakelock.c
+++ b/kernel/power/wakelock.c
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <linux/rbtree.h>
 #include <linux/slab.h>
+#include <linux/workqueue.h>
 
 #include "power.h"
 
@@ -83,7 +84,9 @@ static inline void decrement_wakelocks_number(void) {}
 #define WL_GC_COUNT_MAX	100
 #define WL_GC_TIME_SEC	300
 
+static void __wakelocks_gc(struct work_struct *work);
 static LIST_HEAD(wakelocks_lru_list);
+static DECLARE_WORK(wakelock_work, __wakelocks_gc);
 static unsigned int wakelocks_gc_count;
 
 static inline void wakelocks_lru_add(struct wakelock *wl)
@@ -96,7 +99,7 @@ static inline void wakelocks_lru_most_recent(struct wakelock *wl)
 	list_move(&wl->lru, &wakelocks_lru_list);
 }
 
-static void wakelocks_gc(void)
+static void __wakelocks_gc(struct work_struct *work)
 {
 	struct wakelock *wl, *aux;
 	ktime_t now;
@@ -105,6 +108,7 @@ static void wakelocks_gc(void)
 		return;
 
 	now = ktime_get();
+	mutex_lock(&wakelocks_lock);
 	list_for_each_entry_safe_reverse(wl, aux, &wakelocks_lru_list, lru) {
 		u64 idle_time_ns;
 		bool active;
@@ -126,8 +130,14 @@ static void wakelocks_gc(void)
 			decrement_wakelocks_number();
 		}
 	}
+	mutex_unlock(&wakelocks_lock);
 	wakelocks_gc_count = 0;
 }
+
+static void wakelocks_gc(void)
+{
+	schedule_work(&wakelock_work);
+}
 #else /* !CONFIG_PM_WAKELOCKS_GC */
 static inline void wakelocks_lru_add(struct wakelock *wl) {}
 static inline void wakelocks_lru_most_recent(struct wakelock *wl) {}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1176272

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-07-03 02:00 +0200
Message-ID<pHWyC-10m-9@gated-at.bofh.it>
In reply to#1175078
On Wednesday, July 01, 2015 05:28:48 PM SungEun Kim wrote:
> From: "SungEun Kim" <cleaneye.kim@lge.com>
> 
> The synchronous synchronize_rcu in wakeup_source_remove makes user process
> which writes to /sys/kernel/wake_unlock blocked sometimes.
> 
> For example, when android eventhub tries to release wakelock,
> this blocking process can occur, and eventhub can't get input event
> for a while.
> 
> Using workqueue instead of direct function call at pm_wake_unlock
> can prevent this unnecessary delay of an user space process.

The idea is defendable, but the patch is too simple.

For example, if the garbage collection is in progress, it is not useful
to start a new one.

Also the incrementation and clearing of wakelocks_gc_count should be under
the lock.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web