Why should check "current" consistency?

From: real yr
Date: Sun Mar 07 2010 - 21:21:20 EST


The source code is listed as follows:
This code is inserted into do_fork() function
============================================
struct asmp_cpu_info *info;
......
restart:
if ((info = current->asmp->cpu)) {
dprintk("forking tsk=%p current=%p #tasks=%d\n", p, current,
info->num_tasks);
spin_lock_irqsave(&info->lock, flags);
                /* MY PROBLEM */
if (info != current->asmp->cpu) {
spin_unlock_irqrestore(&info->lock, flags);
goto restart;
}
WARN_ON(info->shielded != 1);
WARN_ON(info->num_tasks == 0);
p->asmp->cpu = info;
list_add_tail(&p->asmp->list, &info->tasks);
++info->num_tasks;
spin_unlock_irqrestore(&info->lock, flags);
}
=========================================
Please see the code with comments "/* MY PROBLEM */", since info is a
local variable,
even if this code was preempted or interrupted, when the attached
process resumes its
state, it will continues from where it was interrupted and the
"current" macro shold be the same.
So, Why should check "if (info != current->asmp->cpu) {" ?

Thanks in advance!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/