From: Dave Hansen <dave.hansen@intel.com>
To: Matthew Wilcox <willy@infradead.org>,
Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, mcgrof@kernel.org,
keescook@chromium.org, corbet@lwn.net, linux-doc@vger.kernel.org,
Vincent Whitchurch <rabinv@axis.com>
Subject: Re: [PATCH] drop_caches: Allow unmapping pages
Date: Mon, 7 Jan 2019 11:25:16 -0800 [thread overview]
Message-ID: <67dac226-00ca-dd0a-800e-0867e12d3ad5@intel.com> (raw)
In-Reply-To: <20190107141545.GX6310@bombadil.infradead.org>
On 1/7/19 6:15 AM, Matthew Wilcox wrote:
> You're going to get data corruption doing this. try_to_unmap_one()
> does:
>
> /* Move the dirty bit to the page. Now the pte is gone. */
> if (pte_dirty(pteval))
> set_page_dirty(page);
>
> so PageDirty() can be false above, but made true by calling
> try_to_unmap().
I don't think that PageDirty() check is _required_ for correctness. You
can always safely try_to_unmap() no matter the state of the PTE. We
can't lock out the hardware from setting the Dirty bit, ever.
It's also just fine to unmap PageDirty() pages, as long as when the PTE
is created, we move the dirty bit from the PTE into the 'struct page'
(which try_to_unmap() does, as you noticed).
> I also think the way you've done this is expedient at the cost of
> efficiency and layering violations. I think you should first tear
> down the mappings of userspace processes (which will reclaim a lot
> of pages allocated to page tables), then you won't need to touch the
> invalidate_inode_pages paths at all.
By "tear down the mappings", do you mean something analogous to munmap()
where the VMA goes away? Or madvise(MADV_DONTNEED) where the PTE is
destroyed but the VMA remains?
Last time I checked, we only did free_pgtables() when tearing down VMAs,
but not for pure unmappings like reclaim or MADV_DONTNEED. I've thought
it might be fun to make a shrinker that scanned page tables looking for
zero'd pages, but I've never run into a system where empty page table
pages were actually causing a noticeable problem.
next prev parent reply other threads:[~2019-01-07 19:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 13:02 [PATCH] drop_caches: Allow unmapping pages Vincent Whitchurch
2019-01-07 14:15 ` Matthew Wilcox
2019-01-07 19:25 ` Dave Hansen [this message]
2019-01-07 19:37 ` Matthew Wilcox
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=67dac226-00ca-dd0a-800e-0867e12d3ad5@intel.com \
--to=dave.hansen@intel.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=rabinv@axis.com \
--cc=vincent.whitchurch@axis.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).