Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp1720712imc; Fri, 22 Feb 2019 09:56:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ2bDoBvk8Ll2PJGey+24DnRCZKg8XaTiFYYn69uhVY6JPqcj9FB7Lrp3QB4h6u7nlqj8DI X-Received: by 2002:a62:190e:: with SMTP id 14mr5414480pfz.70.1550858204214; Fri, 22 Feb 2019 09:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550858204; cv=none; d=google.com; s=arc-20160816; b=fi+lWAxPfhZ1hTYP8f3uudaxlDZ00ZeE7tYYP8cftIjUZBZaoWWB85Cz2EtYeoinIT E1LF6EtvibHciZAzkA0G0RoKb/MwukPsTZ+vUXMTCYrtlbiWDvXE64myECiRM60FAvzz TISghCTmEI/KeY/Tyhse/ZyEjXKD+9hItG+aFk97NO8KFWgbDL5aZBHI/LVXD+hdIRcf sJQtNTi5bEgTg+jy1nvIMS+FU6WTtWZHvb5eC+E0AH4tF1FYYKIgGNf9LI+9qqGIJ0Gu a89GTSN1NbsBfOafJbcJONlrltO6P2W9XLiHr4ByRH7MMidrvrF5h2+b40pcz4T2YDu5 cDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KrmVAuPfJ1brETd1mPFODuYRIWAvIWmoGhyPFvoGWpY=; b=RHbg+L8f93p2mm/7rne6i1qlFtdyjFXbA9NP0iKeeK9wFx+FC3e+EwZhxG806VtE6C yTZgVSOUE8bA8wCzgAZEqjqXKuQl619S8sa+8o7qJuIl1FsX3FrfXuTxiB5trSaHCnf7 vPLG9nump3dBKFkAD3r72jHRMBkigBsHKZ7YlbwmBCWG05e4+vW0uRnas1cKJmroXBef 7gToszJwTW3JCb8IMsgK0OjK3WFDJuAI+YMf0jDoIPcQjNepxVDCT7voJMvXR6fz8wll j5ehkV+3uIc8p9OoaGlhGO0VhyCIo/A8aqvmyGsjtNmxcwoTf1On4xlDsKPmW2BA4Dvk 7fzQ== 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 71si1884706plb.8.2019.02.22.09.56.28; Fri, 22 Feb 2019 09:56:44 -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 S1727146AbfBVRys (ORCPT + 99 others); Fri, 22 Feb 2019 12:54:48 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:58916 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfBVRys (ORCPT ); Fri, 22 Feb 2019 12:54:48 -0500 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 102C380328; Fri, 22 Feb 2019 18:54:38 +0100 (CET) Date: Fri, 22 Feb 2019 18:54:44 +0100 From: Pavel Machek To: Harry Pan Cc: LKML , gs0622@gmail.com, rjw@rjwysocki.net, len.brown@intel.com, linux-pm@vger.kernel.org Subject: Re: [PATCH v5] PM / sleep: measure the time of filesystem syncing Message-ID: <20190222175444.GA8264@amd> References: <20190220161840.994-1-harry.pan@intel.com> <20190222154904.6260-1-harry.pan@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RnlQjJ0d97Da+TV1" Content-Disposition: inline In-Reply-To: <20190222154904.6260-1-harry.pan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --RnlQjJ0d97Da+TV1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri 2019-02-22 23:49:04, Harry Pan wrote: > This patch gives the reader an intuitive metric of the time cost by > the kernel issuing a filesystem 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 automatic script. >=20 > 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 > v5: introduce sync helper shared by suspend, hibernate, and snapshot >=20 > Signed-off-by: Harry Pan > --- > include/linux/suspend.h | 3 +++ > kernel/power/hibernate.c | 5 +---- > kernel/power/main.c | 15 +++++++++++++++ > kernel/power/suspend.c | 13 +++++-------- > kernel/power/user.c | 5 +---- > 5 files changed, 25 insertions(+), 16 deletions(-) >=20 > diff --git a/include/linux/suspend.h b/include/linux/suspend.h > index 3f529ad9a9d2..6b3ea9ea6a9e 100644 > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -425,6 +425,7 @@ void restore_processor_state(void); > /* kernel/power/main.c */ > extern int register_pm_notifier(struct notifier_block *nb); > extern int unregister_pm_notifier(struct notifier_block *nb); > +extern void ksys_sync_helper(void); > =20 > #define pm_notifier(fn, pri) { \ > static struct notifier_block fn##_nb =3D \ > @@ -462,6 +463,8 @@ static inline int unregister_pm_notifier(struct notif= ier_block *nb) > return 0; > } > =20 > +static inline void ksys_sync_helper(void) {} > + > #define pm_notifier(fn, pri) do { (void)(fn); } while (0) > =20 > static inline bool pm_wakeup_pending(void) { return false; } > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index abef759de7c8..cc105ecd9c07 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -14,7 +14,6 @@ > =20 > #include > #include > -#include > #include > #include > #include > @@ -709,9 +708,7 @@ int hibernate(void) > goto Exit; > } > =20 > - pr_info("Syncing filesystems ... \n"); > - ksys_sync(); > - pr_info("done.\n"); > + ksys_sync_helper(); > =20 > error =3D freeze_processes(); > if (error) > diff --git a/kernel/power/main.c b/kernel/power/main.c > index 35b50823d83b..a08dcc743f31 100644 > --- a/kernel/power/main.c > +++ b/kernel/power/main.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > =20 > #include "power.h" > =20 > @@ -51,6 +52,20 @@ void unlock_system_sleep(void) > } > EXPORT_SYMBOL_GPL(unlock_system_sleep); > =20 > +void ksys_sync_helper(void) > +{ > + ktime_t start; > + s64 elapsed_msecs; > + > + start =3D ktime_get(); > + ksys_sync(); > + elapsed_msecs =3D 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); > +} Sharing code is fine. Changing message, remove partial print before long operation is not. Adding timing is not, either. There are other ways to get that info. NAK. Pavel =09 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --RnlQjJ0d97Da+TV1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlxwN2QACgkQMOfwapXb+vJvBQCgkMRk0v/vPSFG3A+Sbq19oee0 8m8AnAsOmxyUQNmZVQPMn8p/jnaclXOJ =myIT -----END PGP SIGNATURE----- --RnlQjJ0d97Da+TV1--