From: Matthew Wilcox <willy@infradead.org>
To: 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 06:15:45 -0800 [thread overview]
Message-ID: <20190107141545.GX6310@bombadil.infradead.org> (raw)
In-Reply-To: <20190107130239.3417-1-vincent.whitchurch@axis.com>
On Mon, Jan 07, 2019 at 02:02:39PM +0100, Vincent Whitchurch wrote:
> +++ b/Documentation/sysctl/vm.txt
> @@ -222,6 +222,10 @@ To increase the number of objects freed by this operation, the user may run
> number of dirty objects on the system and create more candidates to be
> dropped.
>
> +By default, pages which are currently mapped are not dropped from the
> +pagecache. If you want to unmap and drop these pages too, echo 9 or 11 instead
> +of 1 or 3 respectively (set bit 4).
Typically we number bits from 0, so this would be bit 3, not 4. I do see
elsewhere in this file somebody else got this wrong:
: with your system. To disable them, echo 4 (bit 3) into drop_caches.
but that should also be fixed.
> +static int __invalidate_inode_page(struct page *page, bool unmap)
> +{
> + struct address_space *mapping = page_mapping(page);
> + if (!mapping)
> + return 0;
> + if (PageDirty(page) || PageWriteback(page))
> + return 0;
> + if (page_mapped(page)) {
> + if (!unmap)
> + return 0;
> + if (!try_to_unmap(page, TTU_IGNORE_ACCESS))
> + return 0;
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 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.
next prev parent reply other threads:[~2019-01-07 14:15 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 [this message]
2019-01-07 19:25 ` Dave Hansen
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=20190107141545.GX6310@bombadil.infradead.org \
--to=willy@infradead.org \
--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 \
/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).