The patch titled Subject: mm: migrate: add more comments for selecting target node randomly has been added to the -mm tree. Its filename is mm-migrate-add-more-comments-for-selecting-target-node-randomly.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-migrate-add-more-comments-for-selecting-target-node-randomly.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-migrate-add-more-comments-for-selecting-target-node-randomly.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Subject: mm: migrate: add more comments for selecting target node randomly As Yang Shi suggested [1], it will be helpful to explain why we should select target node randomly now if there are multiple target nodes. [1] https://lore.kernel.org/all/CAHbLzkqSqCL+g7dfzeOw8fPyeEC0BBv13Ny1UVGHDkadnQdR=g@xxxxxxxxxxxxxx/ Link: https://lkml.kernel.org/r/c31d36bd097c6e9e69fc0f409c43b78e53e64fc2.1637766801.git.baolin.wang@xxxxxxxxxxxxxxxxx Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Reviewed-by: Yang Shi <shy828301@xxxxxxxxx> Cc: "Huang, Ying" <ying.huang@xxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Cc: zhongjiang-ali <zhongjiang-ali@xxxxxxxxxxxxxxxxx> Cc: Xunlei Pang <xlpang@xxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/migrate.c~mm-migrate-add-more-comments-for-selecting-target-node-randomly +++ a/mm/migrate.c @@ -1196,6 +1196,14 @@ int next_demotion_node(int node) /* * If there are multiple target nodes, just select one * target node randomly. + * + * In addition, we can also use round-robin to select + * target node, but we should introduce another variable + * for node_demotion[] to record last selected target node, + * that may cause cache ping-pong due to the changing of + * last target node. Or introducing per-cpu data to avoid + * caching issue, which seems more complicated. So selecting + * target node randomly seems better until now. */ index = get_random_int() % target_nr; break; _ Patches currently in -mm which might be from baolin.wang@xxxxxxxxxxxxxxxxx are mm-migrate-fix-the-return-value-of-migrate_pages.patch mm-migrate-correct-the-hugetlb-migration-stats.patch mm-compaction-fix-the-migration-stats-in-trace_mm_compaction_migratepages.patch mm-migrate-support-multiple-target-nodes-demotion.patch mm-migrate-add-more-comments-for-selecting-target-node-randomly.patch