Skip to contentSkip to conversation

mm/compaction: Rename 'start_pfn' to 'iteration_start_pfn' in compact_zone()

PATCH Superseded [email protected] 3 participants 6 messages Oct 19, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm/compaction: Rename 'start_pfn' to 'iteration_start_pfn' in compact_zone()

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

 mm/compaction.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +3 -4
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 
 	while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
 		int err;
-		unsigned long start_pfn = cc->migrate_pfn;
+		unsigned long iteration_start_pfn = cc->migrate_pfn;
 
 		/*
 		 * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 		 */
 		cc->rescan = false;
 		if (pageblock_start_pfn(last_migrated_pfn) ==
-		    pageblock_start_pfn(start_pfn)) {
+		    pageblock_start_pfn(iteration_start_pfn)) {
 			cc->rescan = true;
 		}
 
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 			goto check_drain;
 		case ISOLATE_SUCCESS:
 			update_cached = false;
-			last_migrated_pfn = start_pfn;
-			;
+			last_migrated_pfn = iteration_start_pfn;
 		}
 
 		err = migrate_pages(&cc->migratepages, compaction_alloc,
Signature · 1 line
2.18.2
Acked-by on v2 1/1
#1 lore raw
Quoted 42 lines

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

 mm/compaction.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +2 -2
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 
        while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
                int err;
-               unsigned long start_pfn = cc->migrate_pfn;
+               unsigned long iteration_start_pfn = cc->migrate_pfn;
 
                /*
                 * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
                 */
                cc->rescan = false;
                if (pageblock_start_pfn(last_migrated_pfn) ==
-                   pageblock_start_pfn(start_pfn)) {
+                   pageblock_start_pfn(iteration_start_pfn)) {
                        cc->rescan = true;
                }
 

mm/compaction.c compact_zone(struct compact_control *cc, struct capture_control *capc) · line 2314

Quoted 9 lines
mm/compaction.c +1 -2
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
                        goto check_drain;
                case ISOLATE_SUCCESS:
                        update_cached = false;
-                       last_migrated_pfn = start_pfn;
-                       ;
+                       last_migrated_pfn = iteration_start_pfn;
                }
 
                err = migrate_pages(&cc->migratepages, compaction_alloc,

Improves readability.

#2 lore raw
In reply to [email protected]
Quoted 6 lines · On 10/19/20 10:36 AM, [email protected] wrote:

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

"to prevent confusion.", because trace_mm_compaction_end() has the correct value even before the patch - the second start_pfn is out of scope at that point.

Thanks

Quoted 45 lines

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

  mm/compaction.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +3 -4
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 
  	while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
  		int err;
-		unsigned long start_pfn = cc->migrate_pfn;
+		unsigned long iteration_start_pfn = cc->migrate_pfn;
 
  		/*
  		 * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
  		 */
  		cc->rescan = false;
  		if (pageblock_start_pfn(last_migrated_pfn) ==
-		    pageblock_start_pfn(start_pfn)) {
+		    pageblock_start_pfn(iteration_start_pfn)) {
  			cc->rescan = true;
  		}
 
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
  			goto check_drain;
  		case ISOLATE_SUCCESS:
  			update_cached = false;
-			last_migrated_pfn = start_pfn;
-			;
+			last_migrated_pfn = iteration_start_pfn;
  		}
 
  		err = migrate_pages(&cc->migratepages, compaction_alloc,
author
#3 lore raw
Quoted 8 lines · Vlastimil Babka
Quoted 6 lines · On 10/19/20 10:36 AM, [email protected] wrote:

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

Quoted 6 lines

"to prevent confusion.", because trace_mm_compaction_end() has the correct value even before the patch - the second start_pfn is out of scope at that point.

Thanks

In the while-statement, the second start_pfn is always be reassigned the value of cc->migrate_pfn in every loop, also the cc->migrate_pfn might be changed in the loop. Does trace_mm_compaction_end() really want to trace the new assinged start_pfn?

Without the patch: 566e54e11(mm, compaction: remove last_migrated_pfn from compact_control), there is only one start_pfn which has a fixed value. The trace_mm_compaction_end() trace it too.

Thus, I think the tracepoint might get an undesireble value.:)

Thanks,
Yanfei

Quoted 46 lines
Quoted 44 lines

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

  mm/compaction.c | 7 +++----

  1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +1 -1
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
       while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
           int err;
-        unsigned long start_pfn = cc->migrate_pfn;
+        unsigned long iteration_start_pfn = cc->migrate_pfn;
           /*
            * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
            */
           cc->rescan = false;

          if (pageblock_start_pfn(last_migrated_pfn) == -            pageblock_start_pfn(start_pfn)) { +            pageblock_start_pfn(iteration_start_pfn)) { cc->rescan = true;
          }

mm/compaction.c +0 -0
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
               goto check_drain;

          case ISOLATE_SUCCESS:
              update_cached = false;
-            last_migrated_pfn = start_pfn;
-            ;
+            last_migrated_pfn = iteration_start_pfn;
          }
          err = migrate_pages(&cc->migratepages, compaction_alloc,

#4 lore raw
Quoted 15 lines · Yanfei
Quoted 12 lines · Vlastimil Babka
Quoted 6 lines · On 10/19/20 10:36 AM, [email protected] wrote:

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

"to prevent confusion.", because trace_mm_compaction_end() has the correct value even before the patch - the second start_pfn is out of scope at that point.

Quoted 6 lines
Quoted 2 lines

Thanks

In the while-statement, the second start_pfn is always be reassigned the value of cc->migrate_pfn in every loop, also the cc->migrate_pfn might be changed in the loop. Does trace_mm_compaction_end() really want to trace the new assinged start_pfn?

compact_zone()

{
    unsigned long start_pfn = cc->zone->zone_start_pfn;

    while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
        unsigned long start_pfn = cc->migrate_pfn;
	...
    }

    trace_mm_compaction_end(start_pfn, cc->migrate_pfn, ...)
}

