mm: migrate.c: migrate PG_readahead flag
Subsystems (2)
PATCH 1/1 mm: migrate.c: migrate PG_readahead flag
Currently migration code doesn't migrate PG_readahead flag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.
Migrate the flag after end_page_writeback() since it may clear PG_reclaim flag, which is the same bit as PG_readahead, for the new page.
---
I didn't experience any real problem, found by visual inspection. And, this was
discussed in thread: https://lore.kernel.org/linux-mm/[email protected]/T/#m1977ce1de513401b7d09d6fa14fcffe849580aae
mm/migrate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/migrate.c +8 -0
@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))end_page_writeback (newpage); +/* +* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);mem_cgroup_migrate (page, newpage);
Signature · 1 line
1.8.3.1
Andrew Morton
maintainerQuoted 17 lines · On Fri, 14 Feb 2020 08:29:45 +0800 Yang Shi <[email protected]> wrote:
Currently migration code doesn't migrate
PG_readaheadflag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.Migrate the flag after
end_page_writeback()since it may clearPG_reclaimflag, which is the same bit asPG_readahead, for the new page.mm/migrate.c +0
-0@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))end_page_writeback (newpage);
mm/migrate.c void migrate_page_states(struct page *newpage, struct page *page) · line 659
Quoted 10 lines
mm/migrate.c +8
-0+/* +* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);
Why not
if (PageWriteback(newpage)) {
end_page_writeback(newpage); /* * PG_readahead share the same bit with PG_reclaim, the above * end_page_writeback() may clear PG_readahead mistakenly, so * set the bit after that. */ if (PageReadahead(page)) SetPageReadahead(newpage); }
?
Quoted 19 lines · Andrew Morton
Quoted 17 lines · On Fri, 14 Feb 2020 08:29:45 +0800 Yang Shi <[email protected]> wrote:
Currently migration code doesn't migrate
PG_readaheadflag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.Migrate the flag after
end_page_writeback()since it may clearPG_reclaimflag, which is the same bit asPG_readahead, for the new page.mm/migrate.c +0
-0@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))end_page_writeback (newpage);
Quoted 11 lines
mm/migrate.c void migrate_page_states(struct page *newpage, struct page *page) · line 659
Quoted 10 lines
mm/migrate.c +8
-0+/* +* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);Why not
The newpage may not have writeback set, migrating readahead flag should not depend on it.
Quoted 13 lines
if (PageWriteback(newpage)) { end_page_writeback(newpage); /* * PG_readahead share the same bit with PG_reclaim, the above * end_page_writeback() may clear PG_readahead mistakenly, so * set the bit after that. */ if (PageReadahead(page)) SetPageReadahead(newpage); }?
Quoted 29 lines · Yang Shi
Quoted 12 lines · Andrew Morton
Quoted 11 lines · On Fri, 14 Feb 2020 08:29:45 +0800 Yang Shi <[email protected]> wrote:
Currently migration code doesn't migrate
PG_readaheadflag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.Migrate the flag after
end_page_writeback()since it may clearPG_reclaimflag, which is the same bit asPG_readahead, for the new page.Quoted 15 lines
Quoted 4 lines
mm/migrate.c +0
-0@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))mm/migrate.c void migrate_page_states(struct page *newpage, struct page *page) · line 657
Quoted 10 lines
mm/migrate.c +8
-0end_page_writeback (newpage); +/* +* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);Why not
Quoted 2 lines
The newpage may not have writeback set, migrating readahead flag should not depend on it.
Indeed, if the page has writeback set, then the page does not have the readahead flag set; it has the reclaim flag set. The original patch is correct, afaict.
Quoted 13 lines
Quoted 12 lines
if (PageWriteback(newpage)) { end_page_writeback(newpage); /* * PG_readahead share the same bit with PG_reclaim, the above * end_page_writeback() may clear PG_readahead mistakenly, so * set the bit after that. */ if (PageReadahead(page)) SetPageReadahead(newpage); }?
Quoted 10 lines · Yang Shi
Currently migration code doesn't migrate
PG_readaheadflag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.Migrate the flag after
end_page_writeback()since it may clearPG_reclaimflag, which is the same bit asPG_readahead, for the new page.
Looks like an omission. The readahead flag has been added later (2.6.23) while the migration predates 2.6.17.
Quoted 3 lines
Cc Matthew Wilcox <[email protected]>Cc Michal Hocko <[email protected]>Signed-off-by Yang Shi <[email protected]>
Quoted 28 lines
---
I didn't experience any real problem, found by visual inspection. And, this was
discussed in thread: https://lore.kernel.org/linux-mm/[email protected]/T/#m1977ce1de513401b7d09d6fa14fcffe849580aaemm/migrate.c | 8 ++++++++ 1 file changed, 8 insertions(+)mm/migrate.c +8
-0@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))end_page_writeback (newpage); +/* +* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);mem_cgroup_migrate (page, newpage);Signature · 1 line
1.8.3.1
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 31 lines · Yang Shi
Currently migration code doesn't migrate
PG_readaheadflag. Theoretically this would incur slight performance loss as the application might have to ramp its readahead back up again. Even though such problem happens, it might be hidden by something else since migration is typically triggered by compaction and NUMA balancing, any of which should be more noticeable.Migrate the flag after
end_page_writeback()since it may clearPG_reclaimflag, which is the same bit asPG_readahead, for the new page.Cc Matthew Wilcox <[email protected]>Cc Michal Hocko <[email protected]>Signed-off-by Yang Shi <[email protected]>---
I didn't experience any real problem, found by visual inspection. And, this was
discussed in thread: https://lore.kernel.org/linux-mm/[email protected]/T/#m1977ce1de513401b7d09d6fa14fcffe849580aaemm/migrate.c | 8 ++++++++ 1 file changed, 8 insertions(+)mm/migrate.c +1
-0@@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page)if (PageWriteback (newpage))end_page_writeback (newpage); +/*
mm/migrate.c void migrate_page_states(struct page *newpage, struct page *page) · line 660
Quoted 10 lines
mm/migrate.c +7
-0+* PG_readahead share the same bit with PG_reclaim, the above +* end_page_writeback() may clear PG_readahead mistakenly, so set +* the bit after that. +*/ +if (PageReadahead (page)) +SetPageReadahead (newpage); +copy_page_owner (page, newpage);mem_cgroup_migrate (page, newpage);
Looks good to me!
Signature · 3 lines
Thanks, David / dhildenb