All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
@ 2010-09-16 22:35 ` Nicholas A. Bellinger
  0 siblings, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 22:35 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, Vasu Dev, Tim Chen, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie
  Cc: James Smart, Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke,
	Joe Eykholt, Christoph Hellwig, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

Greetings all,

This series contains the first round of a whole-sale conversion for droping
struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
that is protected by host_lock is scsi_cmd_get_serial)_.

The patches #2 -> #8 converts libiscsi, libsas, lpfc, qla4xxx, qla2xxx,
TCM_Loop, and libfc code to drop their own SHT->queuecommand() internal
host_lock unlock() + lock() optimization that certain high performance libs
and LLDs have adopted over the years.  The changes involved here are really
quite straight forward, but please note that none of this code has been tested
with actual hardware yet, and is intended for generating comments for the relivent
SCSI LLD driver maintainers and other interested folks.

There are probably still be more LLDs which use this optimization, so please
let me know if there is another piece of SHT->queuecommand() caller code that
does this legacy optimization and needs to be updated.  I will be sure to
CC the right driver maintainers and CC linux-scsi as I come across any more
conversions.

Many thanks to Vasu Dev and Tim Chen for their work in this area!!

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>

Nicholas Bellinger (8):
  scsi: Drop struct Scsi_Host->host_lock around SHT->queuecommand()
  libiscsi: Remove host_lock unlock() + lock() from
    iscsi_queuecommand()
  libsas: Remove host_lock unlock() + lock() from sas_queuecommand()
  lpfc: Remove host_lock unlock() + lock() from lpfc_queuecommand()
  qla4xxx: Remove host_lock unlock() + lock() from
    qla4xxx_queuecommand()
  qla2xxx: Remove host_lock unlock() + lock() from
    qla2xxx_queuecommand()
  tcm_loop: Remove host_lock unlock() + lock() from
    tcm_loop_queuecommand()
  libfc: Remove host_lock unlock() + lock() from fc_queuecommand()

 drivers/scsi/libfc/fc_fcp.c                    |    5 +----
 drivers/scsi/libiscsi.c                        |    4 ----
 drivers/scsi/libsas/sas_scsi_host.c            |    5 -----
 drivers/scsi/lpfc/lpfc_scsi.c                  |    2 --
 drivers/scsi/qla2xxx/qla_os.c                  |    7 ++-----
 drivers/scsi/qla4xxx/ql4_os.c                  |    8 +-------
 drivers/scsi/scsi.c                            |    3 ++-
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c |    7 -------
 8 files changed, 6 insertions(+), 35 deletions(-)

-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
@ 2010-09-16 22:35 ` Nicholas A. Bellinger
  0 siblings, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 22:35 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, Vasu Dev, Tim Chen, Andi Kleen
  Cc: James Smart, Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke,
	Joe Eykholt, Christoph Hellwig, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

Greetings all,

This series contains the first round of a whole-sale conversion for droping
struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
that is protected by host_lock is scsi_cmd_get_serial)_.

The patches #2 -> #8 converts libiscsi, libsas, lpfc, qla4xxx, qla2xxx,
TCM_Loop, and libfc code to drop their own SHT->queuecommand() internal
host_lock unlock() + lock() optimization that certain high performance libs
and LLDs have adopted over the years.  The changes involved here are really
quite straight forward, but please note that none of this code has been tested
with actual hardware yet, and is intended for generating comments for the relivent
SCSI LLD driver maintainers and other interested folks.

There are probably still be more LLDs which use this optimization, so please
let me know if there is another piece of SHT->queuecommand() caller code that
does this legacy optimization and needs to be updated.  I will be sure to
CC the right driver maintainers and CC linux-scsi as I come across any more
conversions.

Many thanks to Vasu Dev and Tim Chen for their work in this area!!

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>

