From: Greg KH <greg@kroah.com>
To: Alex Lyakas <alex@zadara.com>
Cc: linux-xfs@vger.kernel.org, stable@vger.kernel.org,
vbendel@redhat.com, bfoster@redhat.com, hch@lst.de,
darrick.wong@oracle.com
Subject: Re: [STABLE-PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic
Date: Mon, 4 Nov 2019 12:02:37 +0100 [thread overview]
Message-ID: <20191104110237.GD1945210@kroah.com> (raw)
In-Reply-To: <1572535975-32634-1-git-send-email-alex@zadara.com>
On Thu, Oct 31, 2019 at 05:32:55PM +0200, Alex Lyakas wrote:
> From: Vratislav Bendel <vbendel@redhat.com>
>
> [upstream commit 19957a181608d25c8f4136652d0ea00b3738972d]
>
> Due to an inverted logic mistake in xfs_buftarg_isolate()
> the xfs_buffers with zero b_lru_ref will take another trip
> around LRU, while isolating buffers with non-zero b_lru_ref.
>
> Additionally those isolated buffers end up right back on the LRU
> once they are released, because b_lru_ref remains elevated.
>
> Fix that circuitous route by leaving them on the LRU
> as originally intended.
>
> [Additional description for the issue]
>
> Due to this issue, buffers will spend one cycle less in
> the LRU than intended. If we initialize b_lru_ref to X, we intend the
> buffer to survive X shrinker calls, and on the X+1'th call to be taken
> off the LRU (and maybe freed). But with this issue, the buffer will be
> taken off the LRU and immediately re-added back. But this will happen
> X-1 times, because on the X'th time the b_lru_ref will be 0, and the
> buffer will not be re-added to the LRU. So the buffer will survive X-1
> shrinker calls and not X as intended.
>
> Furthermore, if somehow we end up with the buffer sitting on the LRU
> and having b_lru_ref==0, this buffer will never be taken off the LRU,
> due to the bug. Not sure that this can happen, because by default
> b_lru_ref is set to 1.
>
> This issue existed since the introduction of lru in XFS buffer cache
> in commit
> "430cbeb86fdcbbdabea7d4aa65307de8de425350 xfs: add a lru to the XFS buffer cache".
>
> However, the integration with the "list_lru" insfrastructure was done in kernel 3.12,
> in commit
> "e80dfa19976b884db1ac2bc5d7d6ca0a4027bd1c xfs: convert buftarg LRU to generic code"
>
> Therefore this patch is relevant for all kernels from 3.12 to 4.15
> (upstream fix was made in 4.16).
>
> Signed-off-by: Alex Lyakas <alex@zadara.com>
> Signed-off-by: Vratislav Bendel <vbendel@redhat.com>
> Reviewed-by: Brian Foster <bfoster@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> (cherry picked from commit 19957a181608d25c8f4136652d0ea00b3738972d)
> ---
> fs/xfs/xfs_buf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Now queued up, thanks.
greg k-h
prev parent reply other threads:[~2019-11-04 11:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 15:32 [STABLE-PATCH] xfs: Correctly invert xfs_buftarg LRU isolation logic Alex Lyakas
2019-11-04 11:02 ` Greg KH [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=20191104110237.GD1945210@kroah.com \
--to=greg@kroah.com \
--cc=alex@zadara.com \
--cc=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@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).