Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: track current commit duration in commit_stats
Date: Fri, 25 Apr 2025 13:42:49 +0200	[thread overview]
Message-ID: <20250425114249.GD31681@suse.cz> (raw)
In-Reply-To: <6cb65fc2544863eb6b3ca48b094cf7004e06af69.1745538939.git.boris@bur.io>

On Thu, Apr 24, 2025 at 04:56:34PM -0700, Boris Burkov wrote:
> When debugging/detecting outlier commit stalls, having an indicator that
> we are currently in a long commit critical section can be very useful.
> Extend the commit_stats sysfs file to also include the current commit
> critical section duration.
> 
> Since this requires storing the last commit start time, use that rather
> than a separate stack variable for storing the finished commit durations
> as well.
> 
> Signed-off-by: Boris Burkov <boris@bur.io>

Reviewed-by: David Sterba <dsterba@suse.com>

> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -1138,13 +1138,21 @@ static ssize_t btrfs_commit_stats_show(struct kobject *kobj,
>  				       struct kobj_attribute *a, char *buf)
>  {
>  	struct btrfs_fs_info *fs_info = to_fs_info(kobj);
> +	u64 now = ktime_get_ns();
> +	u64 start_time = fs_info->commit_stats.start_time;
> +	u64 pending = 0;
> +
> +	if (start_time)
> +		pending = now - start_time;
>  
>  	return sysfs_emit(buf,
>  		"commits %llu\n"
> +		"cur_commit_ms %llu\n"
>  		"last_commit_ms %llu\n"
>  		"max_commit_ms %llu\n"
>  		"total_commit_ms %llu\n",

This ordering looks logical, the presence of order should not be assumed
by applications, this is line oriented so a grep should always work.

>  		fs_info->commit_stats.commit_count,
> +		div_u64(pending, NSEC_PER_MSEC),
>  		div_u64(fs_info->commit_stats.last_commit_dur, NSEC_PER_MSEC),
>  		div_u64(fs_info->commit_stats.max_commit_dur, NSEC_PER_MSEC),
>  		div_u64(fs_info->commit_stats.total_commit_dur, NSEC_PER_MSEC));

  reply	other threads:[~2025-04-25 11:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24 23:56 [PATCH] btrfs: track current commit duration in commit_stats Boris Burkov
2025-04-25 11:42 ` David Sterba [this message]
2025-04-29  8:27 ` David Sterba
2025-04-29  9:03   ` 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=20250425114249.GD31681@suse.cz \
    --to=dsterba@suse.cz \
    --cc=boris@bur.io \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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