Nicholas Bellinger (8):
  scsi: Drop struct Scsi_Host->host_lock around SHT->queuecommand()
  libiscsi: Remove host_lock unlock() + lock() from
    iscsi_queuecommand()
  libsas: Remove host_lock unlock() + lock() from sas_queuecommand()
  lpfc: Remove host_lock unlock() + lock() from lpfc_queuecommand()
  qla4xxx: Remove host_lock unlock() + lock() from
    qla4xxx_queuecommand()
  qla2xxx: Remove host_lock unlock() + lock() from
    qla2xxx_queuecommand()
  tcm_loop: Remove host_lock unlock() + lock() from
    tcm_loop_queuecommand()
  libfc: Remove host_lock unlock() + lock() from fc_queuecommand()

 drivers/scsi/libfc/fc_fcp.c                    |    5 +----
 drivers/scsi/libiscsi.c                        |    4 ----
 drivers/scsi/libsas/sas_scsi_host.c            |    5 -----
 drivers/scsi/lpfc/lpfc_scsi.c                  |    2 --
 drivers/scsi/qla2xxx/qla_os.c                  |    7 ++-----
 drivers/scsi/qla4xxx/ql4_os.c                  |    8 +-------
 drivers/scsi/scsi.c                            |    3 ++-
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c |    7 -------
 8 files changed, 6 insertions(+), 35 deletions(-)

-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 22:35 ` Nicholas A. Bellinger
  (?)
@ 2010-09-16 22:39 ` Nicholas A. Bellinger
  -1 siblings, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 22:39 UTC (permalink / raw)
  To: linux-scsi
  Cc: linux-kernel, Vasu Dev, Tim Chen, Andi Kleen, Matthew Wilcox,
	James Bottomley, Mike Christie, James Smart, Andrew Vasquez,
	FUJITA Tomonori, Hannes Reinecke, Joe Eykholt, Christoph Hellwig

On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> Greetings all,
> 
> This series contains the first round of a whole-sale conversion for droping
> struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> that is protected by host_lock is scsi_cmd_get_serial)_.
> 
> The patches #2 -> #8 converts libiscsi, libsas, lpfc, qla4xxx, qla2xxx,
> TCM_Loop, and libfc code to drop their own SHT->queuecommand() internal
> host_lock unlock() + lock() optimization that certain high performance libs
> and LLDs have adopted over the years.  The changes involved here are really
> quite straight forward, but please note that none of this code has been tested
> with actual hardware yet, and is intended for generating comments for the relivent
> SCSI LLD driver maintainers and other interested folks.
> 
> There are probably still be more LLDs which use this optimization, so please
> let me know if there is another piece of SHT->queuecommand() caller code that
> does this legacy optimization and needs to be updated.  I will be sure to
> CC the right driver maintainers and CC linux-scsi as I come across any more
> conversions.
> 
> Many thanks to Vasu Dev and Tim Chen for their work in this area!!

Also just FYI, I have pushed these changes into a branch here:

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=shortlog;h=refs/heads/drop-host_lock

Note that this tree is currently at .36-rc3, but will be jumping to -rc4
shortly.

Thanks!

--nab

