From patchwork Fri Jul 20 01:10:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Poynor X-Patchwork-Id: 1219031 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 913E2DF25A for ; Fri, 20 Jul 2012 01:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752050Ab2GTBLJ (ORCPT ); Thu, 19 Jul 2012 21:11:09 -0400 Received: from mail-ee0-f74.google.com ([74.125.83.74]:38562 "EHLO mail-ee0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736Ab2GTBLI (ORCPT ); Thu, 19 Jul 2012 21:11:08 -0400 Received: by eekb47 with SMTP id b47so168567eek.1 for ; Thu, 19 Jul 2012 18:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=Sa1rr4KAj6RYggmXIroN+oGlMqecBoIPi/fS42VCxGE=; b=Hs+WjgCmbbnVT1k6PMNQtsBTPQDp8qauVe0ouP80vC4MTx3hoFY/I6dhXMmSXE17Jw mq9pQSvdRSYJIQZxSkCZxiStfKOJasbZ7yqKLwntbIlCq/MMLvcelNnp7sYensYd5yzi UX5pHWaEPrfygkF+/gmPN3S8fI9r8KQcQRRCboejJ05/8hpS9Npow1eRZe/zQ8QcUW/Z UE5RlgFBWKVBx490+C22VyIgPB75baWnIYfN2+LwjO/kkimJ8Wvgb4DVhJvC1zSrnKct DnnMiMWGHTdkOAC8atXq+rUdYesGUFK6mMyGiE7BPXwFuB2ZI11NpjODPbqafJwYgjXv H07Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=Sa1rr4KAj6RYggmXIroN+oGlMqecBoIPi/fS42VCxGE=; b=bXp4G3T8kjlyzrQLSUdoYVpet7MOkLcKTxfgAenaTxZkJkNn6yhboPe853OslUBECQ S2hGcXrUsSGim1CpuVM1TqaA6kDNSK/ulNI9YD4cVAblVrnHnKxay0S5a55lqCH0vR75 4F0uG6Vj/Zmp0k93WKo3arjX7D6ywbKiIns06juy29Whc6f53LiW5AGaqe2kzqJw6PIz NbB62wVBHLI/RCWQK/a4hry/XuHKYsht9Msqp6ebu8Yn2a/Yy22P4DP0tEau4q6+mLtF fKP6VGfpII/8PFm2Kj2m5gQbqeBc6MnIe6tXl9foZAn5/Oya8nM4ljPzXoldlL6oKj+w DXRA== Received: by 10.180.96.42 with SMTP id dp10mr2847383wib.2.1342746667374; Thu, 19 Jul 2012 18:11:07 -0700 (PDT) Received: by 10.180.96.42 with SMTP id dp10mr2847377wib.2.1342746667336; Thu, 19 Jul 2012 18:11:07 -0700 (PDT) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id s44si4795858eeo.0.2012.07.19.18.11.07 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 19 Jul 2012 18:11:07 -0700 (PDT) Received: from toddpoynor2.mtv.corp.google.com (toddpoynor2.mtv.corp.google.com [172.18.104.48]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 2610120004E; Thu, 19 Jul 2012 18:11:07 -0700 (PDT) Received: by toddpoynor2.mtv.corp.google.com (Postfix, from userid 115684) id 702C414214C; Thu, 19 Jul 2012 18:11:06 -0700 (PDT) From: Todd Poynor To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, , Todd Poynor Subject: [PATCH v2] PM / Sleep: Print name of wakeup source that aborts suspend Date: Thu, 19 Jul 2012 18:10:58 -0700 Message-Id: <1342746658-17388-1-git-send-email-toddpoynor@google.com> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQkHTm77Dt1HBvvc3FhZoJDsRkxh0EWcF0VXDTaJParcwVEErMxAIhSlKRKc150WTwJjUGd/znm++bAnxe/QKSnGt5G5JYgPBM4I3+CVq3Fe3G2UyEtDwgBlibtahCkosRwsW4/v1r1gcX28EOLHOTnio4o5GaWWgNPvQUyV5vfc+yWB9Ezz0NhJwzS1J2v00E9JrK+P Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Signed-off-by: Todd Poynor --- drivers/base/power/wakeup.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) A driver or app may repeatedly request a wakeup source while the system is attempting to enter suspend, which may indicate a bug or at least point out a highly active system component that is responsible for decreased battery life on a mobile device. Even when the incidence of suspend abort is not severe, identifying wakeup sources that frequently abort suspend can be a useful clue for power management analysis. In some cases the existing stats can point out the offender where there is an unexpectedly high activation count that stands out from the others, but in other cases the wakeup source frequently taken just after the rest of the system thinks its time to suspend might not stand out in the overall stats. It is also often useful to have information about what's been happening recently, rather than totals of all activity for the system boot. It's suggested to dump a line about which wakeup source aborted suspend to aid analysis of these situations. v2 use ktime_to_ns() instead of comparisons on .tv64 field diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index cbb463b..8a0a9ca 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -649,6 +649,31 @@ void pm_wakeup_event(struct device *dev, unsigned int msec) } EXPORT_SYMBOL_GPL(pm_wakeup_event); +static void print_active_wakeup_sources(void) +{ + struct wakeup_source *ws; + int active = 0; + struct wakeup_source *last_activity_ws = NULL; + + rcu_read_lock(); + list_for_each_entry_rcu(ws, &wakeup_sources, entry) { + if (ws->active) { + pr_info("active wakeup source: %s\n", ws->name); + active = 1; + } else if (!active && + (!last_activity_ws || + ktime_to_ns(ws->last_time) > + ktime_to_ns(last_activity_ws->last_time))) { + last_activity_ws = ws; + } + } + + if (!active && last_activity_ws) + pr_info("last active wakeup source: %s\n", + last_activity_ws->name); + rcu_read_unlock(); +} + /** * pm_wakeup_pending - Check if power transition in progress should be aborted. * @@ -671,6 +696,10 @@ bool pm_wakeup_pending(void) events_check_enabled = !ret; } spin_unlock_irqrestore(&events_lock, flags); + + if (ret) + print_active_wakeup_sources(); + return ret; }