title: Locking on Per CPU variable
body: <p>I am reading Linux Kernel Development by Robert Love and trying to understand the kernel synchronization mechanism. I am trying to understand some points related to the locking mechanism which is mentioned in the book as follows -</p>
  
  <hr>
  
  <p>"some situations do not require a spin lock, but do need kernel preemption disabled.The most frequent of these situations is per-processor data. If the data is unique to each processor, there might be no need to protect it with a lock because only that one processor can access the data. If no spin locks are held, the kernel is pre-emptive, and it would be possible for a newly scheduled task to access this same variable.</p>
  
  <p>Consequently, even if this were a uniprocessor computer, the variable could be accessed pseudo-concurrently by multiple processes. Normally, this variable would require a spin lock (to prevent true concurrency on multiprocessing machines). If this were a per- processor variable, however, it might not require a lock.To solve this, kernel preemption can be disabled via preempt_disable()"</p>
  
  <hr>
  
  <p>So considering a multiprocessor system here - 
  I understand that while per-cpu variable is being manipulated by the current process, another process may be scheduled due to SMP and try to manipulate the same per-cpu variable hence the preemption needs to be disabled as explained in the book. But one point I am not able to understand is that what if we only disable kernel preemption and the current process is trying to manipulate the per-cpu data and at the same time an interrupt occurred on the current processor and since the interrupt has not been disabled, CPU stops the current task and starts executing interrupt handler, Now this handler also want to manipulate the same per-cpu variable. So in this case the variable may ended up containing inconsistent data ?  </p>
  
  <p>So does that mean that the interrupt also needs to be disabled on the current processor if the per-cpu variable is also accessed from interrupt handler ? </p>
  
  <p>Platform: Linux on x86</p>