Unless my C knowledge fails me completely, the start_pfn in the while loop is a new different local variable that shadows the start_pfn from compact_zone() level, but does not modify its value. After while loop finishes, start_pfn has still the value assigned at compact_zone() beginning and that's what tracepoint sees.

So renaming the variable in while loop is not a bug fix, but removing confusion.

Quoted 56 lines

Without the patch: 566e54e11(mm, compaction: remove last_migrated_pfn from compact_control), there is only one start_pfn which has a fixed value. The trace_mm_compaction_end() trace it too.

Thus, I think the tracepoint might get an undesireble value.:)

Thanks,
Yanfei

Quoted 46 lines
Quoted 44 lines

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

  mm/compaction.c | 7 +++----

  1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +1 -1
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
       while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
           int err;
-        unsigned long start_pfn = cc->migrate_pfn;
+        unsigned long iteration_start_pfn = cc->migrate_pfn;
           /*
            * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
            */
           cc->rescan = false;

          if (pageblock_start_pfn(last_migrated_pfn) == -            pageblock_start_pfn(start_pfn)) { +            pageblock_start_pfn(iteration_start_pfn)) { cc->rescan = true;
          }

mm/compaction.c +0 -0
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, struct 
 capture_control *capc)
               goto check_drain;

          case ISOLATE_SUCCESS:
              update_cached = false;
-            last_migrated_pfn = start_pfn;
-            ;
+            last_migrated_pfn = iteration_start_pfn;
          }
          err = migrate_pages(&cc->migratepages, compaction_alloc,

author
#5 lore raw
Quoted 32 lines · Vlastimil Babka
Quoted 15 lines · Yanfei
Quoted 12 lines · Vlastimil Babka
Quoted 6 lines · On 10/19/20 10:36 AM, [email protected] wrote:

From: Yanfei Xu <[email protected]>

There are two 'start_pfn' declared in compact_zone() which have different meaning. Rename the second one to 'iteration_start_pfn' to prevent trace_mm_compaction_end() from tracing an undesirable value.

"to prevent confusion.", because trace_mm_compaction_end() has the correct value even before the patch - the second start_pfn is out of scope at that point.

Quoted 6 lines
Quoted 2 lines

Thanks

In the while-statement, the second start_pfn is always be reassigned the value of cc->migrate_pfn in every loop, also the cc->migrate_pfn might be changed in the loop. Does trace_mm_compaction_end() really want to trace the new assinged start_pfn?

compact_zone()
{
    unsigned long start_pfn = cc->zone->zone_start_pfn;

    while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) { unsigned long start_pfn = cc->migrate_pfn;
    ...
    }

Quoted 6 lines

    trace_mm_compaction_end(start_pfn, cc->migrate_pfn, ...)
}

Unless my C knowledge fails me completely, the start_pfn in the while loop is a new different local variable that shadows the start_pfn from compact_zone() level, but does not modify its value. After while loop finishes, start_pfn has still the value assigned at compact_zone() beginning and that's what tracepoint sees.

You are right! and I got your point. As you said, the second start_pfn is out of scope at that point. Will send v3.

Many thanks,
Yanfei

Quoted 59 lines

So renaming the variable in while loop is not a bug fix, but removing confusion.

Quoted 56 lines

Without the patch: 566e54e11(mm, compaction: remove last_migrated_pfn from compact_control), there is only one start_pfn which has a fixed value. The trace_mm_compaction_end() trace it too.

Thus, I think the tracepoint might get an undesireble value.:)

Thanks,
Yanfei

Quoted 46 lines
Quoted 44 lines

BTW, remove an useless semicolon.

---
v1->v2:
Rename 'start_pfn' to 'iteration_start_pfn' and change commit messages.

  mm/compaction.c | 7 +++----

  1 file changed, 3 insertions(+), 4 deletions(-)
mm/compaction.c +1 -1
index 176dcded298e..ccd27c739fd6 100644
@@ -2272,7 +2272,7 @@ compact_zone(struct compact_control *cc, 
 struct capture_control *capc)
       while ((ret = compact_finished(cc)) == COMPACT_CONTINUE) {
           int err;
-        unsigned long start_pfn = cc->migrate_pfn;
+        unsigned long iteration_start_pfn = cc->migrate_pfn;
           /*
            * Avoid multiple rescans which can happen if a page cannot be
@@ -2284,7 +2284,7 @@ compact_zone(struct compact_control *cc, 
 struct capture_control *capc)
            */
           cc->rescan = false;

          if (pageblock_start_pfn(last_migrated_pfn) == -            pageblock_start_pfn(start_pfn)) { +            pageblock_start_pfn(iteration_start_pfn)) { cc->rescan = true;
          }

mm/compaction.c +0 -0
@@ -2308,8 +2308,7 @@ compact_zone(struct compact_control *cc, 
 struct capture_control *capc)
               goto check_drain;

          case ISOLATE_SUCCESS:
              update_cached = false;
-            last_migrated_pfn = start_pfn;
-            ;
+            last_migrated_pfn = iteration_start_pfn;
          }
          err = migrate_pages(&cc->migratepages, compaction_alloc,