Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3378859imj; Tue, 19 Feb 2019 02:27:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IaVI0+/Wd67NbxcP3YRUw0wvfnfV1fdmg7O+LnAnR7bo1mnCV9lpyk6dler9a0awNh0TXD1 X-Received: by 2002:a62:6383:: with SMTP id x125mr10593815pfb.239.1550572020123; Tue, 19 Feb 2019 02:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550572020; cv=none; d=google.com; s=arc-20160816; b=BurGUl0R5i99ptOI5vpSClXniGdnJC2I/n96QMP9sUhcdpZyC+Jm5kK5HZAgRpEKgU uxtqtnkrPfUvmN69NBb/Wk6YwRrEV168hNIEgomD5kWee4VZG87QxSM9Sa5mVLtYNGrz m/Tg1WllXiKrPyJCAbkYWQA1XFTRRvHR4ld4mmgG3XBhVG/Hjq4lHdPnHgWeOb8x8nXU //te2Ik3n27K/6SEFxgFxxeFCOINiwJGpHtNy8DT7plT0Uf2KgRA2QHXBcU1VSeWMSv0 WC2StNNs8x1fcGnSOzRloOkpuFFgSarimtXjqC7v3EZwFupiZDnGVmoCMCLYhq8H+5xv 912g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cqrZOw7KpgpAKQlecw5F+H8fnSLaLEO1RYFChzWdWVQ=; b=vnwk2hMg476lan4h21XfSboPKbqAihfR/ECSoL/8cV8o6Ww2ea9XGCE/6aYjUYX62m 4T3Y4u646guW/mlHNdIqJE5kNOBpUUWr2sXNLChn2k8cPZuW0f3TooKv4DYJA/Yw9hJE 6Aeywtq9dc/e1IwhRhVQKWKE5aMvnvRn61nSoGgGtdd4sIQU3o3zU3VqznVY4CJIdNBR y77u4e2GLDVhG53u0lZ/+/1TbNln6h66IjFoUTqaWOFeCSS4kt/8D2Po1wQuOn0G7vl7 Jbp3oSIXRaLeGwZTcs/d7qkkGnnO7s0USrUDEaAst0CeS+u53ReY3z+mw/ZUc8YBjeFH UbUg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si2820912pgm.355.2019.02.19.02.26.44; Tue, 19 Feb 2019 02:27:00 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728210AbfBSK0C (ORCPT + 99 others); Tue, 19 Feb 2019 05:26:02 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:58333 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbfBSK0C (ORCPT ); Tue, 19 Feb 2019 05:26:02 -0500 Received: from 79.184.254.15.ipv4.supernova.orange.pl (79.184.254.15) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id afe34b449a1f16d5; Tue, 19 Feb 2019 11:26:00 +0100 From: "Rafael J. Wysocki" To: Harry Pan Cc: LKML , gs0622@gmail.com, pavel@ucw.cz, len.brown@intel.com, linux-pm@vger.kernel.org Subject: Re: [PATCH v3] PM / suspend: measure the time of filesystem syncing Date: Tue, 19 Feb 2019 11:24:36 +0100 Message-ID: <2819109.DzhZvocLkm@aspire.rjw.lan> In-Reply-To: <20190214111543.22137-1-harry.pan@intel.com> References: <20190206154214.576-1-harry.pan@intel.com> <20190214111543.22137-1-harry.pan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, February 14, 2019 12:15:43 PM CET Harry Pan wrote: > 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); One more nit. Since you are printing the sync time anyway, there is a little sense to split the message using pr_cont() that may be messed up with by any intervening messages, so why don't you just print a one-line pr_info("Filesystems sync: %d.%03d seconds\n", ...) message? Also, if you change it here, I guess it would be consistent to make an analogous change for hibernation. > + 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(); >