[linux-mm-cc] [PATCH] locking refinement

John McCabe-Dansted gmatht at gmail.com
Tue Apr 22 13:58:53 EDT 2008


On Mon, Apr 21, 2008 at 3:26 PM,  <nai.xia at gmail.com> wrote:
> +               cpu = smp_processor_id();

I think we should be using get_cpu() (and put_cpu()) here instead of
smp_processor_id() here. We do not appear to be holding any form of
lock here, so it would appear that the kernel could preempt us
otherwise.An example bug:
       int arr[NR_CPUS];
       arr[smp_processor_id()] = i;
       /* kernel preemption could happen here */
       j = arr[smp_processor_id()]   /* i and j are not equal as
   smp_processor_id() may not be the same */
is given at:
  http://www.ibm.com/developerworks/linux/library/l-inside.html#h3
And Documentation/preempt-locking.txt
  http://www.mjmwired.net/kernel/Documentation/preempt-locking.txt

-- 
John C. McCabe-Dansted
PhD Student
University of Western Australia


More information about the linux-mm-cc mailing list