linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: page_idle_get_page() does not need zone_lru_lock
@ 2016-12-06  5:55 Hugh Dickins
  2016-12-07  8:32 ` Vlastimil Babka
  2016-12-07 11:08 ` Vladimir Davydov
  0 siblings, 2 replies; 4+ messages in thread
From: Hugh Dickins @ 2016-12-06  5:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Vladimir Davydov, Pavel Emelyanov, linux-mm

Rechecking PageLRU() after get_page_unless_zero() may have value, but
holding zone_lru_lock around that serves no useful purpose: delete it.

Signed-off-by: Hugh Dickins <hughd@google.com>
---

 mm/page_idle.c |    4 ----
 1 file changed, 4 deletions(-)

--- 4.9-rc8/mm/page_idle.c	2016-10-02 16:24:33.000000000 -0700
+++ linux/mm/page_idle.c	2016-12-05 19:44:32.646625435 -0800
@@ -30,7 +30,6 @@
 static struct page *page_idle_get_page(unsigned long pfn)
 {
 	struct page *page;
-	struct zone *zone;
 
 	if (!pfn_valid(pfn))
 		return NULL;
@@ -40,13 +39,10 @@ static struct page *page_idle_get_page(u
 	    !get_page_unless_zero(page))
 		return NULL;
 
-	zone = page_zone(page);
-	spin_lock_irq(zone_lru_lock(zone));
 	if (unlikely(!PageLRU(page))) {
 		put_page(page);
 		page = NULL;
 	}
-	spin_unlock_irq(zone_lru_lock(zone));
 	return page;
 }
 

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

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

* Re: [PATCH] mm: page_idle_get_page() does not need zone_lru_lock
  2016-12-06  5:55 [PATCH] mm: page_idle_get_page() does not need zone_lru_lock Hugh Dickins
@ 2016-12-07  8:32 ` Vlastimil Babka
  2016-12-07 11:08 ` Vladimir Davydov
  1 sibling, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2016-12-07  8:32 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton; +Cc: Vladimir Davydov, Pavel Emelyanov, linux-mm

On 12/06/2016 06:55 AM, Hugh Dickins wrote:
> Rechecking PageLRU() after get_page_unless_zero() may have value, but
> holding zone_lru_lock around that serves no useful purpose: delete it.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
> 
>  mm/page_idle.c |    4 ----
>  1 file changed, 4 deletions(-)
> 
> --- 4.9-rc8/mm/page_idle.c	2016-10-02 16:24:33.000000000 -0700
> +++ linux/mm/page_idle.c	2016-12-05 19:44:32.646625435 -0800
> @@ -30,7 +30,6 @@
>  static struct page *page_idle_get_page(unsigned long pfn)
>  {
>  	struct page *page;
> -	struct zone *zone;
>  
>  	if (!pfn_valid(pfn))
>  		return NULL;
> @@ -40,13 +39,10 @@ static struct page *page_idle_get_page(u
>  	    !get_page_unless_zero(page))
>  		return NULL;
>  
> -	zone = page_zone(page);
> -	spin_lock_irq(zone_lru_lock(zone));
>  	if (unlikely(!PageLRU(page))) {
>  		put_page(page);
>  		page = NULL;
>  	}
> -	spin_unlock_irq(zone_lru_lock(zone));
>  	return page;
>  }
>  
> 
> --
> 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>
> 

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

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

