From patchwork Mon Feb 25 09:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Pan X-Patchwork-Id: 10828529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56F6E17E6 for ; Mon, 25 Feb 2019 12:44:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A3FA1FF83 for ; Mon, 25 Feb 2019 12:44:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E6F32996E; Mon, 25 Feb 2019 12:44:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E17C92A8C6 for ; Mon, 25 Feb 2019 12:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfBYMoR (ORCPT ); Mon, 25 Feb 2019 07:44:17 -0500 Received: from 61-228-43-219.dynamic-ip.hinet.net ([61.228.43.219]:38866 "EHLO E6440.gar.corp.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726864AbfBYMoR (ORCPT ); Mon, 25 Feb 2019 07:44:17 -0500 Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id A5055C10A9; Mon, 25 Feb 2019 17:45:23 +0800 (CST) From: Harry Pan To: LKML Cc: harry.pan@intel.com, gs0622@gmail.com, rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org Subject: [PATCH v7 2/2] PM / sleep: measure the time of filesystems syncing Date: Mon, 25 Feb 2019 17:44:23 +0800 Message-Id: <20190225094422.5492-2-harry.pan@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190225094422.5492-1-harry.pan@intel.com> References: <20190224061753.17638-2-harry.pan@intel.com> <20190225094422.5492-1-harry.pan@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch gives the reader an intuitive metric of the time cost by the kernel issuing filesystems sync during system sleep; although developer can guess by the timestamp of next log or enable the ftrace power event for manual calculation, this manner is easier to read and benefits the automation script. v1 to v5: context discussion v6: split patches logically in code refactor and sync profile v7: improve 32/64 bit machine compatibility Signed-off-by: Harry Pan --- kernel/power/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/power/main.c b/kernel/power/main.c index a8a8e6ec57e6..eea3d65eb960 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -54,9 +54,15 @@ EXPORT_SYMBOL_GPL(unlock_system_sleep); void ksys_sync_helper(void) { - pr_info("Syncing filesystems ... "); + ktime_t start; + long elapsed_msecs; + + start = ktime_get(); ksys_sync(); - pr_cont("done.\n"); + elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start)); + pr_info("Filesystems sync: %ld.%03ld seconds\n", + elapsed_msecs / MSEC_PER_SEC, + elapsed_msecs % MSEC_PER_SEC); } EXPORT_SYMBOL_GPL(ksys_sync_helper);