lkml.org 
[lkml]   [2010]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectWhy should check "current" consistency?
From
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-03-08 03:23    [W:0.088 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site