* Re: [PATCH] mm: page_idle_get_page() does not need zone_lru_lock
  2016-12-06  5:55 [PATCH] mm: page_idle_get_page() does not need zone_lru_lock Hugh Dickins
  2016-12-07  8:32 ` Vlastimil Babka
@ 2016-12-07 11:08 ` Vladimir Davydov
  2016-12-07 13:07   ` Vlastimil Babka
  1 sibling, 1 reply; 4+ messages in thread
From: Vladimir Davydov @ 2016-12-07 11:08 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Minchan Kim, Andrew Morton, Pavel Emelyanov, linux-mm

Hello,

On Mon, Dec 05, 2016 at 09:55:10PM -0800, Hugh Dickins wrote:
> Rechecking PageLRU() after get_page_unless_zero() may have value, but
> holding zone_lru_lock around that serves no useful purpose: delete it.

IIRC this lock/unlock was added on purpose, by request from Minchan. It
serves as a barrier that guarantees that all page fields (specifically
->mapping in case of anonymous pages) have been properly initialized by
the time we pass it to rmap_walk(). Here's a reference to the thread
where this problem was discussed:

  http://lkml.kernel.org/r/<20150430082531.GD21771@blaptop>

> 
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> 
>  mm/page_idle.c |    4 ----
>  1 file changed, 4 deletions(-)
> 
> --- 4.9-rc8/mm/page_idle.c	2016-10-02 16:24:33.000000000 -0700
> +++ linux/mm/page_idle.c	2016-12-05 19:44:32.646625435 -0800
> @@ -30,7 +30,6 @@
>  static struct page *page_idle_get_page(unsigned long pfn)
>  {
>  	struct page *page;
> -	struct zone *zone;
>  
>  	if (!pfn_valid(pfn))
>  		return NULL;
> @@ -40,13 +39,10 @@ static struct page *page_idle_get_page(u
>  	    !get_page_unless_zero(page))
>  		return NULL;
>  
> -	zone = page_zone(page);
> -	spin_lock_irq(zone_lru_lock(zone));
>  	if (unlikely(!PageLRU(page))) {
>  		put_page(page);
>  		page = NULL;
>  	}
> -	spin_unlock_irq(zone_lru_lock(zone));
>  	return page;
>  }
>  

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

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

* Re: [PATCH] mm: page_idle_get_page() does not need zone_lru_lock
  2016-12-07 11:08 ` Vladimir Davydov
@ 2016-12-07 13:07   ` Vlastimil Babka
  0 siblings, 0 replies; 4+ messages in thread
From: Vlastimil Babka @ 2016-12-07 13:07 UTC (permalink / raw)
  To: Vladimir Davydov, Hugh Dickins
  Cc: Minchan Kim, Andrew Morton, Pavel Emelyanov, linux-mm

On 12/07/2016 12:08 PM, Vladimir Davydov wrote:
> Hello,
> 
> On Mon, Dec 05, 2016 at 09:55:10PM -0800, Hugh Dickins wrote:
>> Rechecking PageLRU() after get_page_unless_zero() may have value, but
>> holding zone_lru_lock around that serves no useful purpose: delete it.
> 
> IIRC this lock/unlock was added on purpose, by request from Minchan. It
> serves as a barrier that guarantees that all page fields (specifically
> ->mapping in case of anonymous pages) have been properly initialized by
> the time we pass it to rmap_walk(). Here's a reference to the thread
> where this problem was discussed:
> 
>   http://lkml.kernel.org/r/<20150430082531.GD21771@blaptop>

Um OK, but then there should have been a comment explaining why the lock
is there :/

Vlastimil

>>
>> Signed-off-by: Hugh Dickins <hughd@google.com>
>> ---
>>
>>  mm/page_idle.c |    4 ----
>>  1 file changed, 4 deletions(-)
>>
>> --- 4.9-rc8/mm/page_idle.c	2016-10-02 16:24:33.000000000 -0700
>> +++ linux/mm/page_idle.c	2016-12-05 19:44:32.646625435 -0800
>> @@ -30,7 +30,6 @@
>>  static struct page *page_idle_get_page(unsigned long pfn)
>>  {
>>  	struct page *page;
>> -	struct zone *zone;
>>  
>>  	if (!pfn_valid(pfn))
>>  		return NULL;
>> @@ -40,13 +39,10 @@ static struct page *page_idle_get_page(u
>>  	    !get_page_unless_zero(page))
>>  		return NULL;
>>  
>> -	zone = page_zone(page);
>> -	spin_lock_irq(zone_lru_lock(zone));
>>  	if (unlikely(!PageLRU(page))) {
>>  		put_page(page);
>>  		page = NULL;
>>  	}
>> -	spin_unlock_irq(zone_lru_lock(zone));
>>  	return page;
>>  }
>>  
> 
> --
> 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>
> 

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

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

end of thread, other threads:[~2016-12-07 13:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-06  5:55 [PATCH] mm: page_idle_get_page() does not need zone_lru_lock Hugh Dickins
2016-12-07  8:32 ` Vlastimil Babka
2016-12-07 11:08 ` Vladimir Davydov
2016-12-07 13:07   ` Vlastimil Babka

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