> 
> Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
> 
> Nicholas Bellinger (8):
>   scsi: Drop struct Scsi_Host->host_lock around SHT->queuecommand()
>   libiscsi: Remove host_lock unlock() + lock() from
>     iscsi_queuecommand()
>   libsas: Remove host_lock unlock() + lock() from sas_queuecommand()
>   lpfc: Remove host_lock unlock() + lock() from lpfc_queuecommand()
>   qla4xxx: Remove host_lock unlock() + lock() from
>     qla4xxx_queuecommand()
>   qla2xxx: Remove host_lock unlock() + lock() from
>     qla2xxx_queuecommand()
>   tcm_loop: Remove host_lock unlock() + lock() from
>     tcm_loop_queuecommand()
>   libfc: Remove host_lock unlock() + lock() from fc_queuecommand()
> 
>  drivers/scsi/libfc/fc_fcp.c                    |    5 +----
>  drivers/scsi/libiscsi.c                        |    4 ----
>  drivers/scsi/libsas/sas_scsi_host.c            |    5 -----
>  drivers/scsi/lpfc/lpfc_scsi.c                  |    2 --
>  drivers/scsi/qla2xxx/qla_os.c                  |    7 ++-----
>  drivers/scsi/qla4xxx/ql4_os.c                  |    8 +-------
>  drivers/scsi/scsi.c                            |    3 ++-
>  drivers/target/tcm_loop/tcm_loop_fabric_scsi.c |    7 -------
>  8 files changed, 6 insertions(+), 35 deletions(-)
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 22:35 ` Nicholas A. Bellinger
  (?)
  (?)
@ 2010-09-16 23:01 ` Nicholas A. Bellinger
  2010-09-16 23:18   ` Nicholas A. Bellinger
  -1 siblings, 1 reply; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 23:01 UTC (permalink / raw)
  To: linux-scsi
  Cc: linux-kernel, Vasu Dev, Tim Chen, Andi Kleen, Matthew Wilcox,
	James Bottomley, Mike Christie, James Smart, Andrew Vasquez,
	FUJITA Tomonori, Hannes Reinecke, Joe Eykholt, Christoph Hellwig

On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> Greetings all,
> 
> This series contains the first round of a whole-sale conversion for droping
> struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> that is protected by host_lock is scsi_cmd_get_serial)_.
> 
> The patches #2 -> #8 converts libiscsi, libsas, lpfc, qla4xxx, qla2xxx,
> TCM_Loop, and libfc code to drop their own SHT->queuecommand() internal
> host_lock unlock() + lock() optimization that certain high performance libs
> and LLDs have adopted over the years.  The changes involved here are really
> quite straight forward, but please note that none of this code has been tested
> with actual hardware yet, and is intended for generating comments for the relivent
> SCSI LLD driver maintainers and other interested folks.
> 
> There are probably still be more LLDs which use this optimization, so please
> let me know if there is another piece of SHT->queuecommand() caller code that
> does this legacy optimization and needs to be updated.  I will be sure to
> CC the right driver maintainers and CC linux-scsi as I come across any more
> conversions.

Hi Guys,

drivers/scsi/fnic needs the conversion as well..  Here is that patch;

http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=commitdiff;h=3c886b2ab6faccbe2803094deb7a9647199e5118

Thanks!

--nab


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 23:01 ` Nicholas A. Bellinger
@ 2010-09-16 23:18   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 23:18 UTC (permalink / raw)
  To: linux-scsi
  Cc: linux-kernel, Vasu Dev, Tim Chen, Andi Kleen, Matthew Wilcox,
	James Bottomley, Mike Christie, James Smart, Andrew Vasquez,
	FUJITA Tomonori, Hannes Reinecke, Joe Eykholt, Christoph Hellwig,
	Jeff Garzik

On Thu, 2010-09-16 at 16:01 -0700, Nicholas A. Bellinger wrote:
> On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > 
> > Greetings all,
> > 
> > This series contains the first round of a whole-sale conversion for droping
> > struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> > scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> > that is protected by host_lock is scsi_cmd_get_serial)_.
> > 
> > The patches #2 -> #8 converts libiscsi, libsas, lpfc, qla4xxx, qla2xxx,
> > TCM_Loop, and libfc code to drop their own SHT->queuecommand() internal
> > host_lock unlock() + lock() optimization that certain high performance libs
> > and LLDs have adopted over the years.  The changes involved here are really
> > quite straight forward, but please note that none of this code has been tested
> > with actual hardware yet, and is intended for generating comments for the relivent
> > SCSI LLD driver maintainers and other interested folks.
> > 
> > There are probably still be more LLDs which use this optimization, so please
> > let me know if there is another piece of SHT->queuecommand() caller code that
> > does this legacy optimization and needs to be updated.  I will be sure to
> > CC the right driver maintainers and CC linux-scsi as I come across any more
> > conversions.
> 
> Hi Guys,
> 
> drivers/scsi/fnic needs the conversion as well..  Here is that patch;
> 
> http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=commitdiff;h=3c886b2ab6faccbe2803094deb7a9647199e5118
> 

