Skip to contentSkip to conversation

mm/page_reporting: the "page" must not be the list head

PATCH In review Wei Yang 4 participants 10 messages Aug 17, 2020 – Aug 18, 2020

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/page_reporting: the "page" must not be the list head

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
 mm/page_reporting.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
 		 * the new head of the free list before we release the
 		 * zone lock.
 		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
 			list_rotate_to_front(&page->lru, list);
 
 		/* release lock before waiting on report processing */
Signature · 1 line
2.20.1 (Apple Git-117)
#1 lore raw
Quoted 14 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
 mm/page_reporting.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +0 -0
index 3bbd471cfc81..aaaa3605123d 100644

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 8 lines
mm/page_reporting.c +1 -1
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
 		 * the new head of the free list before we release the
 		 * zone lock.
 		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
 			list_rotate_to_front(&page->lru, list);
 
 		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Signature · 3 lines
Thanks,

David / dhildenb
#2 lore raw
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
 
Quoted 6 lines

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 2 lines
mm/page_reporting.c +0 -0
  		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

This should be a clean-up. Since the &page->lru != list will always be true.

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

#3 lore raw
Quoted 24 lines · Alexander Duyck
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
 
Quoted 9 lines
Quoted 6 lines

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 2 lines
mm/page_reporting.c +0 -0
  		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

This should be a clean-up. Since the &page->lru != list will always be true.

Makes sense, maybe we can make that a little bit clearer in the patch description.

Quoted 6 lines

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Signature · 3 lines
Thanks,

David / dhildenb
author
#9 lore raw
In reply to David Hildenbrand
Quoted 21 lines · David Hildenbrand
Quoted 20 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
 mm/page_reporting.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
 		 * the new head of the free list before we release the
 		 * zone lock.
 		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
 			list_rotate_to_front(&page->lru, list);
 
Quoted 6 lines

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 2 lines
mm/page_reporting.c +0 -0
 		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

I think this is a cleanup.

I am not sure why you ask this, since the check must be true when the iteration continues.

Quoted 4 lines
Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Wei Yang
Help you, Help me
author
#4 lore raw
In reply to David Hildenbrand
Quoted 32 lines · David Hildenbrand
Quoted 31 lines · Alexander Duyck
Quoted 27 lines · David Hildenbrand
Quoted 14 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +0 -0
index 3bbd471cfc81..aaaa3605123d 100644

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 8 lines
mm/page_reporting.c +1 -1
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
 
  		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Quoted 6 lines
Quoted 2 lines

This should be a clean-up. Since the &page->lru != list will always be true.

Makes sense, maybe we can make that a little bit clearer in the patch description.

Ok, do you have some suggestion on the description?

A clean-up for commit xxx?

I would appreciate your suggestion :-)

Quoted 11 lines
Quoted 6 lines

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Wei Yang
Help you, Help me
author
#7 lore raw
In reply to Alexander Duyck
Quoted 30 lines · Alexander Duyck
Quoted 9 lines · David Hildenbrand
Quoted 8 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 13 lines
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
  		/* release lock before waiting on report processing */
 

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Quoted 8 lines

This should be a clean-up. Since the &page->lru != list will always be true.

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Hi, Alexander,

I see you mentioned in the changelog, this change "mm/page_reporting: rotate reported pages to the tail of the list" brings some performance gain.

Would you mind sharing more test detail? I would like to have a try at my side.

Thanks :-)

Signature · 2 lines
Wei Yang
Help you, Help me
Reviewed-by
#5 lore raw
In reply to Wei Yang
Quoted 40 lines · Wei Yang
Quoted 32 lines · David Hildenbrand
Quoted 31 lines · Alexander Duyck
Quoted 27 lines · David Hildenbrand
Quoted 14 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +0 -0
index 3bbd471cfc81..aaaa3605123d 100644

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 8 lines
mm/page_reporting.c +1 -1
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
 
  		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Quoted 6 lines
Quoted 2 lines

This should be a clean-up. Since the &page->lru != list will always be true.

