Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4526579imj; Tue, 12 Feb 2019 18:34:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IaKK3HDoN472H2dMAlfe6nbh1OdbdN5sNdCrtpstftc/Ce58BAggZpu69zUlB9IJr3hdqDz X-Received: by 2002:a62:5486:: with SMTP id i128mr6982327pfb.215.1550025253892; Tue, 12 Feb 2019 18:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550025253; cv=none; d=google.com; s=arc-20160816; b=GAtbRRPV3hDv95KGMVgrKSCJqO5ER5WOv8AW8HuFbxhZtR6s2dFBHEj6k6cBh7b1UV 9x1IyNMH9ORgECVIB+oZchB8cg44yx379H5nBC2exViMIbapo6OfOjRuwgiGBn6E+XGZ Fq04y/iCfDc6CxXQvDVnBFZcBlnysQ3i6HqrLL1goaO9LRFJoTWkqooNz+oRqsDhc44y RfbpJYJkzrvtA86Oyc/F4Aq5FBg1mblsHRjyF+Mv9y2rWxoM1Ezqr/hQC1AQrMFmJguM DJjKPsSJmJ9hvzAZQHI7ouRm0TifWbk/pYyavuj6GK+d0c9uZdItnUMVlAnMeK6IfmrJ m/bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=2Cos5lVwWbpurrhrpSa0YT6qGbgr5VDJak4cKUsbQAw=; b=VyQ05nBT569FrjtWxdavD8HNumoMfhVAIZ+a+kJWwySdS4vxeybUWtxQObowzsZ+Qq NNLLkvPNf5W2sPihJ4WMH2wpFdwNKrwWk13w9ejGVU+DFCsLLiBXKwaiX26XUolmCSH8 lm89o90F0Qkmgo+GH6GnJWvGIBto6eYHqMnJBPQpt5azLEAuPVDSbhCJ3I2Wqa0d3uJX FjXmHSEpuywuQad2Cq7fIlZ+YKyA9PTuenkHGGuqe34VgnU0SQPYFnlehuIykPDsnADm N0Uq1M+7keMiSx0YIE1d46VBBzT0uUfA+YWij2lJLXaeVlrFMVLdFwi+hTxg9201+iFn IApg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si13369144pgl.481.2019.02.12.18.33.58; Tue, 12 Feb 2019 18:34:13 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728549AbfBLX1C (ORCPT + 99 others); Tue, 12 Feb 2019 18:27:02 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:33001 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbfBLX1C (ORCPT ); Tue, 12 Feb 2019 18:27:02 -0500 Received: by mail-ot1-f66.google.com with SMTP id i20so889674otl.0; Tue, 12 Feb 2019 15:27:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2Cos5lVwWbpurrhrpSa0YT6qGbgr5VDJak4cKUsbQAw=; b=jEz/nXWaStHfe7gxSt1I74/VyewOu+CD5iizoNNlbvC/KHHlqCBERCziwobGEc9PSL yjfyTbjSqgS+qtt2p6wbdS/Ko3knxPhD/hfxo3WcHy8x83FCz9w63qeTyMJ6bcNGigia GIxV8tC5dI3xpxZqcSIL1Vwxs5ihAPeuXTZ8uTnyIe70se7KCoa3OhlufgVf6sOUhVZL XGx2antvJdHoKRzC1lsvdFNCvVFZichtgfStoZFNwwh5hPplsKwkKbuiKT1BLWXQ4cwR aYcm/t4wyxSIMRFI1Me1DNkPuhkYN5WqJkTjwcaXd0Yebugj46+yd8ES7aPqk8K9Xvmb weDw== X-Gm-Message-State: AHQUAub43J2qjNmxt12Zi+6JrgkIO9MSHSve+r3vCs1mud1PSIZAvoJo MHlFUdZDDJxoEL/Iu+2ChWc3lGPcuTcJlmj6c9E= X-Received: by 2002:a9d:5a09:: with SMTP id v9mr4643891oth.244.1550014021038; Tue, 12 Feb 2019 15:27:01 -0800 (PST) MIME-Version: 1.0 References: <20190203052007.27392-1-harry.pan@intel.com> <20190206144257.21464-1-harry.pan@intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 13 Feb 2019 00:26:50 +0100 Message-ID: Subject: Re: [PATCH] PM / suspend: measure the time of filesystem syncing To: Harry Pan Cc: LKML , Harry Pan , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 13, 2019 at 12:21 AM Rafael J. Wysocki wrote: > > On Wed, Feb 6, 2019 at 4:57 PM 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. > > > > Signed-off-by: Harry Pan > > --- > > kernel/power/suspend.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > > index 0bd595a0b610..87c0073f0c9d 100644 > > --- a/kernel/power/suspend.c > > +++ b/kernel/power/suspend.c > > @@ -550,6 +550,8 @@ static void suspend_finish(void) > > static int enter_state(suspend_state_t state) > > { > > int error; > > + ktime_t start; > > + unsigned int elapsed_msecs; > > You only need these two if CONFIG_SUSPEND_SKIP_SYNC is set, -> > > > > > trace_suspend_resume(TPS("suspend_enter"), state, true); > > if (state == PM_SUSPEND_TO_IDLE) { > > @@ -570,9 +572,12 @@ static int enter_state(suspend_state_t state) > > > > #ifndef CONFIG_SUSPEND_SKIP_SYNC > > -> so I would change this to > > if (IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC)) { if (!IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC)) { that is (missing "!"). > ktime_t start; > unsigned int elapsed_msecs; > > > trace_suspend_resume(TPS("sync_filesystems"), 0, true); > > + start = ktime_get(); > > Why don't you do this after printing the message below? > > > pr_info("Syncing filesystems ... "); > > ksys_sync(); > > - pr_cont("done.\n"); > > + elapsed_msecs = ktime_to_ms(ktime_sub(ktime_get(), start)); > > + pr_cont("(elapsed %d.%03d seconds) done.\n", elapsed_msecs / 1000, > > + elapsed_msecs % 1000); > > Use MSEC_PER_SEC here. > > > trace_suspend_resume(TPS("sync_filesystems"), 0, false); > > #endif > >