Ok, after doing some more digging the BusLogic and the ever important
libata SCSI glue code use the legacy host_lock unlock() -> do_work ->
lock() optimization as well.  Here are those patches (jgarzik CC'ed):

buslogic: Remove host_lock unlock() + lock() from BusLogic_QueueCommand()
http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=commitdiff;h=b465dfeb8e6950faa9c074681c72ca0a6c21276c

libata: Remove host_lock unlock() + lock() from ata_scsi_queuecmd()
http://git.kernel.org/?p=linux/kernel/git/nab/lio-core-2.6.git;a=commitdiff;h=29f2ded8876910d7eb84e4d270188de6f8a8c8ee

Thanks!

--nab


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 22:35 ` Nicholas A. Bellinger
@ 2010-09-16 23:26   ` Chetan Loke
  -1 siblings, 0 replies; 13+ messages in thread
From: Chetan Loke @ 2010-09-16 23:26 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: linux-scsi, linux-kernel, Vasu Dev, Tim Chen, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie, James Smart,
	Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke, Joe Eykholt,
	Christoph Hellwig

On Thu, Sep 16, 2010 at 6:35 PM, Nicholas A. Bellinger
<nab@linux-iscsi.org> wrote:

> and LLDs have adopted over the years.  The changes involved here are really
> quite straight forward, but please note that none of this code has been tested
> with actual hardware yet, and is intended for generating comments for the relivent
> SCSI LLD driver maintainers and other interested folks.
>

NO. Why not try testing it w/ an abort storm first else we will
seriously end up screwing the filesystems....

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
@ 2010-09-16 23:26   ` Chetan Loke
  0 siblings, 0 replies; 13+ messages in thread
From: Chetan Loke @ 2010-09-16 23:26 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: linux-scsi, linux-kernel, Vasu Dev, Tim Chen, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie, James Smart,
	Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke, Joe Eykholt,
	Christoph Hellwig

On Thu, Sep 16, 2010 at 6:35 PM, Nicholas A. Bellinger
<nab@linux-iscsi.org> wrote:

> and LLDs have adopted over the years.  The changes involved here are really
> quite straight forward, but please note that none of this code has been tested
> with actual hardware yet, and is intended for generating comments for the relivent
> SCSI LLD driver maintainers and other interested folks.
>

NO. Why not try testing it w/ an abort storm first else we will
seriously end up screwing the filesystems....
--
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] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 23:26   ` Chetan Loke
  (?)
@ 2010-09-16 23:28   ` Nicholas A. Bellinger
  -1 siblings, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-16 23:28 UTC (permalink / raw)
  To: Chetan Loke
  Cc: linux-scsi, linux-kernel, Vasu Dev, Tim Chen, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie, James Smart,
	Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke, Joe Eykholt,
	Christoph Hellwig

On Thu, 2010-09-16 at 19:26 -0400, Chetan Loke wrote:
> On Thu, Sep 16, 2010 at 6:35 PM, Nicholas A. Bellinger
> <nab@linux-iscsi.org> wrote:
> 
> > and LLDs have adopted over the years.  The changes involved here are really
> > quite straight forward, but please note that none of this code has been tested
> > with actual hardware yet, and is intended for generating comments for the relivent
> > SCSI LLD driver maintainers and other interested folks.
> >
> 
> NO. Why not try testing it w/ an abort storm first else we will
> seriously end up screwing the filesystems....

The only real issue here would be an immediate struct
Scsi_Host->host_lock dead lock for those LLDs that still use legacy
unlock() > do_work() -> lock() in their SHT->queuecommand() caller.
This is *not* going to happen under heavy load with a bunch of
outstanding WRITEs, but immediate the first couple of times that
scsi_dispatch_cmd() gets called, so there is really little to no fear of
filesystem corruption with these patches.

Anyways, please feel free to test them yourself with an TMR ABORT storm
if you so desire..

Best,

--nab


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-16 22:35 ` Nicholas A. Bellinger
                   ` (3 preceding siblings ...)
  (?)
@ 2010-09-17  1:29 ` Tim Chen
  2010-09-17  1:31   ` Nicholas A. Bellinger
  -1 siblings, 1 reply; 13+ messages in thread
From: Tim Chen @ 2010-09-17  1:29 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: linux-scsi, linux-kernel, Vasu Dev, Andi Kleen, Matthew Wilcox,
	James Bottomley, Mike Christie, James Smart, Andrew Vasquez,
	FUJITA Tomonori, Hannes Reinecke, Joe Eykholt, Christoph Hellwig

On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> Greetings all,
> 
> This series contains the first round of a whole-sale conversion for droping
> struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> that is protected by host_lock is scsi_cmd_get_serial)_.
> 

Maybe we can change the host->cmd_serial_number to atomic and totally
avoid the need to take host_lock.

Tim


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-17  1:29 ` Tim Chen
@ 2010-09-17  1:31   ` Nicholas A. Bellinger
  2010-09-17 18:26     ` Jeff Garzik
  0 siblings, 1 reply; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-17  1:31 UTC (permalink / raw)
  To: Tim Chen
  Cc: linux-scsi, linux-kernel, Vasu Dev, Andi Kleen, Matthew Wilcox,
	James Bottomley, Mike Christie, James Smart, Andrew Vasquez,
	FUJITA Tomonori, Hannes Reinecke, Joe Eykholt, Christoph Hellwig

On Thu, 2010-09-16 at 18:29 -0700, Tim Chen wrote:
> On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> > 
> > Greetings all,
> > 
> > This series contains the first round of a whole-sale conversion for droping
> > struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> > scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> > that is protected by host_lock is scsi_cmd_get_serial)_.
> > 
> 
> Maybe we can change the host->cmd_serial_number to atomic and totally
> avoid the need to take host_lock.