Makes sense, maybe we can make that a little bit clearer in the patch description.

Quoted 6 lines

Ok, do you have some suggestion on the description?

A clean-up for commit xxx?

I would appreciate your suggestion :-)

I'd go with something like

"
mm/page_reporting: drop stale list head check in page_reporting_cycle

list_for_each_entry_safe() guarantees that we will never stumble over the list head; "&page->lru != list" will always evaluate to true. Let's simplify.
"

to stress that this is a pure simplifcation.

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 3 lines
Thanks,

David / dhildenb
author
#6 lore raw
Quoted 50 lines · David Hildenbrand
Quoted 40 lines · Wei Yang
Quoted 32 lines · David Hildenbrand
Quoted 31 lines · Alexander Duyck
Quoted 27 lines · David Hildenbrand
Quoted 14 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_reporting.c +0 -0
index 3bbd471cfc81..aaaa3605123d 100644

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 8 lines
mm/page_reporting.c +1 -1
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
  		 * the new head of the free list before we release the
  		 * zone lock.
  		 */
-		if (&page->lru != list && !list_is_first(&page->lru, list))
+		if (!list_is_first(&page->lru, list))
  			list_rotate_to_front(&page->lru, list);
 
  		/* release lock before waiting on report processing */

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Quoted 6 lines
Quoted 2 lines

This should be a clean-up. Since the &page->lru != list will always be true.

Makes sense, maybe we can make that a little bit clearer in the patch description.

Quoted 6 lines

Ok, do you have some suggestion on the description?

A clean-up for commit xxx?

I would appreciate your suggestion :-)

I'd go with something like

Quoted 8 lines

"
mm/page_reporting: drop stale list head check in page_reporting_cycle

list_for_each_entry_safe() guarantees that we will never stumble over the list head; "&page->lru != list" will always evaluate to true. Let's simplify.
"

Looks really better than mine. Thanks a lot.

Quoted 22 lines

to stress that this is a pure simplifcation.

Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Signature · 3 lines
Thanks,

David / dhildenb
Signature · 3 lines
Thanks,

David / dhildenb
Signature · 2 lines
Wei Yang
Help you, Help me
#8 lore raw
In reply to Wei Yang
Quoted 43 lines · Wei Yang
Quoted 30 lines · Alexander Duyck
Quoted 9 lines · David Hildenbrand
Quoted 8 lines · Wei Yang

If "page" is the list head, list_for_each_entry_safe() would stop iteration.

---
  mm/page_reporting.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

mm/page_reporting.c page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, · line 184

Quoted 13 lines
mm/page_reporting.c +1 -1
index 3bbd471cfc81..aaaa3605123d 100644
@@ -178,7 +178,7 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone,
            * the new head of the free list before we release the
            * zone lock.
            */
-          if (&page->lru != list && !list_is_first(&page->lru, list))
+          if (!list_is_first(&page->lru, list))
                   list_rotate_to_front(&page->lru, list);
           /* release lock before waiting on report processing */
 

Is this a fix or a cleanup? If it's a fix, can this be reproduced easily and what ere the effects?

Quoted 8 lines

This should be a clean-up. Since the &page->lru != list will always be true.

If I recall at some point the that was a check for &next->lru != list but I think I pulled out an additional conditional check somewhere so that we just go through the start of the loop again and iterate over reported pages until we are guaranteed to have a non-reported page to rotate to the top of the list with the general idea being that we wanted the allocator to pull non-reported pages before reported pages.

Hi, Alexander,

Quoted 7 lines

I see you mentioned in the changelog, this change "mm/page_reporting: rotate reported pages to the tail of the list" brings some performance gain.

Would you mind sharing more test detail? I would like to have a try at my side.

Thanks :-)

I seem to recall my default test for most of this was the page_fault1 test from the will-it-scale suite of tests. Basically I was running that while leaving page reporting enabled. However I don't know how much visibility you would have into the performance impact as I seem to recall I had to modify the frequency of scheduling for the reporting polling task in order to see much of an impact.

Thanks.

- Alex