Skip to contentSkip to conversation

mm: speculative get_page

PATCH Oleg Nesterov 3 participants 4 messages Aug 1, 2006 Memory management

lore
Share & tools
lore
#0 lore raw

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_space 
 	if (!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 => return

Oleg.

#1 lore raw
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_space 
 	if (!mapping)
 		return 0;		/* truncate got there first */
 
+	SetPageNoNewRefs(page);
+	smp_wmb();
 	write_lock_irq(&mapping->tree_lock);
 

Is it enough?

Quoted 2 lines

PG_nonewrefs could 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_0 CPU_1 CPU_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 => return
Quoted 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>
#2 lore raw
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_space 
 	if (!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_nonewrefs could 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.

#3 lore raw
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>