mm: speculative get_page
mm/vmscan.c int remove_mapping(struct address_space · line 386
Quoted 11 lines · Nick Piggin
mm/vmscan.c +2
-0@@ -380,6 +380,8 @@ int remove_mapping(struct address_spaceif (!mapping)return 0 ;/* truncate got there first */ +SetPageNoNewRefs (page); +smp_wmb ();write_lock_irq (&mapping->tree_lock);
Is it enough?
PG_nonewrefs could be already set by another add_to_page_cache()/remove_mapping(), and it will be cleared when we take ->tree_lock. For example:
CPU_0 CPU_1 CPU_3
add_to_page_cache:
SetPageNoNewRefs();
write_lock_irq(->tree_lock);
...
write_unlock_irq(->tree_lock);
remove_mapping:
SetPageNoNewRefs();
ClearPageNoNewRefs();
write_lock_irq(->tree_lock);
check page_count()
page_cache_get_speculative:
increment page_count()
no PG_nonewrefs => returnOleg.
Quoted 15 lines · Oleg Nesterov
mm/vmscan.c int remove_mapping(struct address_space · line 386
Quoted 11 lines · Nick Piggin
mm/vmscan.c +2
-0@@ -380,6 +380,8 @@ int remove_mapping(struct address_spaceif (!mapping)return 0 ;/* truncate got there first */ +SetPageNoNewRefs (page); +smp_wmb ();write_lock_irq (&mapping->tree_lock);Is it enough?
Quoted 2 lines
PG_nonewrefscould be already set by another add_to_page_cache()/remove_mapping(), and it will be cleared when we take ->tree_lock.
Isn't the page locked when calling remove_mapping()? It looks like SetPageNoNewRefs & ClearPageNoNewRefs are called in safe places. Either the page is locked, or it's newly allocated. I could have missed something, though.
Quoted 8 lines
For example:
CPU_0CPU_1CPU_3
add_to_page_cache:SetPageNoNewRefs(); write_lock_irq(->tree_lock);
SetPageLocked(page);
Quoted 18 lines
...
write_unlock_irq(->tree_lock);
remove_mapping:
SetPageNoNewRefs();
ClearPageNoNewRefs();
write_lock_irq(->tree_lock);
check page_count()
page_cache_get_speculative:
increment page_count()
no PG_nonewrefs => returnQuoted 1 line
Oleg.
Shaggy
Signature · 8 lines
David Kleikamp IBM Linux Technology Center -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 17 lines · Dave Kleikamp
Quoted 15 lines · Oleg Nesterov
mm/vmscan.c int remove_mapping(struct address_space · line 386
Quoted 11 lines · Nick Piggin
mm/vmscan.c +2
-0@@ -380,6 +380,8 @@ int remove_mapping(struct address_spaceif (!mapping)return 0 ;/* truncate got there first */ +SetPageNoNewRefs (page); +smp_wmb ();write_lock_irq (&mapping->tree_lock);Is it enough?
Quoted 7 lines
Quoted 2 lines
PG_nonewrefscould be already set by another add_to_page_cache()/remove_mapping(), and it will be cleared when we take ->tree_lock.Isn't the page locked when calling
remove_mapping()? It looks like SetPageNoNewRefs & ClearPageNoNewRefs are called in safe places. Either the page is locked, or it's newly allocated. I could have missed something, though.
No, I think it is I who missed something, thanks.
Oleg.
Quoted 9 lines · Oleg Nesterov
Quoted 4 lines · Dave Kleikamp
Isn't the page locked when calling
remove_mapping()? It looks like SetPageNoNewRefs & ClearPageNoNewRefs are called in safe places. Either the page is locked, or it's newly allocated. I could have missed something, though.No, I think it is I who missed something, thanks.
Yeah, SetPageNoNewRefs is indeed called only under PageLocked or for newly allocated pages. I should make a note about that, as it isn't immediately clear.
Thanks
Signature · 8 lines
SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>