public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: dsterba@suse.cz, Nikolay Borisov <nborisov@suse.com>,
	Ioannis Angelakopoulos <iangelak@fb.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v2 2/2] btrfs: Expose the BTRFS commit stats through sysfs
Date: Wed, 15 Jun 2022 14:32:48 -0700	[thread overview]
Message-ID: <YqpQANRnbc4uBmjT@zen> (raw)
In-Reply-To: <20220615133130.GY20633@twin.jikos.cz>

On Wed, Jun 15, 2022 at 03:31:30PM +0200, David Sterba wrote:
> On Wed, Jun 15, 2022 at 03:47:51PM +0300, Nikolay Borisov wrote:
> > > +
> > > +	return sysfs_emit(buf,
> > > +		"commits %llu\n"
> > > +		"last_commit_dur %llu ms\n"
> > > +		"max_commit_dur %llu ms\n"
> > > +		"total_commit_dur %llu ms\n",
> > > +		fs_info->commit_stats.commit_counter,
> > > +		fs_info->commit_stats.last_commit_dur / NSEC_PER_MSEC,
> > > +		fs_info->commit_stats.max_commit_dur / NSEC_PER_MSEC,
> > > +		fs_info->commit_stats.total_commit_dur / NSEC_PER_MSEC);
> > > +}
> > > +
> > > +static ssize_t btrfs_commit_stats_store(struct kobject *kobj,
> > > +						struct kobj_attribute *a,
> > > +						const char *buf, size_t len)
> > > +{
> > 
> > Is there really value in being able to zero out the current stats?
> 
> I think it makes sense for the max commit time, one might want to track
> that for some workload and then reset. For the other it can go both
> ways, eg. a monitoring tool saves the stats completely and resets them.
> OTOH long term stats would be lost in case there's more than one
> application reading it.

As far as I can see, our options are roughly:
1. separate files per stat, only max file has clear
2. clear only max when clearing the joint file
3. clear everything in the joint file (current patch)
4. clear bitmap to control which fields to clear

1 seems the clearest, but is sort of messy in terms of spamming lots of
files. There can be a "1b" variant which is one file with
count/total/last and a second file with max (rather than one each for all
four). 2 is a bit weird, just due to asymmetry. The "multiple separate
clearers" problem Dave came up with seems  serious for 3: it means if I
want to clear max and you want to clear total, we might make each other
lose data. 4 would work around that, but is an untuitive interface.

One other reason clearing total could be good is if we are counting in
nanoseconds, overflow becomes a non-trivial risk. For this reason, I
think I vote for 1 (separate files), but 2 (only clear max in a single
file) seems like a decent compromise. 4 feels overengineered, but is
kind of a souped-up version of 2.

  reply	other threads:[~2022-06-15 21:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14 22:22 [PATCH v2 0/2] btrfs: Expose BTRFS commit stats through sysfs Ioannis Angelakopoulos
2022-06-14 22:22 ` [PATCH v2 1/2] btrfs: Add the capability of getting commit stats in BTRFS Ioannis Angelakopoulos
2022-06-15 12:49   ` Nikolay Borisov
2022-06-21 14:47   ` David Sterba
2022-06-14 22:22 ` [PATCH v2 2/2] btrfs: Expose the BTRFS commit stats through sysfs Ioannis Angelakopoulos
2022-06-15 12:47   ` Nikolay Borisov
2022-06-15 13:31     ` David Sterba
2022-06-15 21:32       ` Boris Burkov [this message]
2022-06-16 15:24         ` Nikolay Borisov
2022-06-16 16:53           ` Boris Burkov
2022-06-20 20:37             ` Ioannis Angelakopoulos
2022-06-21 14:45               ` David Sterba
2022-06-15 20:57   ` kernel test robot
2022-06-15 21:07   ` kernel test robot
2022-06-21 14:49   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YqpQANRnbc4uBmjT@zen \
    --to=boris@bur.io \
    --cc=dsterba@suse.cz \
    --cc=iangelak@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox