Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp751167imp; Wed, 20 Feb 2019 08:21:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IYMhjTpC+6V9U2gFBRzXOT4I7JaIMzf49rAi1hXEAcOV8sUQIcPRniwBxWpHAmdXcV5DRZW X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr14981181plo.265.1550679716716; Wed, 20 Feb 2019 08:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550679716; cv=none; d=google.com; s=arc-20160816; b=Wihb2gftOhxUyki4Akv/kXsrg2uZKR4EAeHQEr1vWSTyBsfMU/e2lir8fsoADFJUkX T7XIysSaX0Jd2S8L5fDGcRexTHJdjaoCaEfOe6+i/vQeI1yILXLam2UUCmEK8OD1sD0L 2qO6HQEJXVxkwCJX9uV7U1CgGhASfi0pnZ/PkQFC//THei/quQDowa9XXE4dUNCcoqOs UxbhsKcIr+sLd1XR78Td5yvE0g/tcK3ZVrA68na2dCpoqo3ZyfMkG5mrHpRBgEPUa9K5 PU/6XP9CdIwV1innqjrqL2FRIEuTGnylZgmnM4Ps+SGyBtYyhRqqQsZIcXZXW0XHsVKR Fdtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=fVOmD+0rc8y0we6uUJZ3/x8u6c8kYVxijwtgWNR+sNs=; b=OQX0jRlaUficCkbnXAQH5QFTzbUJkodPjpjcs2UAZW3r7HeCkFjf1WJZaoskIJ/AKC b3hjxyik2tYs8ARO6rBXmeqfG6fTevs86L9gYXzwmJQo1mb4jtJ6FlZhHbS8pEewdOov TE4br6WYtAKSwVqF/HqlAViUHhuKLJGeGRBrq1hiWZrSSLsneDklF7yiJaRwRcC6b2Eh P3SmxC4UI/zHdi9/QkOJrWUEt7yDYpLCKbTB9n1cdDvU/xBL59LhVR+jOBqYK0TsRIFb urYk9J0il+no8fiqYTF6rACldzdnmxL9d5m6dXKDMUm4zgBzkoLBEJrZR37phAfdPuCB iaVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si1968774plk.273.2019.02.20.08.21.41; Wed, 20 Feb 2019 08:21:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfBTQTd (ORCPT + 99 others); Wed, 20 Feb 2019 11:19:33 -0500 Received: from [101.13.169.104] ([101.13.169.104]:54497 "EHLO E6440.gar.corp.intel.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725877AbfBTQTc (ORCPT ); Wed, 20 Feb 2019 11:19:32 -0500 Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id 4E1ACC0500; Thu, 21 Feb 2019 00:12:25 +0800 (CST) From: Harry Pan To: LKML Cc: gs0622@gmail.com, Harry Pan , rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz, linux-pm@vger.kernel.org Subject: [PATCH v4] PM / suspend: measure the time of filesystem syncing Date: Thu, 21 Feb 2019 00:12:22 +0800 Message-Id: <20190220161222.632-1-harry.pan@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190214111543.22137-1-harry.pan@intel.com> References: <20190214111543.22137-1-harry.pan@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch gives the reader an intuitive metric of the time cost by the kernel issuing a filesystem sync during suspend; 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 automatic script. v2: simplify the variables, apply the simplest form of ktime API. v3: reduce conditional compilation, rectify profiling in better syntax v4: avoid interposition, profile on hibernation, rectify printk format Signed-off-by: Harry Pan --- kernel/power/hibernate.c | 9 +++++++-- kernel/power/suspend.c | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index abef759de7c8..387703907827 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -688,6 +688,8 @@ int hibernate(void) { int error, nr_calls = 0; bool snapshot_test = false; + ktime_t start; + s64 elapsed_msecs; if (!hibernation_available()) { pm_pr_dbg("Hibernation not available.\n"); @@ -709,9 +711,12 @@ int hibernate(void) goto Exit; } - pr_info("Syncing filesystems ... \n"); + start = ktime_get(); ksys_sync(); - pr_info("done.\n"); + elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start)); + pr_info("Filesystems sync: %lld.%03lld seconds\n", + elapsed_msecs / MSEC_PER_SEC, + elapsed_msecs % MSEC_PER_SEC); error = freeze_processes(); if (error) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..7fb5ba1314d3 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -568,13 +568,19 @@ static int enter_state(suspend_state_t state) if (state == PM_SUSPEND_TO_IDLE) s2idle_begin(); -#ifndef CONFIG_SUSPEND_SKIP_SYNC - trace_suspend_resume(TPS("sync_filesystems"), 0, true); - pr_info("Syncing filesystems ... "); - ksys_sync(); - pr_cont("done.\n"); - trace_suspend_resume(TPS("sync_filesystems"), 0, false); -#endif + if (!IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC)) { + ktime_t start; + s64 elapsed_msecs; + + trace_suspend_resume(TPS("sync_filesystems"), 0, true); + start = ktime_get(); + ksys_sync(); + elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start)); + pr_info("Filesystems sync: %lld.%03lld seconds\n", + elapsed_msecs / MSEC_PER_SEC, + elapsed_msecs % MSEC_PER_SEC); + trace_suspend_resume(TPS("sync_filesystems"), 0, false); + } pm_pr_dbg("Preparing system for sleep (%s)\n", mem_sleep_labels[state]); pm_suspend_clear_flags(); -- 2.18.1