/* Returns NULL if the task has no mm. Checks PF_KTHREAD (meaning this kernel workthread has transiently adopted a user mm with use_mm, to do its AIO) is not set and if so returns a reference to it, after bumping up the use count. User must release the mm via mmput() after use. Typically used by /proc and ptrace.  */
struct mm_struct* get_task_mm(struct task_struct *task)
/* Returns NULL if the task has no mm. Checks PF_KTHREAD (meaning this kernel workthread has transiently adopted a user mm with use_mm, to do its AIO) is not set and if so returns a reference to it, after bumping up the use count. User must release the mm via mmput() after use. Typically used by /proc and ptrace.  */
struct mm_struct* get_task_mm(struct task_struct *task)
{
	struct mm_struct *mm;
	task_lock(task);
	mm = task->mm;
	if (mm) {
		if (task->flags & PF_KTHREAD)
			mm = NULL;
		else
			atomic_inc(&mm->mm_users);
	}
	task_unlock(task);
	return mm;
}