public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yang Guo <guoyang2@huawei.com>,
	"Darrick J. Wong" <darrick.wong@oracle.com>
Subject: Re: [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0
Date: Wed, 20 Nov 2019 22:56:44 -0800	[thread overview]
Message-ID: <20191121065644.GA21798@infradead.org> (raw)
In-Reply-To: <20191120210825.GB4614@dread.disaster.area>

> +static void
>  xfs_sb_mod8(
>  	uint8_t			*field,
>  	int8_t			delta)
>  {
>  	int8_t			counter = *field;
>  
> +	if (!delta)
> +		return;
>  	counter += delta;
> +	ASSERT(counter >= 0);
>  	*field = counter;
>  }

I'd almost find it easier to keep the != 0 check in the caller, and
in fact also move the assert there and just kill these helpers, e.g.

	if (tp->t_imaxpct_delta != 0) {
		mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta;
		ASSERT(mp->m_sb.sb_imax_pct >= 0);
	}
	if (tp->t_rextsize_delta != 0) {
		mp->m_sb.sb_rextsize += tp->t_rextsize_delta;
		ASSERT(mp->m_sb.sb_rextsize >= 0);
	}

While this is 2 more lines per counter it is a lot more explicit and
easier to follow.

>  	if (idelta) {
> -		error = xfs_mod_icount(mp, idelta);
> -		if (error)
> -			goto out_undo_fdblocks;
> +		percpu_counter_add_batch(&mp->m_icount, idelta,
> +					 XFS_ICOUNT_BATCH);
> +		if (idelta < 0)
> +			ASSERT(__percpu_counter_compare(&mp->m_icount, 0,
> +							XFS_ICOUNT_BATCH) >= 0)

And here I wonder if keeping single use helpers wouldn't have been a
little nicer.  Not that it really matters.

      reply	other threads:[~2019-11-21  6:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 11:29 [PATCH] xfs: optimise xfs_mod_icount/ifree when delta < 0 Shaokun Zhang
2019-11-04 15:25 ` Christoph Hellwig
2019-11-05  3:08   ` Shaokun Zhang
2019-11-04 20:49 ` Dave Chinner
2019-11-05  3:26   ` Shaokun Zhang
2019-11-05  4:03     ` Dave Chinner
2019-11-06  6:00       ` Shaokun Zhang
2019-11-06 21:20         ` Dave Chinner
2019-11-08  5:58           ` Shaokun Zhang
2019-11-15  9:16             ` Shaokun Zhang
2019-11-18  8:12             ` Dave Chinner
2019-11-20 21:08               ` Dave Chinner
2019-11-21  6:56                 ` Christoph Hellwig [this message]

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=20191121065644.GA21798@infradead.org \
    --to=hch@infradead.org \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=guoyang2@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zhangshaokun@hisilicon.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