From patchwork Fri Aug 1 16:30:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 34728 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B888202A1 for ; Fri, 1 Aug 2014 16:32:00 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf29407157pad.2 for ; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=1EDr5L2aEUglKmAnFoaUOBkW3UnvbFN5BAJuwZ6xVck=; b=SXSY+a+KqGSoh/Sgi4f4za/qft3+lsJKVe8PeEIgYOMf+tOboMeqfJdDpKaYd6kShC XAXB9hb7S23WqRhO2KQKNYUp8UskiAx+ojZddINHwCvAx0QimwrWym2UG8RCVKXsSBXP ZAVBjJ0RIVGhZ420dJu2Ccg8Du+eL6FLodLdbpLUE/aI/hSxlrVp60kz8pCLKksBXoec DMsl59JYNc9IR7roQ2tYcUWlysBv4XYp/FY1Bp2lza4GmJ85ngx0lzlP6nWZbV+9hsXt OAf2wl+TbhAtmYgeSn2GNuc9ZUB+DgFsTO5Sk+/bKN+xsJ/tmEqj6FBtja1jX8XI6Fxh tWDQ== X-Gm-Message-State: ALoCoQnZ4BcETUm0n+IJuGla8HE430nub9yjNV1LrvalOqpfsEe4IOMNnIZiIA2E0bA4+Li/NjaL X-Received: by 10.66.124.199 with SMTP id mk7mr2672005pab.15.1406910719629; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.117 with SMTP id b108ls1404007qga.19.gmail; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) X-Received: by 10.52.98.201 with SMTP id ek9mr6465483vdb.35.1406910719455; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id z9si7781631veu.47.2014.08.01.09.31.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Aug 2014 09:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so7053982vcb.2 for ; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) X-Received: by 10.220.50.8 with SMTP id x8mr7747735vcf.18.1406910719298; Fri, 01 Aug 2014 09:31:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp123659vcb; Fri, 1 Aug 2014 09:31:58 -0700 (PDT) X-Received: by 10.69.2.226 with SMTP id br2mr7505357pbd.29.1406910718295; Fri, 01 Aug 2014 09:31:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba2si5207479pdb.0.2014.08.01.09.31.57 for ; Fri, 01 Aug 2014 09:31:58 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755483AbaHAQb4 (ORCPT + 19 others); Fri, 1 Aug 2014 12:31:56 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:50392 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755298AbaHAQbx (ORCPT ); Fri, 1 Aug 2014 12:31:53 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so5778099pdb.41 for ; Fri, 01 Aug 2014 09:31:53 -0700 (PDT) X-Received: by 10.70.15.225 with SMTP id a1mr7640744pdd.13.1406910713072; Fri, 01 Aug 2014 09:31:53 -0700 (PDT) Received: from localhost.localdomain ([106.51.243.250]) by mx.google.com with ESMTPSA id ee5sm9163129pbc.47.2014.08.01.09.31.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Aug 2014 09:31:52 -0700 (PDT) From: Amit Pundir To: linux-kernel@vger.kernel.org Cc: Todd Poynor , Pavel Machek , Thomas Gleixner , "Rafael J. Wysocki" , Len Brown , linux-pm@vger.kernel.org, Android Kernel Team , John Stultz , Sumit Semwal , Amit Pundir Subject: [RFC][PATCH 2/2] PM: Suspend: Print wall time at suspend entry and exit Date: Fri, 1 Aug 2014 22:00:49 +0530 Message-Id: <1406910649-4028-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1406910649-4028-1-git-send-email-amit.pundir@linaro.org> References: <1406910649-4028-1-git-send-email-amit.pundir@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: amit.pundir@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Todd Poynor Existing printk timestamps in a dmesg only log suspend activities (e.g. filesystem syncs, freezing/unfreezing tasks etc) while the system has already started to enter/exit the suspend state. Sometimes it is handy to have suspend entry/exit overhead information while debugging suspend issues. This patch print markers with wall timestamps at suspend Entry and Exit in the kernel log. These timestamps can be used to compute how long the system spent in low-power suspend state plus the entry/exit overhead. This patch comes from the Android patch set, where its been used to help diagnose battery life problems in various Android-based devices. Cc: Pavel Machek Cc: Thomas Gleixner Cc: Rafael J. Wysocki Cc: Len Brown Cc: linux-pm@vger.kernel.org Cc: Android Kernel Team Cc: John Stultz Cc: Sumit Semwal Signed-off-by: Todd Poynor [Amit Pundir: Reworded the commit message] Signed-off-by: Amit Pundir --- The original patch was submitted to linux-pm couple of years back but I could not trace any feedback or activity thereafter. Hence I'm resubmitting this change. kernel/power/suspend.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index ed35a47..28726b6 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -417,6 +418,18 @@ static int enter_state(suspend_state_t state) return error; } +static void pm_suspend_marker(char *annotation) +{ + struct timespec ts; + struct rtc_time tm; + + getnstimeofday(&ts); + rtc_time_to_tm(ts.tv_sec, &tm); + pr_info("PM: suspend %s %d-%02d-%02d %02d:%02d:%02d.%09lu UTC\n", + annotation, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec); +} + /** * pm_suspend - Externally visible function for suspending the system. * @state: System sleep state to enter. @@ -431,6 +444,7 @@ int pm_suspend(suspend_state_t state) if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) return -EINVAL; + pm_suspend_marker("entry"); error = enter_state(state); if (error) { suspend_stats.fail++; @@ -438,6 +452,7 @@ int pm_suspend(suspend_state_t state) } else { suspend_stats.success++; } + pm_suspend_marker("exit"); return error; } EXPORT_SYMBOL(pm_suspend);