From patchwork Wed Jul 18 18:51:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Poynor X-Patchwork-Id: 1213031 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 064893FCFC for ; Wed, 18 Jul 2012 18:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755527Ab2GRSwg (ORCPT ); Wed, 18 Jul 2012 14:52:36 -0400 Received: from mail-fa0-f74.google.com ([209.85.161.74]:61066 "EHLO mail-fa0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755522Ab2GRSwf (ORCPT ); Wed, 18 Jul 2012 14:52:35 -0400 Received: by fat25 with SMTP id 25so102852fat.1 for ; Wed, 18 Jul 2012 11:52:34 -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=w7hPGwYhibkh4e9j0UjyCZk5ukxuzFOZ27z5e4aEIBQ=; b=bOOh3Tg9aYGQUInLaxbqjqUL1goj5TJV8X8J8NDEg+YWhgt6JekYvGbRJwgjLUxQQ5 5HipEHon3myFUr9KFQdODP7nzjp1Fv8GBzSteY4kyz6ffsarFSt9tboOJN7k6Qk7hYdn aLJfuv8Vdc9aQa9vH0BqwK+Sc36rjYNvTOu3/HXxNQw2LuRehXDsFeS5OV5SQ2lK9YeB pkm3FjRhDM4v3D8BULlfP0ACtJTHPKgqJZVY+8hHym1F3499fLU2IPKa07sCzK6H3lfq xNhn1YC/RA9+9+CfErhYOhJHSV7c1CnTIgWhOWw0nms7hmqO13xYG7FnQ0e2psSDrliX yPew== 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=w7hPGwYhibkh4e9j0UjyCZk5ukxuzFOZ27z5e4aEIBQ=; b=QA4j+QS8u8pFazRwc1YRnJKzmgrPOF3MCnclBvw3DqJZvT6uk7JYtmybIVVAapwgKn WZOTxAxoCgDPDzNSb55s9L9MfFvrcH2Bx6oaGDMVloIaw4g6GG+AJ8/UoPLPmrLAborj pEzeFTzIxHFTr/a1ImNKNzd8GZBJ4KrhOCu/Gql6Zc/FuzXb8UvY26+BXyqEiLTNsqaj jUEnze1Vx85qM1wwiQY+Wc7JdNf5dE1AMhx1iVRI1fubgYXEVv3zyKU5RYE9u+z8z1bv 07PgU8v1m6kDypfhjUNkOea2p/TL5IV5yvIGjea22TYKm2bwW/ZB7uDoBPp85sWCebli U9Qw== Received: by 10.14.211.196 with SMTP id w44mr3755176eeo.0.1342637554583; Wed, 18 Jul 2012 11:52:34 -0700 (PDT) Received: by 10.14.211.196 with SMTP id w44mr3755168eeo.0.1342637554526; Wed, 18 Jul 2012 11:52:34 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id s44si17255823eeo.0.2012.07.18.11.52.34 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 18 Jul 2012 11:52:34 -0700 (PDT) Received: from toddpoynor2.mtv.corp.google.com (toddpoynor2.mtv.corp.google.com [172.18.104.48]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id 5A45D5C0050; Wed, 18 Jul 2012 11:52:34 -0700 (PDT) Received: by toddpoynor2.mtv.corp.google.com (Postfix, from userid 115684) id 8E659142099; Wed, 18 Jul 2012 11:52:33 -0700 (PDT) From: Todd Poynor To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, , Todd Poynor Subject: [PATCH] PM / Sleep: Print name of wakeup source that aborts suspend Date: Wed, 18 Jul 2012 11:51:59 -0700 Message-Id: <1342637519-22355-1-git-send-email-toddpoynor@google.com> X-Mailer: git-send-email 1.7.7.3 X-Gm-Message-State: ALoCoQlA8FhNTiQ3bgBWvoz0VZI/T00ch0uYIwWJa+ALe0PFHw3IbLPHaLItiiz4A2zPxNnk2NSLqg8rcqFT6z415x2Lzl+GzZcfQK+bfMxORacN7i1wSie14fkMrnjCfpyw5gy+c3Ih5rPIUMANbCBO2g95Bb/F31cHRY0I+xfK7y8My/CPNBT5/HfxKy2tq2YXF2QKb5SB Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Print active wakeup sources, or the most recently active wakeup source, when a PM transition is aborted due to wakeup source events. 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 (optionally?) dump a line about which wakeup source aborted suspend to aid analysis of these situations. diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index cbb463b..c079ffe 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 || + ws->last_time.tv64 > + last_activity_ws->last_time.tv64)) { + 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; }