From: Vlastimil Babka <vbabka@suse.cz>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Sasha Levin <sasha.levin@oracle.com>,
Konstantin Khlebnikov <koct9i@gmail.com>,
Lukas Czerner <lczerner@redhat.com>,
Dave Jones <davej@redhat.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] mm/fs: fix pessimization in hole-punching pagecache
Date: Thu, 03 Jul 2014 15:02:08 +0200 [thread overview]
Message-ID: <53B55450.3060908@suse.cz> (raw)
In-Reply-To: <alpine.LSU.2.11.1407021212060.12131@eggly.anvils>
On 07/02/2014 09:13 PM, Hugh Dickins wrote:
> I wanted to revert my v3.1 commit d0823576bf4b ("mm: pincer in
> truncate_inode_pages_range"), to keep truncate_inode_pages_range()
> in synch with shmem_undo_range(); but have stepped back - a change
> to hole-punching in truncate_inode_pages_range() is a change to
> hole-punching in every filesystem (except tmpfs) that supports it.
>
> If there's a logical proof why no filesystem can depend for its own
> correctness on the pincer guarantee in truncate_inode_pages_range() -
> an instant when the entire hole is removed from pagecache - then let's
> revisit later. But the evidence is that only tmpfs suffered from the
> livelock, and we have no intention of extending hole-punch to ramfs.
> So for now just add a few comments (to match or differ from those in
> shmem_undo_range()), and fix one silliness noticed in d0823576bf4b...
>
> Its "index == start" addition to the hole-punch termination test was
> incomplete: it opened a way for the end condition to be missed, and the
> loop go on looking through the radix_tree, all the way to end of file.
> Fix that pessimization by resetting index when detected in inner loop.
>
> Note that it's actually hard to hit this case, without the obsessive
> concurrent faulting that trinity does: normally all pages are removed
> in the initial trylock_page() pass, and this loop finds nothing to do.
> I had to "#if 0" out the initial pass to reproduce bug and test fix.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Konstantin Khlebnikov <koct9i@gmail.com>
> Cc: Lukas Czerner <lczerner@redhat.com>
> Cc: Dave Jones <davej@redhat.com>
> ---
>
> mm/truncate.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> --- 3.16-rc3/mm/truncate.c 2014-06-08 11:19:54.000000000 -0700
> +++ linux/mm/truncate.c 2014-07-02 03:36:05.972553533 -0700
> @@ -355,14 +355,16 @@ void truncate_inode_pages_range(struct a
> for ( ; ; ) {
> cond_resched();
> if (!pagevec_lookup_entries(&pvec, mapping, index,
> - min(end - index, (pgoff_t)PAGEVEC_SIZE),
> - indices)) {
> + min(end - index, (pgoff_t)PAGEVEC_SIZE), indices)) {
> + /* If all gone from start onwards, we're done */
> if (index == start)
> break;
> + /* Otherwise restart to make sure all gone */
> index = start;
> continue;
> }
> if (index == start && indices[0] >= end) {
> + /* All gone out of hole to be punched, we're done */
> pagevec_remove_exceptionals(&pvec);
> pagevec_release(&pvec);
> break;
> @@ -373,8 +375,11 @@ void truncate_inode_pages_range(struct a
>
> /* We rely upon deletion not changing page->index */
> index = indices[i];
> - if (index >= end)
> + if (index >= end) {
> + /* Restart punch to make sure all gone */
> + index = start - 1;
> break;
> + }
>
> if (radix_tree_exceptional_entry(page)) {
> clear_exceptional_entry(mapping, index, page);
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Vlastimil Babka <vbabka@suse.cz>
To: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Sasha Levin <sasha.levin@oracle.com>,
Konstantin Khlebnikov <koct9i@gmail.com>,
Lukas Czerner <lczerner@redhat.com>,
Dave Jones <davej@redhat.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] mm/fs: fix pessimization in hole-punching pagecache
Date: Thu, 03 Jul 2014 15:02:08 +0200 [thread overview]
Message-ID: <53B55450.3060908@suse.cz> (raw)
In-Reply-To: <alpine.LSU.2.11.1407021212060.12131@eggly.anvils>
On 07/02/2014 09:13 PM, Hugh Dickins wrote:
> I wanted to revert my v3.1 commit d0823576bf4b ("mm: pincer in
> truncate_inode_pages_range"), to keep truncate_inode_pages_range()
> in synch with shmem_undo_range(); but have stepped back - a change
> to hole-punching in truncate_inode_pages_range() is a change to
> hole-punching in every filesystem (except tmpfs) that supports it.
>
> If there's a logical proof why no filesystem can depend for its own
> correctness on the pincer guarantee in truncate_inode_pages_range() -
> an instant when the entire hole is removed from pagecache - then let's
> revisit later. But the evidence is that only tmpfs suffered from the
> livelock, and we have no intention of extending hole-punch to ramfs.
> So for now just add a few comments (to match or differ from those in
> shmem_undo_range()), and fix one silliness noticed in d0823576bf4b...
>
> Its "index == start" addition to the hole-punch termination test was
> incomplete: it opened a way for the end condition to be missed, and the
> loop go on looking through the radix_tree, all the way to end of file.
> Fix that pessimization by resetting index when detected in inner loop.
>
> Note that it's actually hard to hit this case, without the obsessive
> concurrent faulting that trinity does: normally all pages are removed
> in the initial trylock_page() pass, and this loop finds nothing to do.
> I had to "#if 0" out the initial pass to reproduce bug and test fix.
>
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Cc: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Konstantin Khlebnikov <koct9i@gmail.com>
> Cc: Lukas Czerner <lczerner@redhat.com>
> Cc: Dave Jones <davej@redhat.com>
> ---
>
> mm/truncate.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> --- 3.16-rc3/mm/truncate.c 2014-06-08 11:19:54.000000000 -0700
> +++ linux/mm/truncate.c 2014-07-02 03:36:05.972553533 -0700
> @@ -355,14 +355,16 @@ void truncate_inode_pages_range(struct a
> for ( ; ; ) {
> cond_resched();
> if (!pagevec_lookup_entries(&pvec, mapping, index,
> - min(end - index, (pgoff_t)PAGEVEC_SIZE),
> - indices)) {
> + min(end - index, (pgoff_t)PAGEVEC_SIZE), indices)) {
> + /* If all gone from start onwards, we're done */
> if (index == start)
> break;
> + /* Otherwise restart to make sure all gone */
> index = start;
> continue;
> }
> if (index == start && indices[0] >= end) {
> + /* All gone out of hole to be punched, we're done */
> pagevec_remove_exceptionals(&pvec);
> pagevec_release(&pvec);
> break;
> @@ -373,8 +375,11 @@ void truncate_inode_pages_range(struct a
>
> /* We rely upon deletion not changing page->index */
> index = indices[i];
> - if (index >= end)
> + if (index >= end) {
> + /* Restart punch to make sure all gone */
> + index = start - 1;
> break;
> + }
>
> if (radix_tree_exceptional_entry(page)) {
> clear_exceptional_entry(mapping, index, page);
>
next prev parent reply other threads:[~2014-07-03 13:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 19:09 [PATCH 1/3] Revert "shmem: fix faulting into a hole while it's punched" Hugh Dickins
2014-07-02 19:09 ` Hugh Dickins
2014-07-02 19:11 ` [PATCH 2/3] shmem: fix faulting into a hole while it's punched, take 2 Hugh Dickins
2014-07-02 19:11 ` Hugh Dickins
2014-07-03 15:37 ` Vlastimil Babka
2014-07-03 15:37 ` Vlastimil Babka
2014-07-03 19:14 ` Hugh Dickins
2014-07-03 19:14 ` Hugh Dickins
2014-07-02 19:13 ` [PATCH 3/3] mm/fs: fix pessimization in hole-punching pagecache Hugh Dickins
2014-07-02 19:13 ` Hugh Dickins
2014-07-03 13:02 ` Vlastimil Babka [this message]
2014-07-03 13:02 ` Vlastimil Babka
2014-07-03 12:54 ` [PATCH 1/3] Revert "shmem: fix faulting into a hole while it's punched" Vlastimil Babka
2014-07-03 12:54 ` Vlastimil Babka
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=53B55450.3060908@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=davej@redhat.com \
--cc=hughd@google.com \
--cc=koct9i@gmail.com \
--cc=lczerner@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sasha.levin@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.