#define TNF_MIGRATED 0x01
#define TNF_NO_GROUP 0x02
+#define TNF_SHARED 0x04
#ifdef CONFIG_NUMA_BALANCING
extern void task_numa_fault(int last_node, int node, int pages, int flags);
spin_lock_nested(l2, SINGLE_DEPTH_NESTING);
}
-static void task_numa_group(struct task_struct *p, int cpupid)
+static void task_numa_group(struct task_struct *p, int cpupid, int flags)
{
struct numa_group *grp, *my_grp;
struct task_struct *tsk;
if (my_grp->nr_tasks == grp->nr_tasks && my_grp > grp)
goto unlock;
- if (!get_numa_group(grp))
- goto unlock;
+ /* Always join threads in the same process. */
+ if (tsk->mm == current->mm)
+ join = true;
+
+ /* Simple filter to avoid false positives due to PID collisions */
+ if (flags & TNF_SHARED)
+ join = true;
- join = true;
+ if (join && !get_numa_group(grp))
+ join = false;
unlock:
rcu_read_unlock();
} else {
priv = cpupid_match_pid(p, last_cpupid);
if (!priv && !(flags & TNF_NO_GROUP))
- task_numa_group(p, last_cpupid);
+ task_numa_group(p, last_cpupid, flags);
}
/*
if (!pte_write(pte))
flags |= TNF_NO_GROUP;
+ /*
+ * Flag if the page is shared between multiple address spaces. This
+ * is later used when determining whether to group tasks together
+ */
+ if (page_mapcount(page) > 1 && (vma->vm_flags & VM_SHARED))
+ flags |= TNF_SHARED;
+
last_cpupid = page_cpupid_last(page);
page_nid = page_to_nid(page);
target_nid = numa_migrate_prep(page, vma, addr, page_nid);