From: Matthew Wilcox <willy@infradead.org>
To: David Stevens <stevensd@chromium.org>
Cc: linux-mm@kvack.org, Peter Xu <peterx@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
Yang Shi <shy828301@gmail.com>,
David Hildenbrand <david@redhat.com>,
Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/khugepaged: skip shmem with userfaultfd
Date: Mon, 6 Feb 2023 14:25:46 +0000 [thread overview]
Message-ID: <Y+EN6oDi5k5L9651@casper.infradead.org> (raw)
In-Reply-To: <20230206112856.1802547-1-stevensd@google.com>
On Mon, Feb 06, 2023 at 08:28:56PM +0900, David Stevens wrote:
> @@ -1747,6 +1748,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
> XA_STATE_ORDER(xas, &mapping->i_pages, start, HPAGE_PMD_ORDER);
> int nr_none = 0, result = SCAN_SUCCEED;
> bool is_shmem = shmem_file(file);
> + bool i_mmap_locked = false;
you don't need this ...
> + * While iterating, we may drop the page cache lock multiple times. It
> + * is safe to replace pages in the page cache with hpage while doing so
> + * because nobody is able to map or otherwise access the content of
> + * hpage until we unlock it. However, we cannot insert hpage into empty
> + * indicies until we know we won't have to drop the page cache lock
"indices".
> @@ -1967,6 +1974,46 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
> put_page(page);
> goto xa_unlocked;
> }
> +
> + if (nr_none) {
> + struct vm_area_struct *vma;
> + int nr_none_check = 0;
> +
> + xas_unlock_irq(&xas);
> + i_mmap_lock_read(mapping);
> + i_mmap_locked = true;
> + xas_lock_irq(&xas);
> +
> + xas_set(&xas, start);
> + for (index = start; index < end; index++) {
> + if (!xas_next(&xas))
> + nr_none_check++;
> + }
> +
> + if (nr_none != nr_none_check) {
> + result = SCAN_PAGE_FILLED;
... you can unlock the i_mmap_lock here before the goto.
I think you need to add a case in madvise_collapse_errno(). It should
probably return -EBUSY, I would think?
next prev parent reply other threads:[~2023-02-06 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 11:28 David Stevens
2023-02-06 14:25 ` Matthew Wilcox [this message]
2023-02-06 19:01 ` Matthew Wilcox
2023-02-06 20:52 ` Peter Xu
2023-02-06 21:50 ` Matthew Wilcox
2023-02-07 1:37 ` David Stevens
2023-02-07 2:29 ` Matthew Wilcox
2023-02-07 4:14 ` David Stevens
2023-02-06 21:02 ` Peter Xu
2023-02-07 3:56 ` David Stevens
2023-02-07 16:34 ` Peter Xu
2023-02-08 2:42 ` David Stevens
2023-02-08 17:24 ` Peter Xu
2023-02-09 5:10 ` David Stevens
2023-02-09 18:50 ` Peter Xu
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=Y+EN6oDi5k5L9651@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=stevensd@chromium.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