Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754474AbbGCG5w (ORCPT ); Fri, 3 Jul 2015 02:57:52 -0400 Received: from LGEMRELSE7Q.lge.com ([156.147.1.151]:50144 "EHLO lgemrelse7q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754420AbbGCG5q (ORCPT ); Fri, 3 Jul 2015 02:57:46 -0400 X-Original-SENDERIP: 165.243.139.167 X-Original-MAILFROM: From: SungEun Kim To: rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "cleaeye.kim" Subject: [PATCH v3] PM / Sleep: Use workqueue for user space wakeup sources garbage collector Date: Fri, 3 Jul 2015 15:57:20 +0900 Message-Id: <1435906640-27641-1-git-send-email-cleaneye.kim@lge.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1435739328-17021-1-git-send-email-cleaneye.kim@lge.com> References: <1435739328-17021-1-git-send-email-cleaneye.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2359 Lines: 80 From: "cleaeye.kim" 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 --- kernel/power/wakelock.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c index 019069c..1896386 100644 --- a/kernel/power/wakelock.c +++ b/kernel/power/wakelock.c @@ -17,6 +17,7 @@ #include #include #include +#include #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,13 +99,12 @@ 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; - if (++wakelocks_gc_count <= WL_GC_COUNT_MAX) - return; + mutex_lock(&wakelocks_lock); now = ktime_get(); list_for_each_entry_safe_reverse(wl, aux, &wakelocks_lru_list, lru) { @@ -127,6 +129,16 @@ static void wakelocks_gc(void) } } wakelocks_gc_count = 0; + + mutex_unlock(&wakelocks_lock); +} + +static void wakelocks_gc(void) +{ + if (++wakelocks_gc_count <= WL_GC_COUNT_MAX) + return; + + schedule_work(&wakelock_work); } #else /* !CONFIG_PM_WAKELOCKS_GC */ static inline void wakelocks_lru_add(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/