From: Hugh Dickins <hugh@veritas.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-mm@kvack.org
Subject: Re: s390's PageSwapCache test
Date: Sat, 2 Aug 2008 19:44:08 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0808021924450.9727@blonde.site> (raw)
In-Reply-To: <1217694031.22955.14.camel@localhost>
On Sat, 2 Aug 2008, Martin Schwidefsky wrote:
> On Sat, 2008-08-02 at 10:05 +0100, Hugh Dickins wrote:
> > I'm slightly bothered by that PageSwapCache() test you've just added
> > in page_remove_rmap(), before s390's page_test_dirty():
> >
> > if ((!PageAnon(page) || PageSwapCache(page)) &&
> > page_test_dirty(page)) {
> > page_clear_dirty(page);
> > set_page_dirty(page);
> > }
> >
> > It's not wrong; but if it's necessary, then I need to understand why;
> > and if it's unnecessary, then we'd do better to remove it (optimizing
> > your optimization a little).
> ...
> Hmm, what about the following sequence:
> 1) a page is added to the swap
> 2) the page is dirtied again
> 3) the process forks
> 4) the first process does an mlock
> 5) vmscan succeeds in replacing the pte of the second process with a
> swap entry but fails for the pte of the first process.
> 6) the first process exists.
exits
>
> If the PageSwapCache() check is missing zap_pte_range() will drop the
> last pte for the page but won't transfer the dirty bit.
> Wouldn't that break?
Yes, it took me a while to understand, but you are right. I was
blinkered, thinking always of page_remove_rmap called by zap_pte_range,
forgetting page_remove_rmap called by try_to_unmap_one i.e. vmscan.
Your example is dealt with on the non-s390 arches by try_to_unmap_one's
if (pte_dirty(pteval))
set_page_dirty(page);
but s390 needs something else: and since you can't do it until the
last mapping is removed, you're stuck with detecting the possibility
of this case by testing PageSwapCache in there.
It's a pity that so often it's irrelevant, but I can't offhand think
of a better answer, and it would only be a small optimization to an
already non-optimal path.
Good thinking, Martin, and thank you for enlightening me:
when I'm next in patch mode I'll add a comment there on it.
Hugh
--
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>
prev parent reply other threads:[~2008-08-02 18:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-02 9:05 Hugh Dickins
2008-08-02 16:20 ` Martin Schwidefsky
2008-08-02 18:44 ` Hugh Dickins [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=Pine.LNX.4.64.0808021924450.9727@blonde.site \
--to=hugh@veritas.com \
--cc=linux-mm@kvack.org \
--cc=schwidefsky@de.ibm.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