public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [patch 1/2] mm: speculative get_page
  2006-08-01 19:32 [patch 1/2] mm: speculative get_page Oleg Nesterov
@ 2006-08-01 15:55 ` Dave Kleikamp
  2006-08-01 20:42   ` Oleg Nesterov
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Kleikamp @ 2006-08-01 15:55 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Nick Piggin, Hugh Dickins, Andrew Morton, Andy Whitcroft,
	linux-mm, linux-kernel

On Tue, 2006-08-01 at 23:32 +0400, Oleg Nesterov wrote:
> 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.

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.

>  For example:
> 
> CPU_0					CPU_1					CPU_3
> 
> add_to_page_cache:
> 
>     SetPageNoNewRefs();
>     write_lock_irq(->tree_lock);

      SetPageLocked(page);

>     ...
>     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.

Shaggy
-- 
David Kleikamp
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] mm: speculative get_page
@ 2006-08-01 19:32 Oleg Nesterov
  2006-08-01 15:55 ` Dave Kleikamp
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2006-08-01 19:32 UTC (permalink / raw)
  To: Nick Piggin
  Cc: Hugh Dickins, Andrew Morton, Andy Whitcroft, linux-mm,
	linux-kernel

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] mm: speculative get_page
  2006-08-01 15:55 ` Dave Kleikamp
@ 2006-08-01 20:42   ` Oleg Nesterov
  2006-08-01 23:53     ` Nick Piggin
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2006-08-01 20:42 UTC (permalink / raw)
  To: Dave Kleikamp
  Cc: Nick Piggin, Hugh Dickins, Andrew Morton, Andy Whitcroft,
	linux-mm, linux-kernel

On 08/01, Dave Kleikamp wrote:
>
> On Tue, 2006-08-01 at 23:32 +0400, Oleg Nesterov wrote:
> > 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.
> 
> 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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] mm: speculative get_page
  2006-08-01 20:42   ` Oleg Nesterov
@ 2006-08-01 23:53     ` Nick Piggin
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Piggin @ 2006-08-01 23:53 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Dave Kleikamp, Nick Piggin, Hugh Dickins, Andrew Morton,
	Andy Whitcroft, linux-mm, linux-kernel

Oleg Nesterov wrote:
> On 08/01, Dave Kleikamp wrote:

>>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

-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-01 23:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 19:32 [patch 1/2] mm: speculative get_page Oleg Nesterov
2006-08-01 15:55 ` Dave Kleikamp
2006-08-01 20:42   ` Oleg Nesterov
2006-08-01 23:53     ` Nick Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox