Re: [patch 1/2] mm: speculative get_page

Oleg Nesterov
2006-08-01T15:08:46Z

Nick Piggin wrote:
>
> --- linux-2.6.orig/mm/vmscan.c
> +++ linux-2.6/mm/vmscan.c
> @@ -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.