do_migrate_pages() calls migrate_to_node() even if task is already on a correct node
Subsystems (2)
PATCH 1/1 do_migrate_pages() calls migrate_to_node() even if task is already on a correct node
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination cpuset are a subset of the nodes of the source cpuset do_migrate_pages() will move pages that are already on a node in the destination cpuset. The reason for this is do_migrate_pages() does not check whether each node in the source nodemask is in the destination nodemask before calling migrate_to_node(). If we simply do this check and skip them when the source is in the destination moving we wont move nodes that dont need to be moved.
Adding a little debug printk to migrate_to_node():
Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate from ALL the nodes even if they are in the both the source and destination nodesets:
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3
With this change we only migrate from nodes that are not in the destination nodesets:
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 2 to 3
Migrating 1 to 4
Migrating 0 to 3
mm/mempolicy.c +3 -0
@@ -1012,6 +1012,9 @@ int do_migrate_pages(struct mm_struct *mm,int dest =0 ;for_each_node_mask (s, tmp) { +/* no need to move if its already there */ +if (node_isset (s, *to_nodes)) +continue ; d =node_remap (s, *from_nodes, *to_nodes);if (s == d)continue ;
Quoted 2 lines · Larry Woodman
With this change we only migrate from nodes that are not in the destination nodesets:
That's a pretty obvious improvement :)
Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 2 to 3
Migrating 1 to 4
Migrating 0 to 3Signed-off-by Larry Woodman<[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
CC to Christoph.
Quoted 11 lines
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination cpuset are a subset of the nodes of the source cpuset
do_migrate_pages()will move pages that are already on a node in the destination cpuset. The reason for this isdo_migrate_pages()does not check whether each node in the source nodemask is in the destination nodemask before callingmigrate_to_node(). If we simply do this check and skip them when the source is in the destination moving we wont move nodes that dont need to be moved.Adding a little debug printk to
migrate_to_node():Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate from ALL the nodes even if they are in the both the source and destination nodesets:
Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3
Wait.
This may be non-optimal for cpusets, but maybe optimal migrate_pages, especially the usecase is HPC. I guess this is intended behavior. I think we need to hear Christoph's intention.
But, I'm not against this if he has no objection.
Quoted 4 lines
With this change we only migrate from nodes that are not in the destination nodesets:
Quoted 9 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 2 to 3
Migrating 1 to 4
Migrating 0 to 3Signed-off-by Larry Woodman<[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 29 lines · KOSAKI Motohiro
CC to Christoph.
Quoted 18 lines
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination
cpuset are a subset of the nodes of the source cpusetdo_migrate_pages()will move pages that are already on a node in the destination cpuset. The reason for this isdo_migrate_pages()does not check whether each node in the source
nodemask is in the destination nodemask before callingmigrate_to_node(). If we simply do this check and skip them when the source is in the destination moving we wont move nodes that dont need to be moved.Adding a little debug printk to
migrate_to_node():Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate
from ALL the nodes even if they are in the both the source and destination nodesets:Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3
Quoted 7 lines
Wait.
This may be non-optimal for cpusets, but maybe optimal
migrate_pages, especially
the usecase is HPC. I guess this is intended behavior. I think we need to hear
Christoph's intention.
How is the moving of pages that are already in the intended cpuset better than just leaving them alone?
Quoted 1 line
But, I'm not against this if he has no objection.
Sure. Christoph?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · KOSAKI Motohiro
CC to Christoph.
Sorry Christoph I meant to cc you on the original message!
Larry
Quoted 9 lines
Wait.
This may be non-optimal for cpusets, but maybe optimal
migrate_pages, especially the usecase is HPC. I guess this is intended behavior. I think we need to hear Christoph's intention.But, I'm not against this if he has no objection.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 29 lines · KOSAKI Motohiro
CC to Christoph.
Quoted 18 lines
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination
cpuset are a subset of the nodes of the source cpusetdo_migrate_pages()will move pages that are already on a node
in the destination cpuset. The reason for this isdo_migrate_pages()does not check whether each node in the source
nodemask is in the destination nodemask before callingmigrate_to_node(). If we simply do this check and skip them
when the source is in the destination moving we wont move nodes that dont need to be moved.Adding a little debug printk to
migrate_to_node():Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate
from ALL the nodes even if they are in the both the source and destination nodesets:Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3
Quoted 8 lines
Wait.
This may be non-optimal for cpusets, but maybe optimal
migrate_pages, especially
the usecase is HPC. I guess this is intended behavior. I think we need to hear Christoph's intention.But, I'm not against this if he has no objection.
The use case for this is if you have an app running on nodes 3,4,5 on your machine and now you want to shift it to 4,5,6. The expectation is that the location of the pages relative to the first node stay the same. Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
If you justd copy 3 to 6 then the app may get confused when doing additional allocations since different types of information is now stored on the "first" node (which is now 4).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 37 lines · Christoph Lameter
Quoted 35 lines · KOSAKI Motohiro
CC to Christoph.
Quoted 18 lines
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination
cpuset are a subset of the nodes of the source cpusetdo_migrate_pages()will move pages that are already on a node
in the destination cpuset. The reason for this isdo_migrate_pages()does not check whether each node in the source
nodemask is in the destination nodemask before callingmigrate_to_node(). If we simply do this check and skip them
when the source is in the destination moving we wont move nodes that dont need to be moved.Adding a little debug printk to
migrate_to_node():Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate
from ALL the nodes even if they are in the both the source and destination nodesets:Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3Wait.
This may be non-optimal for cpusets, but maybe optimal
migrate_pages, especially
the usecase is HPC. I guess this is intended behavior. I think we need to hear Christoph's intention.
Quoted 6 lines
Quoted 1 line
But, I'm not against this if he has no objection.
The use case for this is if you have an app running on nodes 3,4,5 on your machine and now you want to shift it to 4,5,6. The expectation is that the location of the pages relative to the first node stay the same. Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6 to keep the node ordering the same?
Larry
Quoted 6 lines
If you justd copy 3 to 6 then the app may get confused when doing additional allocations since different types of information is now stored on the "first" node (which is now 4).
Quoted 6 lines
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email:<a href=mailto:"[email protected]"> [email protected]</a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 46 lines · Christoph Lameter
Quoted 29 lines · KOSAKI Motohiro
CC to Christoph.
Quoted 18 lines
While moving tasks between cpusets I noticed some strange behavior. Specifically if the nodes of the destination
cpuset are a subset of the nodes of the source cpusetdo_migrate_pages()will move pages that are already on a node
in the destination cpuset. The reason for this isdo_migrate_pages()does not check whether each node in the source
nodemask is in the destination nodemask before callingmigrate_to_node(). If we simply do this check and skip them
when the source is in the destination moving we wont move nodes that dont need to be moved.Adding a little debug printk to
migrate_to_node():Without this change migrating tasks from a cpuset containing nodes 0-7 to a cpuset containing nodes 3-4, we migrate
from ALL the nodes even if they are in the both the source and destination nodesets:Quoted 8 lines
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3Quoted 8 lines
Wait.
This may be non-optimal for cpusets, but maybe optimal
migrate_pages, especially
the usecase is HPC. I guess this is intended behavior. I think we need to hear Christoph's intention.But, I'm not against this if he has no objection.
The use case for this is if you have an app running on nodes 3,4,5 on your machine and now you want to shift it to 4,5,6. The expectation is that the location of the pages relative to the first node stay the same. Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
Quoted 3 lines
If you justd copy 3 to 6 then the app may get confused when doing additional allocations since different types of information is now stored on the "first" node (which is now 4).
MPOL_INTERLEAVE is more simple situaltion. applications naturally assume the memory is mapped intealeaving and application threads optimize for it. if we broke intereaving, the applications may slow down.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 5 lines · Larry Woodman
Quoted 2 lines
Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?
Yup. Have a look at do_migrate_pages and the descrition in the comment by there by Paul Jackson.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Larry Woodman
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?
Would it make more sense to do 5->6, 4->5, 3->4? If we move stuff from 3 to 4 before clearing the old 4 stuff out, it might get crowded?
Quoted 6 lines · On Thu, 22 Mar 2012, [email protected] wrote:
Quoted 3 lines
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Would it make more sense to do 5->6, 4->5, 3->4? If we move stuff from 3 to 4 before clearing the old 4 stuff out, it might get crowded?
Right. I thought Paul did take care of that way back when it was written?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · On 03/22/2012 03:36 PM, [email protected] wrote:
Quoted 3 lines · Larry Woodman
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Would it make more sense to do 5->6, 4->5, 3->4? If we move stuff from 3 to 4 before clearing the old 4 stuff out, it might get crowded?
Yes, I didnt try to imply the order in which pages were moved just the additional moving necessary.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Larry Woodman
Quoted 8 lines · On 03/22/2012 03:36 PM, [email protected] wrote:
Quoted 3 lines · Larry Woodman
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Would it make more sense to do 5->6, 4->5, 3->4? If we move stuff from 3 to 4 before clearing the old 4 stuff out, it might get crowded?
Yes, I didnt try to imply the order in which pages were moved just the additional moving necessary.
Oh, OK.. :)
Quoted 11 lines · Christoph Lameter
Quoted 5 lines · Larry Woodman
Quoted 2 lines
Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Yup. Have a look at
do_migrate_pagesand the descrition in the comment by there by Paul Jackson.
Christoph and others what do you think about this???
mm/mempolicy.c +10 -0
@@ -1012,6 +1012,16 @@ int do_migrate_pages(struct mm_struct *mm,int dest =0 ;for_each_node_mask (s, tmp) { + +/* IFF there is an equal number of source and +* destination nodes, maintain relative node distance +* even when source and destination nodes overlap. +* However, when the node weight is unequal, never move +* memory out of any destination nodes */ +if ((nodes_weight (*from_nodes) !=nodes_weight (*to_nodes)) && + (node_isset (s, *to_nodes))) +continue ; + d =node_remap (s, *from_nodes, *to_nodes);if (s == d)continue ;
Quoted 26 lines · Larry Woodman
Quoted 11 lines · Christoph Lameter
Quoted 5 lines · Larry Woodman
Quoted 2 lines
Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Yup. Have a look at
do_migrate_pagesand the descrition in the comment by there by Paul Jackson.Christoph and others what do you think about this???
for_each_node_mask(s, tmp) {mm/mempolicy.c +10
-0+ +/* IFF there is an equal number of source and +* destination nodes, maintain relative node distance +* even when source and destination nodes overlap. +* However, when the node weight is unequal, never move +* memory out of any destination nodes */ +if ((nodes_weight (*from_nodes) !=nodes_weight (*to_nodes)) && + (node_isset (s, *to_nodes))) +continue ; +
Quoted 3 lines
d = node_remap(s, *from_nodes, *to_nodes); if (s == d) continue;
I'm confused. Could you please explain why you choose nodes_weight()? On my first impression, it seems almostly unrelated factor.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 26 lines · KOSAKI Motohiro
Quoted 25 lines · Larry Woodman
Quoted 11 lines · Christoph Lameter
Quoted 5 lines · Larry Woodman
Quoted 2 lines
Application may manage their locality given a range of nodes and each of the x .. x+n nodes has their particular purpose.
So to be clear on this, in that case the intention would be move 3 to 4, 4 to 5 and 5 to 6
to keep the node ordering the same?Yup. Have a look at
do_migrate_pagesand the descrition in the comment by there by Paul Jackson.Christoph and others what do you think about this???
for_each_node_mask(s, tmp) {mm/mempolicy.c +7
-0+ +/* IFF there is an equal number of source and +* destination nodes, maintain relative node distance +* even when source and destination nodes overlap. +* However, when the node weight is unequal, never move +* memory out of any destination nodes */ + if ((nodes_weight(*from_nodes) !=
nodes_weight(*to_nodes)) &&
+ (node_isset(s, *to_nodes)))
Quoted 8 lines
mm/mempolicy.c int do_migrate_pages(struct mm_struct *mm, · line 1027
Quoted 5 lines
mm/mempolicy.c +2
-0+continue ; + d =node_remap (s, *from_nodes, *to_nodes);if (s == d)continue ;I'm confused. Could you please explain why you choose
nodes_weight()? On my first impression, it seems almostly unrelated factor.
nodes_weight() tells us the number of nodes in the cpuset so if you are migrating from say 2, 3 &4 to 3, 4 &5 we wont go from 2 to 5 and call it done like the original patch did. With this patch we will preserve the migrating of 2, 3 &4 to 3, 4 &5 yet if we are migrating from 0-7 to 3-4 we wont do this:
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 4 to 3
Migrating 1 to 4
Migrating 3 to 4
Migrating 0 to 3
Migrating 2 to 3
Instead, will do this:
Migrating 7 to 4
Migrating 6 to 3
Migrating 5 to 4
Migrating 1 to 4
Migrating 0 to 3
Migrating 2 to 3
Larry
Quoted 8 lines
Signature · 6 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · KOSAKI Motohiro
Quoted 13 lines
for_each_node_mask(s, tmp) {mm/mempolicy.c +5
-0+ +/* IFF there is an equal number of source and +* destination nodes, maintain relative node distance +* even when source and destination nodes overlap. +* However, when the node weight is unequal, never move
(quoted diff) +2
-0+ * memory out of any destination nodes */ + if ((nodes_weight(*from_nodes) !=
nodes_weight(*to_nodes)) &&mm/mempolicy.c +2
-0+ (node_isset(s, *to_nodes))) +continue ;
Quoted 8 lines
Quoted 4 lines
+
d = node_remap(s, *from_nodes, *to_nodes); if (s == d) continue;I'm confused. Could you please explain why you choose
nodes_weight()? On my first impression,
it seems almostly unrelated factor.
Isnt this the original code by Paul? I would think that the 1-1 movement is only useful to do if the number of nodes in both the destination and the source is the same.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 21 lines · Christoph Lameter
Quoted 11 lines · KOSAKI Motohiro
Quoted 11 lines
for_each_node_mask(s, tmp) {mm/mempolicy.c +5
-0+ +/* IFF there is an equal number of source and +* destination nodes, maintain relative node distance +* even when source and destination nodes overlap. +* However, when the node weight is unequal, never move
(quoted diff) +2
-0+ * memory out of any destination nodes */ + if ((nodes_weight(*from_nodes) !=nodes_weight(*to_nodes))&&
mm/mempolicy.c +1
-0+ (node_isset(s, *to_nodes)))Quoted 8 lines
Quoted 5 lines
mm/mempolicy.c +2
-0+continue ; +d = node_remap(s, *from_nodes, *to_nodes); if (s == d) continue;I'm confused. Could you please explain why you choose
nodes_weight()? On my first impression,
it seems almostly unrelated factor.
Quoted 1 line
Isnt this the original code by Paul?
No, I added the test to see if the source and destination has the same number of nodes.
Quoted 3 lines
I would think that the 1-1 movement
is only useful to do if the number of nodes in both the destination and the source is the same.
Agreed, thats exactly what this patch does. are you OK with this change then???
Larry
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Larry Woodman
of nodes.
Quoted 3 lines
I would think that the 1-1 movement
is only useful to do if the number of nodes in both the destination and the source is the same.Agreed, thats exactly what this patch does. are you OK with this change then???
Please add to the patch description some explanation how this patch changes the way page migration does things.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>