Hmmmm good point, then we would also need an atomic_t for signaling
(shost_state == SHOST_DEL) in scsi_dispatch_cmd() to be able to
completly drop host_lock usage within scsi_dispatch_cmd().

I can take a look at doing this specific part, if you would be willing
to have a look at the host->cmd_serial_number conversion piece.  ;)

Thanks Tim!

--nab



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-17 18:26     ` Jeff Garzik
@ 2010-09-17 18:24       ` Nicholas A. Bellinger
  2010-09-17 19:01       ` Tim Chen
  1 sibling, 0 replies; 13+ messages in thread
From: Nicholas A. Bellinger @ 2010-09-17 18:24 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Tim Chen, linux-scsi, linux-kernel, Vasu Dev, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie, James Smart,
	Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke, Joe Eykholt,
	Christoph Hellwig

On Fri, 2010-09-17 at 14:26 -0400, Jeff Garzik wrote:
> On 09/16/2010 09:31 PM, Nicholas A. Bellinger wrote:
> > On Thu, 2010-09-16 at 18:29 -0700, Tim Chen wrote:
> >> On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
> >>> From: Nicholas Bellinger<nab@linux-iscsi.org>
> >>>
> >>> Greetings all,
> >>>
> >>> This series contains the first round of a whole-sale conversion for droping
> >>> struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
> >>> scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
> >>> that is protected by host_lock is scsi_cmd_get_serial)_.
> >>>
> >>
> >> Maybe we can change the host->cmd_serial_number to atomic and totally
> >> avoid the need to take host_lock.
> >
> > Hmmmm good point, then we would also need an atomic_t for signaling
> > (shost_state == SHOST_DEL) in scsi_dispatch_cmd() to be able to
> > completly drop host_lock usage within scsi_dispatch_cmd().
> >
> > I can take a look at doing this specific part, if you would be willing
> > to have a look at the host->cmd_serial_number conversion piece.  ;)
> 
> But that raises the familiar tale of:  using multiple atomics (w/ their 
> locked instructions) may cost more than a spinlock.

So patch #1 in the v2 series just posted uses the following code:

static inline void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd)
{
        /*
         * The use of per struct scsi_cmnd->serial_number is disabled by default
         */
        if (!(host->use_serial_number))
                return;
        /*
         * Increment the host->cmd_serial_number by 2 so cmd->serial_number
         * is always odd and wraps to 1 instead of 0.
         */
        cmd->serial_number = atomic_add_return(2, &host->cmd_serial_number);
}


Note that host->use_serial_number is disabled by default, so for the typical case
no atomic_t reading (or writing) is required.

Best,

--nab



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-17  1:31   ` Nicholas A. Bellinger
@ 2010-09-17 18:26     ` Jeff Garzik
  2010-09-17 18:24       ` Nicholas A. Bellinger
  2010-09-17 19:01       ` Tim Chen
  0 siblings, 2 replies; 13+ messages in thread
From: Jeff Garzik @ 2010-09-17 18:26 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: Tim Chen, linux-scsi, linux-kernel, Vasu Dev, Andi Kleen,
	Matthew Wilcox, James Bottomley, Mike Christie, James Smart,
	Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke, Joe Eykholt,
	Christoph Hellwig

On 09/16/2010 09:31 PM, Nicholas A. Bellinger wrote:
> On Thu, 2010-09-16 at 18:29 -0700, Tim Chen wrote:
>> On Thu, 2010-09-16 at 15:35 -0700, Nicholas A. Bellinger wrote:
>>> From: Nicholas Bellinger<nab@linux-iscsi.org>
>>>
>>> Greetings all,
>>>
>>> This series contains the first round of a whole-sale conversion for droping
>>> struct Scsi_Host->host_lock around struct Scsi_Host->queuecommand() within
>>> scsi_dispatch_cmd().  So with this first patch the only part of scsi_dispatch_cmd()
>>> that is protected by host_lock is scsi_cmd_get_serial)_.
>>>
>>
>> Maybe we can change the host->cmd_serial_number to atomic and totally
>> avoid the need to take host_lock.
>
> Hmmmm good point, then we would also need an atomic_t for signaling
> (shost_state == SHOST_DEL) in scsi_dispatch_cmd() to be able to
> completly drop host_lock usage within scsi_dispatch_cmd().
>
> I can take a look at doing this specific part, if you would be willing
> to have a look at the host->cmd_serial_number conversion piece.  ;)

But that raises the familiar tale of:  using multiple atomics (w/ their 
locked instructions) may cost more than a spinlock.

	Jeff




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller
  2010-09-17 18:26     ` Jeff Garzik
  2010-09-17 18:24       ` Nicholas A. Bellinger
@ 2010-09-17 19:01       ` Tim Chen
  1 sibling, 0 replies; 13+ messages in thread
