Re: [PATCH v3] PM / suspend: measure the time of filesystem syncing
From: Rafael J. Wysocki
Date: Wed Feb 20 2019 - 16:45:39 EST
On Wed, Feb 20, 2019 at 5:44 PM Pan, Harry <harry.pan@xxxxxxxxx> wrote:
>
> Thanks for comments.
>
> > > + 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?
> >
> Yes, I agree.
> In practical, I did see intervening messages (between pr_info and
> pr_cont) when it came to long sync in kernel.
> I was hesitated in this considering not fully understanding the
> backdrop of split messages using pr_info() then pr_cont().
>
> > Also, if you change it here, I guess it would be consistent to make
> > an analogous change for hibernation.
>
> One potential last-mile need your wisdom, which is about the switch
> case of SNAPSHOT_FREEZE of the userspace interface you wrote.
> I am yet to touch it, nor understand how to validate it.
Why don't you add a "sync" helper function in main.c with the timing
and message that will be called from hibernate.c, user.c and suspend.c
(in the last one conditional on
!IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC))?
That would reduce some code duplication nicely.