RE: [PATCH] [SCSI] mpt2sas : Fix unsafe using smp_processor_id() inpreemptible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Accepted. 
Resent the patch.
Please see attached mail.

Regards,
Nagalakshmi


-----Original Message-----
From: Matthew Wilcox [mailto:matthew@xxxxxx] 
Sent: Wednesday, April 18, 2012 9:44 AM
To: Moore, Eric
Cc: Nandigama, Nagalakshmi; stable@xxxxxxxxxxxxxxx; linux-scsi@xxxxxxxxxxxxxxx; Prakash, Sathya; jejb@xxxxxxxxxx
Subject: Re: [PATCH] [SCSI] mpt2sas : Fix unsafe using smp_processor_id() in preemptible

On Tue, Apr 17, 2012 at 09:35:49PM -0600, Moore, Eric wrote:
>  Jan Schmidt suggested using raw_smp_processor_id()  back in February, see this: http://marc.info/?t=132974687100003&r=1&w=2
> 
> Alex Shi recently suggested using preempt_disable() and preempt_enable() to solve the same issue, see this: http://marc.info/?t=133274303900003&r=1&w=2
> 
> I believe the stack traces are there in both email discussion, they occur when CONFIG_DEBUG_PREEMPT is enabled.
> 
> I would rather go with the solution giving the best performance.   James Bottomley is there on the discussion with  Jan Schmidt, he suggested using get_cpu() and put_cpu().

I use get_cpu() / put_cpu() in the NVMe driver in similar circumstances.
It's not noticable in the profiles :-)

Where my usage differs from the patch for mpt2sas is that I hold a
reference to the CPU over the submission.  This works out well for
me because I have per-CPU state.  Might be worth considering for your
driver ...

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--- Begin Message ---
When CONFIG_DEBUG_PREEMPT is enabled, bug is observed in the smp_processor_id().
This is because smp_processor_id() is not called in preempt safe condition.

To fix this issue, use get_cpu() and put_cpu() instead of smp_processor_id.

Signed-off-by: Nagalakshmi Nandigama <nagalakshmi.nandigama@xxxxxxx>
CC: stable@xxxxxxxxxxxxxxx
---

diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index 272fab7..0f47f56 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -1792,7 +1792,10 @@ static inline void _base_writeq(__u64 b, volatile void __iomem *addr,
 static inline u8
 _base_get_msix_index(struct MPT2SAS_ADAPTER *ioc)
 {
-       return ioc->cpu_msix_table[smp_processor_id()];
+       int cpu = get_cpu();
+       put_cpu();
+       return ioc->cpu_msix_table[cpu];
+
 }

 /**

--- End Message ---

[SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Photos]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

Add to Google Powered by Linux