From: Tim Chen @ 2010-09-17 19:01 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Nicholas A. Bellinger, linux-scsi, linux-kernel, Vasu Dev,
	Andi Kleen, Matthew Wilcox, James Bottomley, Mike Christie,
	James Smart, Andrew Vasquez, FUJITA Tomonori, Hannes Reinecke,
	Joe Eykholt, Christoph Hellwig

On Fri, 2010-09-17 at 14:26 -0400, Jeff Garzik wrote:

> 
> But that raises the familiar tale of:  using multiple atomics (w/ their 
> locked instructions) may cost more than a spinlock.
> 

As brought up by James earlier, the scsi_host lock was used in so many
places that getting rid of it here to reduce contention for it will be a
net win, even with the cost of the atomics.  And for most LLDs that
don't need the serial number, we can just initialize it to zero for
those and have no need to increment it (thus also avoiding the atomics'
cost).

Tim


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-17 19:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16 22:35 [PATCH 0/8] Drop host_lock around LLD SHT->queuecommand() caller Nicholas A. Bellinger
2010-09-16 22:35 ` Nicholas A. Bellinger
2010-09-16 22:39 ` Nicholas A. Bellinger
2010-09-16 23:01 ` Nicholas A. Bellinger
2010-09-16 23:18   ` Nicholas A. Bellinger
2010-09-16 23:26 ` Chetan Loke
2010-09-16 23:26   ` Chetan Loke
2010-09-16 23:28   ` Nicholas A. Bellinger
2010-09-17  1:29 ` Tim Chen
2010-09-17  1:31   ` Nicholas A. Bellinger
2010-09-17 18:26     ` Jeff Garzik
2010-09-17 18:24       ` Nicholas A. Bellinger
2010-09-17 19:01       ` Tim Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.