Skip to content

Commit

Permalink
cgroup/cpuset: Avoid memory migration when nodemasks match
Browse files Browse the repository at this point in the history
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 <nsaenzju@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Nicolas Saenz Julienne authored and Tejun Heo committed Aug 25, 2021
1 parent ee9707e commit 9f72daf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/cgroup/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,11 @@ static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
{
struct cpuset_migrate_mm_work *mwork;

if (nodes_equal(*from, *to)) {
mmput(mm);
return;
}

mwork = kzalloc(sizeof(*mwork), GFP_KERNEL);
if (mwork) {
mwork->mm = mm;
Expand Down

0 comments on commit 9f72daf

Please sign in to comment.