Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1701258imj; Thu, 14 Feb 2019 10:32:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IblJHLiw3obdz1ZOx7Z6ZGWiKHvrBTKzvQEGWxC1gknbuwRrvGLM9wHeacP5pCZmRDJ42w1 X-Received: by 2002:a62:f204:: with SMTP id m4mr5434797pfh.58.1550169160314; Thu, 14 Feb 2019 10:32:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550169160; cv=none; d=google.com; s=arc-20160816; b=mX9BDKnfuyJUpSfDIj09CQSQqqz6QJX4T6vEa1m0YPLhe5t1tAjgn8bRfSJTfXT+Br U81FHrnKrPyfOUa4SPmhPa+9DjFmUpRMTLKLxCAysiIOGYQjsMyoG5o/j4xv3tu0ulEx Z7WCfghKuA0y9WiUW4RCu1n8wPmoPuEY0wZ97bMhYiWJOE8ExAGl4Mh9cbMZlDQrT648 pa1cwH2Ie+cSfqD0OthyfrkcXjw/SgrFuBfUXT6Efnqk3QuuZ+K7vopPJ+nIUljyK6a1 pTqmgVIO3Yn1xO+ZWD2RxqA973F/zJozb18B1w1/0UovQUnIpfwZrtQgK2MjC8tV/XkT j9rg== 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=pednms5nNzAygvq/6SHuGdkBAejWWgGAV7kLxC3yWic=; b=gvXAgJJ5xu55Vgsep+Zs7YrzikotYSY9sp3gP8+ZIHJTrJyBmHt2nAk7kVAakuQH/8 wtl4WaUawlCzluOAo0kx+zXLMEB4M/Oej6W/oAQ1Q9JXTNjYkmMif5fRmdjJWNgx3iTe exlDbeqHwWwB3Dr4kinih3E6KP9xPjjK+iFLW2lrbGwFs/S9NoV7+3Hp/8Dd05IyNbV8 H/k/pw2L3dvKarMuq0T5hFk9hbMR+RiSLM7S74ue0h1auFVk2gtH0OpEhszxFq6sXjhK 48EWL39j3trpPqD6x5yqQ0ZQsLHxcMb3qfUHJyFHcGigmIlvbtcSkYtNzCl1uZ9iFOad K+yQ== 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 d6si1168930pgq.319.2019.02.14.10.32.24; Thu, 14 Feb 2019 10:32:40 -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 S2405682AbfBNLWg (ORCPT + 99 others); Thu, 14 Feb 2019 06:22:36 -0500 Received: from 61-228-47-100.dynamic-ip.hinet.net ([61.228.47.100]:48744 "EHLO E6440.gar.corp.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733036AbfBNLWg (ORCPT ); Thu, 14 Feb 2019 06:22:36 -0500 Received: from E6440.gar.corp.intel.com (localhost [127.0.0.1]) by E6440.gar.corp.intel.com (Postfix) with ESMTP id F1018C0680; Thu, 14 Feb 2019 15:16:56 +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 v3] PM / suspend: measure the time of filesystem syncing Date: Thu, 14 Feb 2019 15:16:51 +0800 Message-Id: <20190214071651.447-1-harry.pan@intel.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20190206154214.576-1-harry.pan@intel.com> References: <20190206154214.576-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 Signed-off-by: Harry Pan --- kernel/power/suspend.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0bd595a0b610..4844fc6a796d 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -568,13 +568,20 @@ 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; + unsigned int elapsed_msecs; + + trace_suspend_resume(TPS("sync_filesystems"), 0, true); + pr_info("Syncing filesystems ... "); + start = ktime_get(); + ksys_sync(); + elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start)); + pr_cont("(elapsed %d.%03d seconds) done.\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