* [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
@ 2016-05-20 12:56 Ewan D. Milne
2016-05-20 14:33 ` Laurence Oberman
2016-05-23 9:19 ` Johannes Thumshirn
0 siblings, 2 replies; 3+ messages in thread
From: Ewan D. Milne @ 2016-05-20 12:56 UTC (permalink / raw)
To: linux-scsi
From: "Ewan D. Milne" <emilne@redhat.com>
A spinlock is sufficient for this purpose, and much smaller.
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
---
drivers/scsi/scsi.c | 8 ++++----
drivers/scsi/scsi_scan.c | 2 +-
include/scsi/scsi_device.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1deb6ad..330d807 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -829,11 +829,11 @@ retry_pg80:
kfree(vpd_buf);
goto retry_pg80;
}
- mutex_lock(&sdev->inquiry_mutex);
+ spin_lock(&sdev->inquiry_lock);
orig_vpd_buf = sdev->vpd_pg80;
sdev->vpd_pg80_len = result;
rcu_assign_pointer(sdev->vpd_pg80, vpd_buf);
- mutex_unlock(&sdev->inquiry_mutex);
+ spin_unlock(&sdev->inquiry_lock);
synchronize_rcu();
if (orig_vpd_buf) {
kfree(orig_vpd_buf);
@@ -858,11 +858,11 @@ retry_pg83:
kfree(vpd_buf);
goto retry_pg83;
}
- mutex_lock(&sdev->inquiry_mutex);
+ spin_lock(&sdev->inquiry_lock);
orig_vpd_buf = sdev->vpd_pg83;
sdev->vpd_pg83_len = result;
rcu_assign_pointer(sdev->vpd_pg83, vpd_buf);
- mutex_unlock(&sdev->inquiry_mutex);
+ spin_unlock(&sdev->inquiry_lock);
synchronize_rcu();
if (orig_vpd_buf)
kfree(orig_vpd_buf);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index e0a78f5..f445615 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -240,7 +240,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
INIT_LIST_HEAD(&sdev->starved_entry);
INIT_LIST_HEAD(&sdev->event_list);
spin_lock_init(&sdev->list_lock);
- mutex_init(&sdev->inquiry_mutex);
+ spin_lock_init(&sdev->inquiry_lock);
INIT_WORK(&sdev->event_work, scsi_evt_thread);
INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index a6c346d..0410ed8 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -115,7 +115,7 @@ struct scsi_device {
char type;
char scsi_level;
char inq_periph_qual; /* PQ from INQUIRY data */
- struct mutex inquiry_mutex;
+ spinlock_t inquiry_lock;
unsigned char inquiry_len; /* valid bytes in 'inquiry' */
unsigned char * inquiry; /* INQUIRY response data */
const char * vendor; /* [back_compat] point into 'inquiry' ... */
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
2016-05-20 12:56 [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data Ewan D. Milne
@ 2016-05-20 14:33 ` Laurence Oberman
2016-05-23 9:19 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Laurence Oberman @ 2016-05-20 14:33 UTC (permalink / raw)
To: Ewan D. Milne; +Cc: linux-scsi
----- Original Message -----
> From: "Ewan D. Milne" <emilne@redhat.com>
> To: linux-scsi@vger.kernel.org
> Sent: Friday, May 20, 2016 8:56:14 AM
> Subject: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
>
> From: "Ewan D. Milne" <emilne@redhat.com>
>
> A spinlock is sufficient for this purpose, and much smaller.
>
> Signed-off-by: Ewan D. Milne <emilne@redhat.com>
> ---
> drivers/scsi/scsi.c | 8 ++++----
> drivers/scsi/scsi_scan.c | 2 +-
> include/scsi/scsi_device.h | 2 +-
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 1deb6ad..330d807 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -829,11 +829,11 @@ retry_pg80:
> kfree(vpd_buf);
> goto retry_pg80;
> }
> - mutex_lock(&sdev->inquiry_mutex);
> + spin_lock(&sdev->inquiry_lock);
> orig_vpd_buf = sdev->vpd_pg80;
> sdev->vpd_pg80_len = result;
> rcu_assign_pointer(sdev->vpd_pg80, vpd_buf);
> - mutex_unlock(&sdev->inquiry_mutex);
> + spin_unlock(&sdev->inquiry_lock);
> synchronize_rcu();
> if (orig_vpd_buf) {
> kfree(orig_vpd_buf);
> @@ -858,11 +858,11 @@ retry_pg83:
> kfree(vpd_buf);
> goto retry_pg83;
> }
> - mutex_lock(&sdev->inquiry_mutex);
> + spin_lock(&sdev->inquiry_lock);
> orig_vpd_buf = sdev->vpd_pg83;
> sdev->vpd_pg83_len = result;
> rcu_assign_pointer(sdev->vpd_pg83, vpd_buf);
> - mutex_unlock(&sdev->inquiry_mutex);
> + spin_unlock(&sdev->inquiry_lock);
> synchronize_rcu();
> if (orig_vpd_buf)
> kfree(orig_vpd_buf);
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index e0a78f5..f445615 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -240,7 +240,7 @@ static struct scsi_device *scsi_alloc_sdev(struct
> scsi_target *starget,
> INIT_LIST_HEAD(&sdev->starved_entry);
> INIT_LIST_HEAD(&sdev->event_list);
> spin_lock_init(&sdev->list_lock);
> - mutex_init(&sdev->inquiry_mutex);
> + spin_lock_init(&sdev->inquiry_lock);
> INIT_WORK(&sdev->event_work, scsi_evt_thread);
> INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue);
>
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index a6c346d..0410ed8 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -115,7 +115,7 @@ struct scsi_device {
> char type;
> char scsi_level;
> char inq_periph_qual; /* PQ from INQUIRY data */
> - struct mutex inquiry_mutex;
> + spinlock_t inquiry_lock;
> unsigned char inquiry_len; /* valid bytes in 'inquiry' */
> unsigned char * inquiry; /* INQUIRY response data */
> const char * vendor; /* [back_compat] point into 'inquiry' ... */
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Look fine to me:
Reviewed by: Laurence Oberman <loberman@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data
2016-05-20 12:56 [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data Ewan D. Milne
2016-05-20 14:33 ` Laurence Oberman
@ 2016-05-23 9:19 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2016-05-23 9:19 UTC (permalink / raw)
To: Ewan D. Milne; +Cc: linux-scsi
On Fri, May 20, 2016 at 08:56:14AM -0400, Ewan D. Milne wrote:
> From: "Ewan D. Milne" <emilne@redhat.com>
>
> A spinlock is sufficient for this purpose, and much smaller.
>
> Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-23 9:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-20 12:56 [PATCH] scsi: use spinlock instead of mutex for RCU-protected VPD inquiry data Ewan D. Milne
2016-05-20 14:33 ` Laurence Oberman
2016-05-23 9:19 ` Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox