Skip to content

Commit 9f72daf

Browse files
vianplhtejun
authored andcommitted
cgroup/cpuset: Avoid memory migration when nodemasks match
With the introduction of ee9707e ("cgroup/cpuset: Enable memory migration for cpuset v2") attaching a process to a different cgroup will trigger a memory migration regardless of whether it's really needed. Memory migration is an expensive operation, so bypass it if the nodemasks passed to cpuset_migrate_mm() are equal. Note that we're not only avoiding the migration work itself, but also a call to lru_cache_disable(), which triggers and flushes an LRU drain work on every online CPU. Signed-off-by: Nicolas Saenz Julienne <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent ee9707e commit 9f72daf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/cgroup/cpuset.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,11 @@ static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
16341634
{
16351635
struct cpuset_migrate_mm_work *mwork;
16361636

1637+
if (nodes_equal(*from, *to)) {
1638+
mmput(mm);
1639+
return;
1640+
}
1641+
16371642
mwork = kzalloc(sizeof(*mwork), GFP_KERNEL);
16381643
if (mwork) {
16391644
mwork->mm = mm;

0 commit comments

Comments
 (0)