From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Hugh Dickins <hugh.dickins@tiscali.co.uk>,
Mel Gorman <mel@csn.ul.ie>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [rfc patch 3/3] mm: munlock COW pages on truncation unmap
Date: Sat, 3 Oct 2009 22:56:55 +0900 [thread overview]
Message-ID: <2f11576a0910030656l73c9811w18e0f224fb3d98af@mail.gmail.com> (raw)
In-Reply-To: <20091002233837.GA3638@cmpxchg.org>
>> Umm..
>> I haven't understand this.
>>
>> (1) unmap_mapping_range() is called twice.
>>
>> unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
>> truncate_inode_pages(mapping, new);
>> unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
>>
>> (2) PG_mlock is turned on from mlock() and vmscan.
>> (3) vmscan grab anon_vma, but mlock don't grab anon_vma.
>
> You are right, I was so focused on the LRU side that I missed an
> obvious window here: an _explicit_ mlock can still happen between the
> PG_mlocked clearing section and releasing the page.
>
> If we race with it, the put_page() in __mlock_vma_pages_range() might
> free the freshly mlocked page.
>
>> (4) after truncate_inode_pages(), we don't need to think vs-COW, because
>> find_get_page() never success. but first unmap_mapping_range()
>> have vs-COW racing.
>
> Yes, we can race with COW breaking, but I can not see a problem there.
> It clears the old page's mlock, but also with an atomic
> TestClearPageMlocked(). And the new page is mapped and mlocked under
> pte lock and only if we didn't clear the pte in the meantime.
Ah, You are right.
>> So, Is anon_vma grabbing really sufficient?
>
> No, the explicit mlocking race exists, I think.
>
>> Or, you intent to the following?
>>
>> unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 0);
>> truncate_inode_pages(mapping, new);
>> unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
>
> As mentioned above, I don't see how it would make a difference.
Yes, sorry. please forget this.
>> > @@ -544,6 +544,13 @@ redo:
>> > */
>> > lru = LRU_UNEVICTABLE;
>> > add_page_to_unevictable_list(page);
>> > + /*
>> > + * See the TestClearPageMlocked() in zap_pte_range():
>> > + * if a racing unmapper did not see the above setting
>> > + * of PG_lru, we must see its clearing of PG_locked
>> > + * and move the page back to the evictable list.
>> > + */
>> > + smp_mb();
>> > }
>>
>> add_page_to_unevictable() have a spin lock. Why do we need additionl
>> explicit memory barrier?
>
> It sets PG_lru under spinlock and tests PG_mlocked after the unlock.
> The following sections from memory-barriers.txt made me nervous:
>
> (5) LOCK operations.
>
> This acts as a one-way permeable barrier. It guarantees that all memory
> operations after the LOCK operation will appear to happen after the LOCK
> operation with respect to the other components of the system.
>
> (6) UNLOCK operations.
>
> This also acts as a one-way permeable barrier. It guarantees that all
> memory operations before the UNLOCK operation will appear to happen before
> the UNLOCK operation with respect to the other components of the system.
>
> Memory operations that occur after an UNLOCK operation may appear to
> happen before it completes.
>
> So the only garuantee this gives us is that both PG_lru setting and
> PG_mlocked testing happen after LOCK and PG_lru setting finishes
> before UNLOCK, no? I wanted to make sure this does not happen:
>
> LOCK, test PG_mlocked, set PG_lru, UNLOCK
>
> I don't know whether there is a data dependency between those two
> operations. They go to the same word, but I could also imagine
> setting one bit is independent of reading another one. Humm. Help.
Ahh, Yes! you are right.
We really need this barrier.
However, I think this issue doesn't depend on zap_pte_range patch.
Other TestClearPageMlocked(page) caller have the same problem, because
putback_lru_page() doesn't have any exclusion, right?
--
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>
next prev parent reply other threads:[~2009-10-03 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-30 21:09 [rfc patch 1/3] mm: always pass mapping in zap_details Johannes Weiner
2009-09-30 21:09 ` [rfc patch 2/3] mm: serialize truncation unmap against try_to_unmap() Johannes Weiner
2009-09-30 21:09 ` [rfc patch 3/3] mm: munlock COW pages on truncation unmap Johannes Weiner
2009-10-02 2:40 ` KOSAKI Motohiro
2009-10-02 23:38 ` Johannes Weiner
2009-10-03 13:56 ` KOSAKI Motohiro [this message]
2009-10-05 19:32 ` Johannes Weiner
2009-10-06 1:11 ` KOSAKI Motohiro
2009-10-06 7:44 ` KOSAKI Motohiro
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=2f11576a0910030656l73c9811w18e0f224fb3d98af@mail.gmail.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hannes@cmpxchg.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
/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).