linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Vratislav Bendel <vbendel@redhat.com>
Cc: linux-xfs@vger.kernel.org, Brian Foster <bfoster@redhat.com>,
	linux-kernel@vger.kernel.org, djwong@kernel.org
Subject: Re: [PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic
Date: Fri, 2 Mar 2018 08:36:03 -0800	[thread overview]
Message-ID: <20180302163603.GQ19312@magnolia> (raw)
In-Reply-To: <20180301224800.GI12763@magnolia>

On Thu, Mar 01, 2018 at 02:48:00PM -0800, Darrick J. Wong wrote:
> On Wed, Feb 28, 2018 at 04:49:51PM +0100, Vratislav Bendel wrote:
> > The function xfs_buftarg_isolate() used by xfs buffer schrinkers 
> > to determine whether a buffer should be isolated and disposed 
> > from LRU list, has inverted logic.
> > 
> > Excerpt from xfs_buftarg_isolate():
> >         /*
> >          * Decrement the b_lru_ref count unless the value is already
> >          * zero. If the value is already zero, we need to reclaim the
> >          * buffer, otherwise it gets another trip through the LRU.
> >          */
> >         if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) {
> >                 spin_unlock(&bp->b_lock);
> >                 return LRU_ROTATE;
> >         }
> > 
> > However, as per documentation, atomic_add_unless() returns _zero_
> > if the atomic value was originally equal to the specified *unsless* value.
> > 
> > Ultimately causing a xfs_buffer with ->b_lru_ref == 0, to take another 
> > trip around LRU, while isolating buffers with non-zero b_lru_ref.
> > 
> > Signed-off-by: Vratislav Bendel <vbendel@redhat.com>
> > CC: Brian Foster <bfoster@redhat.com>
> 
> Looks ok, will test...
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

This tests ok, but please address Brian and Luis' comments before I put
this in the upstream tream.

--D

> --D
> 
> > ---
> >  fs/xfs/xfs_buf.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > index d1da2ee9e6db..ac669a10c62f 100644
> > --- a/fs/xfs/xfs_buf.c
> > +++ b/fs/xfs/xfs_buf.c
> > @@ -1708,7 +1708,7 @@ xfs_buftarg_isolate(
> >  	 * zero. If the value is already zero, we need to reclaim the
> >  	 * buffer, otherwise it gets another trip through the LRU.
> >  	 */
> > -	if (!atomic_add_unless(&bp->b_lru_ref, -1, 0)) {
> > +	if (atomic_add_unless(&bp->b_lru_ref, -1, 0)) {
> >  		spin_unlock(&bp->b_lock);
> >  		return LRU_ROTATE;
> >  	}
> > -- 
> > 2.14.3
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-03-02 16:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 15:49 [PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic Vratislav Bendel
2018-02-28 19:08 ` Luis R. Rodriguez
2018-03-01 17:39 ` Brian Foster
2018-03-01 22:48 ` Darrick J. Wong
2018-03-02 16:36   ` Darrick J. Wong [this message]
2018-03-05 10:19     ` Vratislav Bendel
2018-03-05 18:52       ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2018-03-06 10:26 Vratislav Bendel
2018-03-07  0:34 ` Darrick J. Wong
2018-03-08  8:08 ` Christoph Hellwig

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=20180302163603.GQ19312@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.com \
    --cc=djwong@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=vbendel@redhat.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;
as well as URLs for NNTP newsgroup(s).