scsi/block: NUMA-local scan allocations, shared-tag path cleanup, and SCSI I/O counters
Subsystems (54)
Sumit Saxena
maintainerv3 cover scsi/block: NUMA-local scan allocations, shared-tag path cleanup, and SCSI I/O counters
This series contains three performance improvements targeting the SCSI and block layers on multi-socket NUMA and heavily loaded SMP systems.
On multi-socket NUMA systems we observed extreme I/O throughput variance of 50-60% between runs. This series identifies and fixes two root causes:
cross-node memory accesses due to NUMA-unaware allocations in the scan path, and false sharing between hot atomic counters in struct request_queue and struct scsi_device.
Performance notes:
Tested on a dual-socket NUMA system (2x 32-core, 256 GB/socket) with an mpi3mr HBA, running fio (random read, 4K, QD 64, 16 jobs, 60 s, direct I/O). IOPS figures are in KIOPS (thousands of IOPS):
Configuration Avg KIOPS Range (KIOPS) Spread Baseline 6,255 4,200 - 6,700 ~37% Baseline + all patches 7,350 7,000 - 7,700 ~10%
Key findings:
These patches combinedly reduces the observed 50-60% run-to-run variance to under 10%, significantly improving workload predictability and improves IOPs by 16-18%.
No functional regressions observed.
Changes in v3
-------------
-Handled feedback from Bart Van Assche and John Garry.
-Added a patch for shost local NUMA allocation.
-Converted ioerr_cnt and iotmo_cnt atomic counters into per-cpu counters.
Changes in v2
--------------
Patch 1 — Same functional goal as v1 patch 1: NUMA-local scsi_device / scsi_target allocations in the scan path so steady-state I/O does not habitually touch remote memory when the host has a fixed DMA/NUMA affinity.
Patch 2 — Replaces v1’s ____cacheline_aligned_in_smp on nr_active_requests_shared_tags with removal of the shared-tag fairness throttling machinery (including hctx_may_queue(), blk_mq_hw_ctx.nr_active, and request_queue.nr_active_requests_shared_tags and their updates). This follows the earlier standalone proposal by Bart Van Assche [1], rebased for the current tree; it removes the high-frequency atomic accounting that motivated the v1 false-sharing workaround and, in our testing, improves IOPS on the order of roughly 16–18% for the shared-tag workload exercised.
Patch 3 — Replaces v1’s cache-line padding of iodone_cnt with percpu_counter for both iorequest_cnt and iodone_cnt, so submission and completion paths mostly update CPU-local state instead of bouncing a single cache line, without inflating struct scsi_device for SMP alignment.
Merge / review hints
--------------------
Patch 3 touches the block layer and should have block maintainer review; rest of patches are SCSI-oriented. Please route or Ack as your subsystem workflow requires.
Bart Van Assche (1):
block: drop shared-tag fairness throttling
James Rizzo (1):
scsi: scan: allocate sdev and starget on the NUMA node of the host
adapter
Sumit Saxena (2):
scsi: host: allocate struct Scsi_Host on the NUMA node of the host
adapter
scsi: use percpu counters for iostat counters in struct scsi_device
block/blk-core.c | 2 - block/blk-mq-debugfs.c | 22 ++++- block/blk-mq-tag.c | 4 - block/blk-mq.c | 17 +--- block/blk-mq.h | 100 ---------------------- drivers/scsi/3w-9xxx.c | 2 +- drivers/scsi/3w-sas.c | 2 +- drivers/scsi/3w-xxxx.c | 2 +- drivers/scsi/53c700.c | 2 +- drivers/scsi/BusLogic.c | 2 +- drivers/scsi/a100u2w.c | 2 +- drivers/scsi/a2091.c | 2 +- drivers/scsi/a3000.c | 2 +- drivers/scsi/aacraid/linit.c | 2 +- drivers/scsi/advansys.c | 6 +- drivers/scsi/aha152x.c | 2 +- drivers/scsi/aha1542.c | 2 +- drivers/scsi/aha1740.c | 2 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 2 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +- drivers/scsi/aic94xx/aic94xx_init.c | 2 +- drivers/scsi/am53c974.c | 2 +- drivers/scsi/arcmsr/arcmsr_hba.c | 3 +- drivers/scsi/arm/acornscsi.c | 2 +- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_1.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/oak.c | 2 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/atari_scsi.c | 2 +- drivers/scsi/atp870u.c | 2 +- drivers/scsi/bfa/bfad_im.c | 2 +- drivers/scsi/csiostor/csio_init.c | 4 +- drivers/scsi/dc395x.c | 2 +- drivers/scsi/dmx3191d.c | 2 +- drivers/scsi/elx/efct/efct_xport.c | 4 +- drivers/scsi/esas2r/esas2r_main.c | 2 +- drivers/scsi/fdomain.c | 2 +- drivers/scsi/fnic/fnic_main.c | 2 +- drivers/scsi/g_NCR5380.c | 2 +- drivers/scsi/gvp11.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/hosts.c | 6 +- drivers/scsi/hpsa.c | 2 +- drivers/scsi/hptiop.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- drivers/scsi/imm.c | 2 +- drivers/scsi/initio.c | 2 +- drivers/scsi/ipr.c | 2 +- drivers/scsi/ips.c | 2 +- drivers/scsi/isci/init.c | 2 +- drivers/scsi/jazz_esp.c | 2 +- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/mac53c94.c | 2 +- drivers/scsi/mac_esp.c | 2 +- drivers/scsi/mac_scsi.c | 2 +- drivers/scsi/megaraid.c | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/mesh.c | 2 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +- drivers/scsi/mvme147.c | 2 +- drivers/scsi/mvsas/mv_init.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/myrb.c | 2 +- drivers/scsi/myrs.c | 2 +- drivers/scsi/ncr53c8xx.c | 2 +- drivers/scsi/nsp32.c | 2 +- drivers/scsi/pcmcia/nsp_cs.c | 2 +- drivers/scsi/pcmcia/qlogic_stub.c | 2 +- drivers/scsi/pcmcia/sym53c500_cs.c | 2 +- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pmcraid.c | 2 +- drivers/scsi/ppa.c | 2 +- drivers/scsi/ps3rom.c | 2 +- drivers/scsi/qla1280.c | 2 +- drivers/scsi/qla2xxx/qla_mid.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 2 +- drivers/scsi/qlogicfas.c | 2 +- drivers/scsi/qlogicpti.c | 2 +- drivers/scsi/scsi_debug.c | 2 +- drivers/scsi/scsi_error.c | 4 +- drivers/scsi/scsi_lib.c | 10 +-- drivers/scsi/scsi_scan.c | 15 +++- drivers/scsi/scsi_sysfs.c | 23 +++-- drivers/scsi/sd.c | 2 +- drivers/scsi/sgiwd93.c | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- drivers/scsi/snic/snic_main.c | 2 +- drivers/scsi/stex.c | 2 +- drivers/scsi/storvsc_drv.c | 2 +- drivers/scsi/sun3_scsi.c | 2 +- drivers/scsi/sun3x_esp.c | 2 +- drivers/scsi/sun_esp.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- drivers/scsi/wd719x.c | 2 +- drivers/scsi/xen-scsifront.c | 2 +- drivers/scsi/zorro_esp.c | 2 +- include/linux/blk-mq.h | 6 -- include/linux/blkdev.h | 2 - include/scsi/libfc.h | 2 +- include/scsi/scsi_device.h | 9 +- include/scsi/scsi_host.h | 3 +- 110 files changed, 168 insertions(+), 258 deletions(-)
Signature · 1 line
2.43.7
Sumit Saxena
maintainerPATCH v3 1/4 scsi: scan: allocate sdev and starget on the NUMA node of the host adapter
From: James Rizzo <[email protected]>
When a host adapter is attached to a specific NUMA node, allocating scsi_device and scsi_target via kzalloc() may place them on a remote node. All hot-path I/O accesses to these structures then cross the NUMA interconnect, adding latency and consuming inter-node bandwidth.
Use kzalloc_node() with dev_to_node(shost->dma_dev) so allocations land on the same node as the HBA, reducing cross-node traffic and improving I/O performance on NUMA systems.
--- drivers/scsi/scsi_scan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/scsi_scan.c +4 -3
@@ -34,6 +34,7 @@#include <linux/kthread.h> #include <linux/spinlock.h> #include <linux/async.h> +#include <linux/topology.h> #include <linux/slab.h> #include <linux/unaligned.h>
@@ -287,8 +288,8 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,struct Scsi_Host *shost =dev_to_shost (starget->dev.parent);struct queue_limits lim; - sdev =kzalloc (sizeof (*sdev) + shost->transportt->device_size, -GFP_KERNEL ); + sdev =kzalloc_node (sizeof (*sdev) + shost->transportt->device_size, +GFP_KERNEL ,dev_to_node (shost->dma_dev));if (!sdev) goto out;
@@ -502,7 +503,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,struct scsi_target *found_target;int error, ref_got; - starget =kzalloc (size,GFP_KERNEL ); + starget =kzalloc_node (size,GFP_KERNEL ,dev_to_node (shost->dma_dev));if (!starget) {printk (KERN_ERR "%s: allocation failure\n" , __func__);return NULL ;
Signature · 1 line
2.43.7
Re: [PATCH v3 1/4] scsi: scan: allocate sdev and starget on the NUMA node of the host adapter
- huge trim
Quoted 9 lines · Sumit Saxena
From: James Rizzo<[email protected]>
When a host adapter is attached to a specific NUMA node, allocating
scsi_deviceandscsi_targetviakzalloc()may place them on a remote node. All hot-path I/O accesses to these structures then cross the NUMA interconnect, adding latency and consuming inter-node bandwidth.Use
kzalloc_node()withdev_to_node(shost->dma_dev)so allocations land on the same node as the HBA,
kzalloc_node() does not guarantee local NUMA node allocations, only tries
Quoted 5 lines
reducing cross-node traffic and improving
I/O performance on NUMA systems.Signed-off-by James Rizzo<[email protected]>Signed-off-by Sumit Saxena<[email protected]>
FWIW,
Re: [PATCH v3 1/4] scsi: scan: allocate sdev and starget on the NUMA node of the host adapter
In reply to Sumit SaxenaQuoted 11 lines · Sumit Saxena
From: James Rizzo <[email protected]>
When a host adapter is attached to a specific NUMA node, allocating
scsi_deviceandscsi_targetviakzalloc()may place them on a remote node. All hot-path I/O accesses to these structures then cross the NUMA interconnect, adding latency and consuming inter-node bandwidth.Use
kzalloc_node()withdev_to_node(shost->dma_dev)so allocations land on the same node as the HBA, reducing cross-node traffic and improving I/O performance on NUMA systems.
Quoted 6 lines
Signed-off-by James Rizzo <[email protected]>Signed-off-by Sumit Saxena <[email protected]>--- drivers/scsi/scsi_scan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Sumit Saxena
maintainerPATCH v3 2/4 scsi: host: allocate struct Scsi_Host on the NUMA node of the host adapter
In reply to Sumit Saxenascsi_host_alloc() used kzalloc(), which always picks an arbitrary node. Extend the function to accept a 'struct device *dev' parameter and use kzalloc_node() with dev_to_node(dev) so the Scsi_Host struct lands on the same NUMA node as the HBA, mirroring the treatment already applied to struct scsi_device, struct scsi_target, and shost_data.
When dev is NULL (legacy ISA/platform drivers without a dma_dev) the allocation falls back to NUMA_NO_NODE, preserving existing behaviour.
Update all in-tree callers:
- PCI-based HBA drivers pass &pdev->dev (or the equivalent struct member such as &phba->pcidev->dev, &h->pdev->dev, &ha->pdev->dev) so their host struct is placed on the adapter's node.
- Non-PCI drivers (ISA, Amiga, ARM PCMCIA, virtio, Hyper-V, PS3, …) pass NULL.
- libfc's libfc_host_alloc() inline helper passes NULL; FC drivers that want NUMA awareness can open-code the call with their pdev.
--- drivers/scsi/3w-9xxx.c | 2 +- drivers/scsi/3w-sas.c | 2 +- drivers/scsi/3w-xxxx.c | 2 +- drivers/scsi/53c700.c | 2 +- drivers/scsi/BusLogic.c | 2 +- drivers/scsi/a100u2w.c | 2 +- drivers/scsi/a2091.c | 2 +- drivers/scsi/a3000.c | 2 +- drivers/scsi/aacraid/linit.c | 2 +- drivers/scsi/advansys.c | 6 +++--- drivers/scsi/aha152x.c | 2 +- drivers/scsi/aha1542.c | 2 +- drivers/scsi/aha1740.c | 2 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 2 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +- drivers/scsi/aic94xx/aic94xx_init.c | 2 +- drivers/scsi/am53c974.c | 2 +- drivers/scsi/arcmsr/arcmsr_hba.c | 3 ++- drivers/scsi/arm/acornscsi.c | 2 +- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_1.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/oak.c | 2 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/atari_scsi.c | 2 +- drivers/scsi/atp870u.c | 2 +- drivers/scsi/bfa/bfad_im.c | 2 +- drivers/scsi/csiostor/csio_init.c | 4 ++-- drivers/scsi/dc395x.c | 2 +- drivers/scsi/dmx3191d.c | 2 +- drivers/scsi/elx/efct/efct_xport.c | 4 ++-- drivers/scsi/esas2r/esas2r_main.c | 2 +- drivers/scsi/fdomain.c | 2 +- drivers/scsi/fnic/fnic_main.c | 2 +- drivers/scsi/g_NCR5380.c | 2 +- drivers/scsi/gvp11.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/hosts.c | 6 ++++-- drivers/scsi/hpsa.c | 2 +- drivers/scsi/hptiop.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- drivers/scsi/imm.c | 2 +- drivers/scsi/initio.c | 2 +- drivers/scsi/ipr.c | 2 +- drivers/scsi/ips.c | 2 +- drivers/scsi/isci/init.c | 2 +- drivers/scsi/jazz_esp.c | 2 +- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/mac53c94.c | 2 +- drivers/scsi/mac_esp.c | 2 +- drivers/scsi/mac_scsi.c | 2 +- drivers/scsi/megaraid.c | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/mesh.c | 2 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/mvme147.c | 2 +- drivers/scsi/mvsas/mv_init.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/myrb.c | 2 +- drivers/scsi/myrs.c | 2 +- drivers/scsi/ncr53c8xx.c | 2 +- drivers/scsi/nsp32.c | 2 +- drivers/scsi/pcmcia/nsp_cs.c | 2 +- drivers/scsi/pcmcia/qlogic_stub.c | 2 +- drivers/scsi/pcmcia/sym53c500_cs.c | 2 +- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pmcraid.c | 2 +- drivers/scsi/ppa.c | 2 +- drivers/scsi/ps3rom.c | 2 +- drivers/scsi/qla1280.c | 2 +- drivers/scsi/qla2xxx/qla_mid.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 2 +- drivers/scsi/qlogicfas.c | 2 +- drivers/scsi/qlogicpti.c | 2 +- drivers/scsi/scsi_debug.c | 2 +- drivers/scsi/sgiwd93.c | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- drivers/scsi/snic/snic_main.c | 2 +- drivers/scsi/stex.c | 2 +- drivers/scsi/storvsc_drv.c | 2 +- drivers/scsi/sun3_scsi.c | 2 +- drivers/scsi/sun3x_esp.c | 2 +- drivers/scsi/sun_esp.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- drivers/scsi/wd719x.c | 2 +- drivers/scsi/xen-scsifront.c | 2 +- drivers/scsi/zorro_esp.c | 2 +- include/scsi/libfc.h | 2 +- include/scsi/scsi_host.h | 3 ++- 97 files changed, 107 insertions(+), 103 deletions(-)
drivers/scsi/3w-9xxx.c +1 -1
@@ -2021,7 +2021,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) goto out_disable_device; } - host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension)); + host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension), &pdev->dev);if (!host) {TW_PRINTK (host,TW_DRIVER ,0x24 ,"Failed to allocate memory for device extension" ); retval = -ENOMEM ;
drivers/scsi/3w-sas.c +1 -1
@@ -1576,7 +1576,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) goto out_disable_device; } - host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension)); + host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension), &pdev->dev);if (!host) {TW_PRINTK (host,TW_DRIVER ,0x19 ,"Failed to allocate memory for device extension" ); retval = -ENOMEM ;
drivers/scsi/3w-xxxx.c +1 -1
@@ -2268,7 +2268,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id) goto out_disable_device; } - host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension)); + host =scsi_host_alloc (&driver_template,sizeof (TW_Device_Extension), &pdev->dev);if (!host) {printk (KERN_WARNING "3w-xxxx: Failed to allocate memory for device extension." ); retval = -ENOMEM ;
drivers/scsi/53c700.c +1 -1
@@ -341,7 +341,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,if (tpnt->proc_name ==NULL ) tpnt->proc_name ="53c700" ; - host =scsi_host_alloc (tpnt,4 ); + host =scsi_host_alloc (tpnt,4 ,NULL );if (!host)return NULL ; memset(hostdata->slots, 0, sizeof(struct NCR_700_command_slot)
drivers/scsi/BusLogic.c +1 -1
@@ -2302,7 +2302,7 @@ static int __init blogic_init(void)*/ host =scsi_host_alloc (&blogic_template, -sizeof (struct blogic_adapter )); +sizeof (struct blogic_adapter ),NULL );if (host ==NULL ) {release_region (myadapter->io_addr, myadapter->addr_count);
drivers/scsi/a100u2w.c +1 -1
@@ -1106,7 +1106,7 @@ static int inia100_probe_one(struct pci_dev *pdev, bios =inw (port +0x50 ); - shost =scsi_host_alloc (&inia100_template,sizeof (struct orc_host )); + shost =scsi_host_alloc (&inia100_template,sizeof (struct orc_host ), &pdev->dev);if (!shost) goto out_release_region;
drivers/scsi/a2091.c +1 -1
@@ -214,7 +214,7 @@ static int a2091_probe(struct zorro_dev *z, const struct zorro_device_id *ent)return -EBUSY ; instance =scsi_host_alloc (&a2091_scsi_template, -sizeof (struct a2091_hostdata )); +sizeof (struct a2091_hostdata ),NULL );if (!instance) { error = -ENOMEM ; goto fail_alloc;
drivers/scsi/a3000.c +1 -1
@@ -235,7 +235,7 @@ static int __init amiga_a3000_scsi_probe(struct platform_device *pdev)return -EBUSY ; instance =scsi_host_alloc (&amiga_a3000_scsi_template, -sizeof (struct a3000_hostdata )); +sizeof (struct a3000_hostdata ),NULL );if (!instance) { error = -ENOMEM ; goto fail_alloc;
drivers/scsi/aacraid/linit.c +1 -1
@@ -1636,7 +1636,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_master (pdev); - shost =scsi_host_alloc (&aac_driver_template,sizeof (struct aac_dev )); + shost =scsi_host_alloc (&aac_driver_template,sizeof (struct aac_dev ), &pdev->dev);if (!shost) { error = -ENOMEM ; goto out_disable_pdev;
drivers/scsi/advansys.c +3 -3
@@ -11237,7 +11237,7 @@ static int advansys_vlb_probe(struct device *dev, unsigned int id) goto release_region; err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =scsi_host_alloc (&advansys_template,sizeof (*board),NULL );if (!shost) goto release_region;
@@ -11345,7 +11345,7 @@ static int advansys_eisa_probe(struct device *dev) irq =advansys_eisa_irq_no (edev); err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =scsi_host_alloc (&advansys_template,sizeof (*board),NULL );if (!shost) goto release_region;
@@ -11462,7 +11462,7 @@ static int advansys_pci_probe(struct pci_dev *pdev, ioport =pci_resource_start (pdev,0 ); err = -ENOMEM ; - shost =scsi_host_alloc (&advansys_template,sizeof (*board)); + shost =scsi_host_alloc (&advansys_template,sizeof (*board), &pdev->dev);if (!shost) goto release_region;
drivers/scsi/aha152x.c +1 -1
@@ -734,7 +734,7 @@ struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *setup) {struct Scsi_Host *shpnt; - shpnt =scsi_host_alloc (&aha152x_driver_template,sizeof (struct aha152x_hostdata )); + shpnt =scsi_host_alloc (&aha152x_driver_template,sizeof (struct aha152x_hostdata ),NULL );if (!shpnt) {printk (KERN_ERR "aha152x: scsi_host_alloc failed\n" );return NULL ;
drivers/scsi/aha1542.c +1 -1
@@ -752,7 +752,7 @@ static struct Scsi_Host *aha1542_hw_init(const struct scsi_host_template *tpnt,if (!request_region (base_io,AHA1542_REGION_SIZE ,"aha1542" ))return NULL ; - sh =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata )); + sh =scsi_host_alloc (tpnt,sizeof (struct aha1542_hostdata ),NULL );if (!sh) goto release; aha1542 =shost_priv (sh);
drivers/scsi/aha1740.c +1 -1
@@ -583,7 +583,7 @@ static int aha1740_probe (struct device *dev)printk (KERN_INFO "aha174x: Extended translation %sabled.\n" , translation ?"en" :"dis" ); shpnt =scsi_host_alloc (&aha1740_template, -sizeof (struct aha1740_hostdata )); +sizeof (struct aha1740_hostdata ),NULL );if (shpnt ==NULL ) goto err_release_region;
drivers/scsi/aic7xxx/aic79xx_osm.c +1 -1
@@ -1214,7 +1214,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templaint retval; template->name = ahd->description; - host =scsi_host_alloc (template,sizeof (struct ahd_softc *)); + host =scsi_host_alloc (template,sizeof (struct ahd_softc *),NULL );if (host ==NULL )return (ENOMEM );
drivers/scsi/aic7xxx/aic7xxx_osm.c +1 -1
@@ -1083,7 +1083,7 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templaint retval; template->name = ahc->description; - host =scsi_host_alloc (template,sizeof (struct ahc_softc *)); + host =scsi_host_alloc (template,sizeof (struct ahc_softc *),NULL );if (host ==NULL )return -ENOMEM ;
drivers/scsi/aic94xx/aic94xx_init.c +1 -1
@@ -704,7 +704,7 @@ static int asd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) err = -ENOMEM ; - shost =scsi_host_alloc (&aic94xx_sht,sizeof (void *)); + shost =scsi_host_alloc (&aic94xx_sht,sizeof (void *), &dev->dev);if (!shost) goto Err;
drivers/scsi/am53c974.c +1 -1
@@ -388,7 +388,7 @@ static int pci_esp_probe_one(struct pci_dev *pdev, goto fail_disable_device; } - shost =scsi_host_alloc (hostt,sizeof (struct esp )); + shost =scsi_host_alloc (hostt,sizeof (struct esp ), &pdev->dev);if (!shost) {dev_printk (KERN_INFO , &pdev->dev,"failed to allocate scsi host\n" );
drivers/scsi/arcmsr/arcmsr_hba.c +2 -1
@@ -1087,7 +1087,8 @@ static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (error){return -ENODEV ; } - host =scsi_host_alloc (&arcmsr_scsi_host_template,sizeof (struct AdapterControlBlock )); + host =scsi_host_alloc (&arcmsr_scsi_host_template, +sizeof (struct AdapterControlBlock ), &pdev->dev);if (!host){ goto pci_disable_dev; }
drivers/scsi/arm/acornscsi.c +1 -1
@@ -2806,7 +2806,7 @@ static int acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id)if (ret) goto out; - host =scsi_host_alloc (&acornscsi_template,sizeof (AS_Host)); + host =scsi_host_alloc (&acornscsi_template,sizeof (AS_Host),NULL );if (!host) { ret = -ENOMEM ; goto out_release;
drivers/scsi/arm/arxescsi.c +1 -1
@@ -272,7 +272,7 @@ static int arxescsi_probe(struct expansion_card *ec, const struct ecard_id *id) goto out_region; } - host =scsi_host_alloc (&arxescsi_template,sizeof (struct arxescsi_info )); + host =scsi_host_alloc (&arxescsi_template,sizeof (struct arxescsi_info ),NULL );if (!host) { ret = -ENOMEM ; goto out_region;
drivers/scsi/arm/cumana_1.c +1 -1
@@ -238,7 +238,7 @@ static int cumanascsi1_probe(struct expansion_card *ec,if (ret) goto out; - host =scsi_host_alloc (&cumanascsi_template,sizeof (struct NCR5380_hostdata )); + host =scsi_host_alloc (&cumanascsi_template,sizeof (struct NCR5380_hostdata ),NULL );if (!host) { ret = -ENOMEM ; goto out_release;
drivers/scsi/arm/cumana_2.c +1 -1
@@ -394,7 +394,7 @@ static int cumanascsi2_probe(struct expansion_card *ec, } host =scsi_host_alloc (&cumanascsi2_template, -sizeof (struct cumanascsi2_info )); +sizeof (struct cumanascsi2_info ),NULL );if (!host) { ret = -ENOMEM ; goto out_region;
drivers/scsi/arm/eesox.c +1 -1
@@ -510,7 +510,7 @@ static int eesoxscsi_probe(struct expansion_card *ec, const struct ecard_id *id) } host =scsi_host_alloc (&eesox_template, -sizeof (struct eesoxscsi_info )); +sizeof (struct eesoxscsi_info ),NULL );if (!host) { ret = -ENOMEM ; goto out_region;
drivers/scsi/arm/oak.c +1 -1
@@ -126,7 +126,7 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)if (ret) goto out; - host =scsi_host_alloc (&oakscsi_template,sizeof (struct NCR5380_hostdata )); + host =scsi_host_alloc (&oakscsi_template,sizeof (struct NCR5380_hostdata ),NULL );if (!host) { ret = -ENOMEM ; goto release;
drivers/scsi/arm/powertec.c +1 -1
@@ -318,7 +318,7 @@ static int powertecscsi_probe(struct expansion_card *ec, } host =scsi_host_alloc (&powertecscsi_template, -sizeof (struct powertec_info )); +sizeof (struct powertec_info ),NULL );if (!host) { ret = -ENOMEM ; goto out_region;
drivers/scsi/atari_scsi.c +1 -1
@@ -785,7 +785,7 @@ static int __init atari_scsi_probe(struct platform_device *pdev) } instance =scsi_host_alloc (&atari_scsi_template, -sizeof (struct NCR5380_hostdata )); +sizeof (struct NCR5380_hostdata ),NULL );if (!instance) { error = -ENOMEM ; goto fail_alloc;
drivers/scsi/atp870u.c +1 -1
@@ -1579,7 +1579,7 @@ static int atp870u_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_set_master (pdev); err = -ENOMEM ; - shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit )); + shpnt =scsi_host_alloc (&atp870u_template,sizeof (struct atp_unit ), &pdev->dev);if (!shpnt) goto release_region;
drivers/scsi/bfa/bfad_im.c +1 -1
@@ -740,7 +740,7 @@ bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad) sht->sg_tablesize = bfad->cfg_data.io_max_sge; -return scsi_host_alloc (sht,sizeof (struct bfad_im_port_pointer )); +return scsi_host_alloc (sht,sizeof (struct bfad_im_port_pointer ),NULL ); }void
drivers/scsi/csiostor/csio_init.c +2 -2
@@ -606,11 +606,11 @@ csio_shost_init(struct csio_hw *hw, struct device *dev,if (dev == &hw->pdev->dev) shost =scsi_host_alloc ( &csio_fcoe_shost_template, -sizeof (struct csio_lnode )); +sizeof (struct csio_lnode ), &hw->pdev->dev);else shost =scsi_host_alloc ( &csio_fcoe_shost_vport_template, -sizeof (struct csio_lnode )); +sizeof (struct csio_lnode ), &hw->pdev->dev);if (!shost) goto err;
drivers/scsi/dc395x.c +1 -1
@@ -3984,7 +3984,7 @@ static int dc395x_init_one(struct pci_dev *dev, const struct pci_device_id *id)/* allocate scsi host information (includes out adapter) */ scsi_host =scsi_host_alloc (&dc395x_driver_template, -sizeof (struct AdapterCtlBlk )); +sizeof (struct AdapterCtlBlk ), &dev->dev);if (!scsi_host) goto fail;
drivers/scsi/dmx3191d.c +1 -1
@@ -74,7 +74,7 @@ static int dmx3191d_probe_one(struct pci_dev *pdev, } shost =scsi_host_alloc (&dmx3191d_driver_template, -sizeof (struct NCR5380_hostdata )); +sizeof (struct NCR5380_hostdata ), &pdev->dev);if (!shost) goto out_release_region;
drivers/scsi/elx/efct/efct_xport.c +2 -2
@@ -378,7 +378,7 @@ efct_scsi_new_device(struct efct *efct)int error =0 ;struct efct_vport *vport =NULL ; - shost =scsi_host_alloc (&efct_template,sizeof (*vport)); + shost =scsi_host_alloc (&efct_template,sizeof (*vport),NULL );if (!shost) {efc_log_err (efct,"failed to allocate Scsi_Host struct\n" );return -ENOMEM ;
@@ -902,7 +902,7 @@ efct_scsi_new_vport(struct efct *efct, struct device *dev)int error =0 ;struct efct_vport *vport =NULL ; - shost =scsi_host_alloc (&efct_template,sizeof (*vport)); + shost =scsi_host_alloc (&efct_template,sizeof (*vport),NULL );if (!shost) {efc_log_err (efct,"failed to allocate Scsi_Host struct\n" );return NULL ;
drivers/scsi/esas2r/esas2r_main.c +1 -1
@@ -382,7 +382,7 @@ static int esas2r_probe(struct pci_dev *pcid,"after pci_enable_device() enable_cnt: %d" , pcid->enable_cnt.counter); - host =scsi_host_alloc (&driver_template, host_alloc_size); + host =scsi_host_alloc (&driver_template, host_alloc_size, &pcid->dev);if (host ==NULL ) {esas2r_log (ESAS2R_LOG_CRIT ,"scsi_host_alloc() FAIL" );return -ENODEV ;
drivers/scsi/fdomain.c +1 -1
@@ -537,7 +537,7 @@ struct Scsi_Host *fdomain_create(int base, int irq, int this_id,return NULL ; } - sh =scsi_host_alloc (&fdomain_template,sizeof (struct fdomain )); + sh =scsi_host_alloc (&fdomain_template,sizeof (struct fdomain ),NULL );if (!sh)return NULL ;
drivers/scsi/fnic/fnic_main.c +1 -1
@@ -847,7 +847,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { host =scsi_host_alloc (&fnic_host_template, -sizeof (struct fnic *)); +sizeof (struct fnic *), &pdev->dev);if (!host) {dev_err (&fnic->pdev->dev,"Unable to allocate scsi host\n" ); err = -ENOMEM ;
drivers/scsi/g_NCR5380.c +1 -1
@@ -312,7 +312,7 @@ static int generic_NCR5380_init_one(const struct scsi_host_template *tpnt, goto out_release; } - instance =scsi_host_alloc (tpnt,sizeof (struct NCR5380_hostdata )); + instance =scsi_host_alloc (tpnt,sizeof (struct NCR5380_hostdata ),NULL );if (instance ==NULL ) { ret = -ENOMEM ; goto out_unmap;
drivers/scsi/gvp11.c +1 -1
@@ -353,7 +353,7 @@ static int gvp11_probe(struct zorro_dev *z, const struct zorro_device_id *ent) goto fail_check_or_alloc; instance =scsi_host_alloc (&gvp11_scsi_template, -sizeof (struct gvp11_hostdata )); +sizeof (struct gvp11_hostdata ),NULL );if (!instance) { error = -ENOMEM ; goto fail_check_or_alloc;
drivers/scsi/hisi_sas/hisi_sas_main.c +1 -1
@@ -2483,7 +2483,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,struct device *dev = &pdev->dev;int error; - shost =scsi_host_alloc (hw->sht,sizeof (*hisi_hba)); + shost =scsi_host_alloc (hw->sht,sizeof (*hisi_hba),NULL );if (!shost) {dev_err (dev,"scsi host alloc failed\n" );return NULL ;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -1
@@ -3469,7 +3469,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)struct hisi_hba *hisi_hba;struct device *dev = &pdev->dev; - shost =scsi_host_alloc (&sht_v3_hw,sizeof (*hisi_hba)); + shost =scsi_host_alloc (&sht_v3_hw,sizeof (*hisi_hba), &pdev->dev);if (!shost) {dev_err (dev,"shost alloc failed\n" );return NULL ;
drivers/scsi/hosts.c +4 -2
@@ -403,12 +403,14 @@ static const struct device_type scsi_host_type = {* Return value: * Pointer to a new Scsi_Host **/ -struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht,int privsize) +struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht,int privsize, +struct device *dev) {struct Scsi_Host *shost;int index; - shost =kzalloc (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL ); + shost =kzalloc_node (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL , + dev ?dev_to_node (dev) :NUMA_NO_NODE );if (!shost)return NULL ;
drivers/scsi/hpsa.c +1 -1
@@ -5837,7 +5837,7 @@ static int hpsa_scsi_host_alloc(struct ctlr_info *h) {struct Scsi_Host *sh; - sh =scsi_host_alloc (&hpsa_driver_template,sizeof (struct ctlr_info *)); + sh =scsi_host_alloc (&hpsa_driver_template,sizeof (struct ctlr_info *), &h->pdev->dev);if (sh ==NULL ) {dev_err (&h->pdev->dev,"scsi_host_alloc failed\n" );return -ENOMEM ;
drivers/scsi/hptiop.c +1 -1
@@ -1311,7 +1311,7 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id) goto disable_pci_device; } - host =scsi_host_alloc (&driver_template,sizeof (struct hptiop_hba )); + host =scsi_host_alloc (&driver_template,sizeof (struct hptiop_hba ), &pcidev->dev);if (!host) {printk (KERN_ERR "hptiop: fail to alloc scsi host\n" ); goto free_pci_regions;
drivers/scsi/ibmvscsi/ibmvfc.c +1 -1
@@ -6325,7 +6325,7 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)unsigned int max_scsi_queues =min ((unsigned int )IBMVFC_MAX_SCSI_QUEUES , online_cpus);ENTER ; - shost =scsi_host_alloc (&driver_template,sizeof (*vhost)); + shost =scsi_host_alloc (&driver_template,sizeof (*vhost),NULL );if (!shost) {dev_err (dev,"Couldn't allocate host data\n" ); goto out;
drivers/scsi/ibmvscsi/ibmvscsi.c +1 -1
@@ -2235,7 +2235,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)dev_set_drvdata (&vdev->dev,NULL ); - host =scsi_host_alloc (&driver_template,sizeof (*hostdata)); + host =scsi_host_alloc (&driver_template,sizeof (*hostdata),NULL );if (!host) {dev_err (&vdev->dev,"couldn't allocate host data\n" ); goto scsi_host_alloc_failed;
drivers/scsi/imm.c +1 -1
@@ -1221,7 +1221,7 @@ static int __imm_attach(struct parport *pb)INIT_DELAYED_WORK (&dev->imm_tq, imm_interrupt); err = -ENOMEM ; - host =scsi_host_alloc (&imm_template,sizeof (imm_struct *)); + host =scsi_host_alloc (&imm_template,sizeof (imm_struct *),NULL );if (!host) goto out1; host->io_port = pb->base;
drivers/scsi/initio.c +1 -1
@@ -2824,7 +2824,7 @@ static int initio_probe_one(struct pci_dev *pdev, error = -ENODEV ; goto out_disable_device; } - shost =scsi_host_alloc (&initio_template,sizeof (struct initio_host )); + shost =scsi_host_alloc (&initio_template,sizeof (struct initio_host ), &pdev->dev);if (!shost) {printk (KERN_WARNING "initio: Could not allocate host structure.\n" ); error = -ENOMEM ;
drivers/scsi/ipr.c +1 -1
@@ -9379,7 +9379,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,ENTER ;dev_info (&pdev->dev,"Found IOA with IRQ: %d\n" , pdev->irq); - host =scsi_host_alloc (&driver_template,sizeof (*ioa_cfg)); + host =scsi_host_alloc (&driver_template,sizeof (*ioa_cfg), &pdev->dev);if (!host) {dev_err (&pdev->dev,"call to scsi_host_alloc failed!\n" );
drivers/scsi/ips.c +1 -1
@@ -6638,7 +6638,7 @@ ips_register_scsi(int index) {struct Scsi_Host *sh;ips_ha_t *ha, *oldha = ips_ha[index]; - sh =scsi_host_alloc (&ips_driver_template,sizeof (ips_ha_t)); + sh =scsi_host_alloc (&ips_driver_template,sizeof (ips_ha_t), &oldha->pcidev->dev);if (!sh) {IPS_PRINTK (KERN_WARNING , oldha->pcidev,"Unable to register controller with SCSI subsystem\n" );
drivers/scsi/isci/init.c +1 -1
@@ -538,7 +538,7 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)INIT_LIST_HEAD (&idev->node); } - shost =scsi_host_alloc (&isci_sht,sizeof (void *)); + shost =scsi_host_alloc (&isci_sht,sizeof (void *), &pdev->dev);if (!shost)return NULL ;
drivers/scsi/jazz_esp.c +1 -1
@@ -110,7 +110,7 @@ static int esp_jazz_probe(struct platform_device *dev)struct resource *res;int err; - host =scsi_host_alloc (tpnt,sizeof (struct esp )); + host =scsi_host_alloc (tpnt,sizeof (struct esp ),NULL ); err = -ENOMEM ;if (!host)
drivers/scsi/libiscsi.c +1 -1
@@ -2903,7 +2903,7 @@ struct Scsi_Host *iscsi_host_alloc(const struct scsi_host_template *sht,struct Scsi_Host *shost;struct iscsi_host *ihost; - shost =scsi_host_alloc (sht,sizeof (struct iscsi_host ) + dd_data_size); + shost =scsi_host_alloc (sht,sizeof (struct iscsi_host ) + dd_data_size,NULL );if (!shost)return NULL ; ihost =shost_priv (shost);
drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -4745,7 +4745,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev) template->sg_tablesize =lpfc_get_sg_tablesize (phba); } - shost =scsi_host_alloc (template,sizeof (struct lpfc_vport )); + shost =scsi_host_alloc (template,sizeof (struct lpfc_vport ), &phba->pcidev->dev);if (!shost) goto out;
drivers/scsi/mac53c94.c +1 -1
@@ -426,7 +426,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *matreturn -EBUSY ; } - host =scsi_host_alloc (&mac53c94_template,sizeof (struct fsc_state )); + host =scsi_host_alloc (&mac53c94_template,sizeof (struct fsc_state ),NULL );if (host ==NULL ) {printk (KERN_ERR "mac53c94: couldn't register host" ); rc = -ENOMEM ;
drivers/scsi/mac_esp.c +1 -1
@@ -301,7 +301,7 @@ static int esp_mac_probe(struct platform_device *dev)if (dev->id >1 )return -ENODEV ; - host =scsi_host_alloc (tpnt,sizeof (struct esp )); + host =scsi_host_alloc (tpnt,sizeof (struct esp ),NULL ); err = -ENOMEM ;if (!host)
drivers/scsi/mac_scsi.c +1 -1
@@ -474,7 +474,7 @@ static int __init mac_scsi_probe(struct platform_device *pdev) mac_scsi_template.sg_tablesize =1 ; instance =scsi_host_alloc (&mac_scsi_template, -sizeof (struct NCR5380_hostdata )); +sizeof (struct NCR5380_hostdata ),NULL );if (!instance)return -ENOMEM ;
drivers/scsi/megaraid.c +1 -1
@@ -4203,7 +4203,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) }/* Initialize SCSI Host structure */ - host =scsi_host_alloc (&megaraid_template,sizeof (adapter_t)); + host =scsi_host_alloc (&megaraid_template,sizeof (adapter_t), &pdev->dev);if (!host) goto out_iounmap;
drivers/scsi/megaraid/megaraid_mbox.c +1 -1
@@ -620,7 +620,7 @@ megaraid_io_attach(adapter_t *adapter)struct Scsi_Host *host;// Initialize SCSI Host structure - host =scsi_host_alloc (&megaraid_template_g,8 ); + host =scsi_host_alloc (&megaraid_template_g,8 , &pdev->dev);if (!host) {con_log (CL_ANN , (KERN_WARNING "megaraid mbox: scsi_host_alloc failed\n" ));
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
@@ -7512,7 +7512,7 @@ static int megasas_probe_one(struct pci_dev *pdev,pci_set_master (pdev); host =scsi_host_alloc (&megasas_template, -sizeof (struct megasas_instance )); +sizeof (struct megasas_instance ), &pdev->dev);if (!host) {dev_printk (KERN_DEBUG , &pdev->dev,"scsi_host_alloc failed\n" );
drivers/scsi/mesh.c +1 -1
@@ -1877,7 +1877,7 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)printk (KERN_ERR "mesh: unable to request memory resources" );return -EBUSY ; } - mesh_host =scsi_host_alloc (&mesh_template,sizeof (struct mesh_state )); + mesh_host =scsi_host_alloc (&mesh_template,sizeof (struct mesh_state ),NULL );if (mesh_host ==NULL ) {printk (KERN_ERR "mesh: couldn't register host" ); goto out_release;
drivers/scsi/mpi3mr/mpi3mr_os.c +1 -1
@@ -5468,7 +5468,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) } shost =scsi_host_alloc (&mpi3mr_driver_template, -sizeof (struct mpi3mr_ioc )); +sizeof (struct mpi3mr_ioc ), &pdev->dev);if (!shost) { retval = -ENODEV ; goto shost_failed;
drivers/scsi/mpt3sas/mpt3sas_scsih.c +2 -2
@@ -13367,7 +13367,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);/* Use mpt2sas driver host template for SAS 2.0 HBA's */ shost =scsi_host_alloc (&mpt2sas_driver_template, -sizeof (struct MPT3SAS_ADAPTER )); +sizeof (struct MPT3SAS_ADAPTER ), &pdev->dev);if (!shost)return -ENODEV ; ioc =shost_priv (shost);
@@ -13399,7 +13399,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)case MPI26_VERSION :/* Use mpt3sas driver host template for SAS 3.0 HBA's */ shost =scsi_host_alloc (&mpt3sas_driver_template, -sizeof (struct MPT3SAS_ADAPTER )); +sizeof (struct MPT3SAS_ADAPTER ), &pdev->dev);if (!shost)return -ENODEV ; ioc =shost_priv (shost);
drivers/scsi/mvme147.c +1 -1
@@ -97,7 +97,7 @@ static int __init mvme147_init(void)return 0 ; mvme147_shost =scsi_host_alloc (&mvme147_host_template, -sizeof (struct WD33C93_hostdata )); +sizeof (struct WD33C93_hostdata ),NULL );if (!mvme147_shost) goto err_out; mvme147_shost->base =0xfffe4000 ;
drivers/scsi/mvsas/mv_init.c +1 -1
@@ -494,7 +494,7 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto err_out_regions; - shost =scsi_host_alloc (&mvs_sht,sizeof (void *)); + shost =scsi_host_alloc (&mvs_sht,sizeof (void *), &pdev->dev);if (!shost) { rc = -ENOMEM ; goto err_out_regions;
drivers/scsi/mvumi.c +1 -1
@@ -2468,7 +2468,7 @@ static int mvumi_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)if (ret) goto fail_set_dma_mask; - host =scsi_host_alloc (&mvumi_template,sizeof (*mhba)); + host =scsi_host_alloc (&mvumi_template,sizeof (*mhba), &pdev->dev);if (!host) {dev_err (&pdev->dev,"scsi_host_alloc failed\n" ); ret = -ENOMEM ;
drivers/scsi/myrb.c +1 -1
@@ -3401,7 +3401,7 @@ static struct myrb_hba *myrb_detect(struct pci_dev *pdev,struct Scsi_Host *shost;struct myrb_hba *cb =NULL ; - shost =scsi_host_alloc (&myrb_template,sizeof (struct myrb_hba )); + shost =scsi_host_alloc (&myrb_template,sizeof (struct myrb_hba ), &pdev->dev);if (!shost) {dev_err (&pdev->dev,"Unable to allocate Controller\n" );return NULL ;
drivers/scsi/myrs.c +1 -1
@@ -1937,7 +1937,7 @@ static struct myrs_hba *myrs_alloc_host(struct pci_dev *pdev,struct Scsi_Host *shost;struct myrs_hba *cs; - shost =scsi_host_alloc (&myrs_template,sizeof (struct myrs_hba )); + shost =scsi_host_alloc (&myrs_template,sizeof (struct myrs_hba ), &pdev->dev);if (!shost)return NULL ;
drivers/scsi/ncr53c8xx.c +1 -1
@@ -8108,7 +8108,7 @@ struct Scsi_Host * __init ncr_attach(struct scsi_host_template *tpnt,printk (KERN_INFO "ncr53c720-%d: rev 0x%x irq %d\n" , unit, device->chip.revision_id, device->slot.irq); - instance =scsi_host_alloc (tpnt,sizeof (*host_data)); + instance =scsi_host_alloc (tpnt,sizeof (*host_data),NULL );if (!instance) goto attach_error; host_data = (struct host_data *) instance->hostdata;
drivers/scsi/nsp32.c +1 -1
@@ -2556,7 +2556,7 @@ static int nsp32_detect(struct pci_dev *pdev)/* * register this HBA as SCSI device */ - host =scsi_host_alloc (&nsp32_template,sizeof (nsp32_hw_data)); + host =scsi_host_alloc (&nsp32_template,sizeof (nsp32_hw_data), &pdev->dev);if (host ==NULL ) {nsp32_msg (KERN_ERR ,"failed to scsi register" ); goto err;
drivers/scsi/pcmcia/nsp_cs.c +1 -1
@@ -1326,7 +1326,7 @@ static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht)nsp_hw_data *data_b = &nsp_data_base, *data;nsp_dbg (NSP_DEBUG_INIT ,"this_id=%d" , sht->this_id); - host =scsi_host_alloc (&nsp_driver_template,sizeof (nsp_hw_data)); + host =scsi_host_alloc (&nsp_driver_template,sizeof (nsp_hw_data),NULL );if (host ==NULL ) {nsp_dbg (NSP_DEBUG_INIT ,"host failed" );return NULL ;
drivers/scsi/pcmcia/qlogic_stub.c +1 -1
@@ -106,7 +106,7 @@ static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,qlogicfas408_setup (qbase, qinitid,INT_TYPE ); host->name = qlogic_name; - shost =scsi_host_alloc (host,sizeof (struct qlogicfas408_priv )); + shost =scsi_host_alloc (host,sizeof (struct qlogicfas408_priv ),NULL );if (!shost) goto err; shost->io_port = qbase;
drivers/scsi/pcmcia/sym53c500_cs.c +1 -1
@@ -752,7 +752,7 @@ SYM53C500_config(struct pcmcia_device *link)chip_init (port_base); - host =scsi_host_alloc (tpnt,sizeof (struct sym53c500_data )); + host =scsi_host_alloc (tpnt,sizeof (struct sym53c500_data ),NULL );if (!host) {printk ("SYM53C500: Unable to register host, giving up.\n" ); goto err_release;
drivers/scsi/pm8001/pm8001_init.c +1 -1
@@ -1142,7 +1142,7 @@ static int pm8001_pci_probe(struct pci_dev *pdev,if (rc) goto err_out_regions; - shost =scsi_host_alloc (&pm8001_sht,sizeof (void *)); + shost =scsi_host_alloc (&pm8001_sht,sizeof (void *), &pdev->dev);if (!shost) { rc = -ENOMEM ; goto err_out_regions;
drivers/scsi/pmcraid.c +1 -1
@@ -5236,7 +5236,7 @@ static int pmcraid_probe(struct pci_dev *pdev, } host =scsi_host_alloc (&pmcraid_host_template, -sizeof (struct pmcraid_instance )); +sizeof (struct pmcraid_instance ), &pdev->dev);if (!host) {dev_err (&pdev->dev,"scsi_host_alloc failed!\n" );
drivers/scsi/ppa.c +1 -1
@@ -1101,7 +1101,7 @@ static int __ppa_attach(struct parport *pb)INIT_DELAYED_WORK (&dev->ppa_tq, ppa_interrupt); err = -ENOMEM ; - host =scsi_host_alloc (&ppa_template,sizeof (ppa_struct *)); + host =scsi_host_alloc (&ppa_template,sizeof (ppa_struct *),NULL );if (!host) goto out1; host->io_port = pb->base;
drivers/scsi/ps3rom.c +1 -1
@@ -361,7 +361,7 @@ static int ps3rom_probe(struct ps3_system_bus_device *_dev) goto fail_free_bounce; host =scsi_host_alloc (&ps3rom_host_template, -sizeof (struct ps3rom_private )); +sizeof (struct ps3rom_private ),NULL );if (!host) {dev_err (&dev->sbd.core,"%s:%u: scsi_host_alloc failed\n" , __func__, __LINE__);
drivers/scsi/qla1280.c +1 -1
@@ -4142,7 +4142,7 @@ qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)pci_set_master (pdev); error = -ENOMEM ; - host =scsi_host_alloc (&qla1280_driver_template,sizeof (*ha)); + host =scsi_host_alloc (&qla1280_driver_template,sizeof (*ha), &pdev->dev);if (!host) {printk (KERN_WARNING "qla1280: Failed to register host, aborting.\n" );
drivers/scsi/qla2xxx/qla_mid.c +1 -1
@@ -502,7 +502,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) vha =qla2x00_create_host (sht, ha);if (!vha) {ql_log (ql_log_warn, vha,0xa005 , -"scsi_host_alloc() failed for vport.\n" ); +"scsi_host_alloc() failed for vport.\n" ,NULL );return (NULL ); }
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -5046,7 +5046,7 @@ struct scsi_qla_host *qla2x00_create_host(const struct scsi_host_template *sht,struct Scsi_Host *host;struct scsi_qla_host *vha =NULL ; - host =scsi_host_alloc (sht,sizeof (scsi_qla_host_t)); + host =scsi_host_alloc (sht,sizeof (scsi_qla_host_t), &ha->pdev->dev);if (!host) {ql_log_pci (ql_log_fatal, ha->pdev,0x0107 ,"Failed to allocate host from the scsi layer, aborting.\n" );
drivers/scsi/qlogicfas.c +1 -1
@@ -95,7 +95,7 @@ static struct Scsi_Host *__qlogicfas_detect(struct scsi_host_template *host,qlogicfas408_setup (qbase, qinitid,INT_TYPE ); - hreg =scsi_host_alloc (host,sizeof (struct qlogicfas408_priv )); + hreg =scsi_host_alloc (host,sizeof (struct qlogicfas408_priv ),NULL );if (!hreg) goto err_release_mem; priv =get_priv_by_host (hreg);
drivers/scsi/qlogicpti.c +1 -1
@@ -1316,7 +1316,7 @@ static int qpti_sbus_probe(struct platform_device *op)if (op->archdata.irqs[0 ] ==0 )return -ENODEV ; - host =scsi_host_alloc (&qpti_template,sizeof (struct qlogicpti )); + host =scsi_host_alloc (&qpti_template,sizeof (struct qlogicpti ),NULL );if (!host)return -ENOMEM ;
drivers/scsi/scsi_debug.c +1 -1
@@ -9548,7 +9548,7 @@ static int sdebug_driver_probe(struct device *dev) sdbg_host =dev_to_sdebug_host (dev); - hpnt =scsi_host_alloc (&sdebug_driver_template,0 ); + hpnt =scsi_host_alloc (&sdebug_driver_template,0 ,NULL );if (NULL == hpnt) {pr_err ("scsi_host_alloc failed\n" ); error = -ENODEV ;
drivers/scsi/sgiwd93.c +1 -1
@@ -231,7 +231,7 @@ static int sgiwd93_probe(struct platform_device *pdev)unsigned int irq = pd->irq;int err; - host =scsi_host_alloc (&sgiwd93_template,sizeof (struct ip22_hostdata )); + host =scsi_host_alloc (&sgiwd93_template,sizeof (struct ip22_hostdata ),NULL );if (!host) { err = -ENOMEM ; goto out;
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
@@ -7619,7 +7619,7 @@ static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)int rc;struct Scsi_Host *shost; - shost =scsi_host_alloc (&pqi_driver_template,sizeof (ctrl_info)); + shost =scsi_host_alloc (&pqi_driver_template,sizeof (ctrl_info), &ctrl_info->pci_dev->dev);if (!shost) {dev_err (&ctrl_info->pci_dev->dev,"scsi_host_alloc failed\n" );return -ENOMEM ;
drivers/scsi/snic/snic_main.c +1 -1
@@ -363,7 +363,7 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* * Allocate SCSI Host and setup association between host, and snic */ - shost =scsi_host_alloc (&snic_host_template,sizeof (struct snic )); + shost =scsi_host_alloc (&snic_host_template,sizeof (struct snic ), &pdev->dev);if (!shost) {SNIC_ERR ("Unable to alloc scsi_host\n" ); ret = -ENOMEM ;
drivers/scsi/stex.c +1 -1
@@ -1667,7 +1667,7 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) S6flag =0 ;register_reboot_notifier (&stex_notifier); - host =scsi_host_alloc (&driver_template,sizeof (struct st_hba )); + host =scsi_host_alloc (&driver_template,sizeof (struct st_hba ), &pdev->dev);if (!host) { printk(KERN_ERR DRV_NAME "(%s): scsi_host_alloc failed\n",
drivers/scsi/storvsc_drv.c +1 -1
@@ -1969,7 +1969,7 @@ static int storvsc_probe(struct hv_device *device, (100 - ring_avail_percent_lowater) /100 ; host =scsi_host_alloc (&scsi_driver, -sizeof (struct hv_host_device )); +sizeof (struct hv_host_device ),NULL );if (!host)return -ENOMEM ;
drivers/scsi/sun3_scsi.c +1 -1
@@ -578,7 +578,7 @@ static int __init sun3_scsi_probe(struct platform_device *pdev)#endif instance =scsi_host_alloc (&sun3_scsi_template, -sizeof (struct NCR5380_hostdata )); +sizeof (struct NCR5380_hostdata ),NULL );if (!instance) { error = -ENOMEM ; goto fail_alloc;
drivers/scsi/sun3x_esp.c +1 -1
@@ -175,7 +175,7 @@ static int esp_sun3x_probe(struct platform_device *dev)struct resource *res;int err = -ENOMEM ; - host =scsi_host_alloc (tpnt,sizeof (struct esp )); + host =scsi_host_alloc (tpnt,sizeof (struct esp ),NULL );if (!host) goto fail;
drivers/scsi/sun_esp.c +1 -1
@@ -457,7 +457,7 @@ static int esp_sbus_probe_one(struct platform_device *op,struct esp *esp;int err; - host =scsi_host_alloc (tpnt,sizeof (struct esp )); + host =scsi_host_alloc (tpnt,sizeof (struct esp ),NULL ); err = -ENOMEM ;if (!host)
drivers/scsi/sym53c8xx_2/sym_glue.c +1 -1
@@ -1300,7 +1300,7 @@ static struct Scsi_Host *sym_attach(const struct scsi_host_template *tpnt, int uif (!fw) goto attach_failed; - shost =scsi_host_alloc (tpnt,sizeof (*sym_data)); + shost =scsi_host_alloc (tpnt,sizeof (*sym_data), &pdev->dev);if (!shost) goto attach_failed; sym_data =shost_priv (shost);
drivers/scsi/virtio_scsi.c +1 -1
@@ -929,7 +929,7 @@ static int virtscsi_probe(struct virtio_device *vdev) num_targets =virtscsi_config_get (vdev, max_target) +1 ; shost =scsi_host_alloc (&virtscsi_host_template, -struct_size (vscsi, req_vqs, num_queues)); +struct_size (vscsi, req_vqs, num_queues),NULL );if (!shost)return -ENOMEM ;
drivers/scsi/vmw_pvscsi.c +1 -1
@@ -1435,7 +1435,7 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE ; pvscsi_template.cmd_per_lun =min (pvscsi_template.can_queue, pvscsi_cmd_per_lun); - host =scsi_host_alloc (&pvscsi_template,sizeof (struct pvscsi_adapter )); + host =scsi_host_alloc (&pvscsi_template,sizeof (struct pvscsi_adapter ), &pdev->dev);if (!host) {printk (KERN_ERR "vmw_pvscsi: failed to allocate host\n" ); goto out_release_resources_and_disable;
drivers/scsi/wd719x.c +1 -1
@@ -921,7 +921,7 @@ static int wd719x_pci_probe(struct pci_dev *pdev, const struct pci_device_id *d) goto release_region; err = -ENOMEM ; - sh =scsi_host_alloc (&wd719x_template,sizeof (struct wd719x )); + sh =scsi_host_alloc (&wd719x_template,sizeof (struct wd719x ), &pdev->dev);if (!sh) goto release_region;
drivers/scsi/xen-scsifront.c +1 -1
@@ -899,7 +899,7 @@ static int scsifront_probe(struct xenbus_device *dev,int err = -ENOMEM ;char name[TASK_COMM_LEN ]; - host =scsi_host_alloc (&scsifront_sht,sizeof (*info)); + host =scsi_host_alloc (&scsifront_sht,sizeof (*info),NULL );if (!host) {xenbus_dev_fatal (dev, err,"fail to allocate scsi host" );return err;
drivers/scsi/zorro_esp.c +1 -1
@@ -774,7 +774,7 @@ static int zorro_esp_probe(struct zorro_dev *z, goto fail_free_zep; } - host =scsi_host_alloc (tpnt,sizeof (struct esp )); + host =scsi_host_alloc (tpnt,sizeof (struct esp ),NULL );if (!host) {pr_err ("No host detected; board configuration problem?\n" );
include/scsi/libfc.h +1 -1
@@ -883,7 +883,7 @@ libfc_host_alloc(const struct scsi_host_template *sht, int priv_size)struct fc_lport *lport;struct Scsi_Host *shost; - shost =scsi_host_alloc (sht,sizeof (*lport) + priv_size); + shost =scsi_host_alloc (sht,sizeof (*lport) + priv_size,NULL );if (!shost)return NULL ; lport =shost_priv (shost);
include/scsi/scsi_host.h +2 -1
@@ -796,7 +796,8 @@ static inline int scsi_host_in_recovery(struct Scsi_Host *shost)extern int scsi_queue_work (struct Scsi_Host *,struct work_struct *);extern void scsi_flush_work (struct Scsi_Host *); -extern struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *,int ); +extern struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht, +int privsize,struct device *dev);extern int __must_check scsi_add_host_with_dma (struct Scsi_Host *,struct device *,struct device *);
Signature · 1 line
2.43.7
Re: [PATCH v3 2/4] scsi: host: allocate struct Scsi_Host on the NUMA node of the host adapter
Quoted 18 lines · Sumit Saxena
scsi_host_alloc()usedkzalloc(), which always picks an arbitrary node. Extend the function to accept a 'struct device *dev' parameter and usekzalloc_node()withdev_to_node(dev)so theScsi_Hoststruct lands on the same NUMA node as the HBA, mirroring the treatment already applied to structscsi_device, structscsi_target, andshost_data.When dev is NULL (legacy ISA/platform drivers without a
dma_dev) the allocation falls back toNUMA_NO_NODE, preserving existing behaviour.Update all in-tree callers:
- PCI-based HBA drivers pass&pdev->dev(or the equivalent struct member such as&phba->pcidev->dev,&h->pdev->dev,&ha->pdev->dev) so their host struct is placed on the adapter's node.
- Non-PCI drivers (ISA, Amiga, ARM PCMCIA, virtio, Hyper-V, PS3, …) pass NULL.
- libfc'slibfc_host_alloc()inline helper passes NULL; FC drivers that want NUMA awareness can open-code the call with their pdev.
Quoted 2 lines
Suggested-by John Garry <[email protected]>Signed-off-by Sumit Saxena <[email protected]>
Wow ... I was not expecting such a large change, but admittedly I did not consider the implementation.
I did mention that pci-based adapters should already be effectively doing kzalloc_node() since the adapter driver is probed on the local NUMA node (and kmalloc first tries local NUMA allocations).
Quoted 20 lines
---
drivers/scsi/hosts.c +4
-2@@ -403,12 +403,14 @@ static const struct device_type scsi_host_type = {* Return value: * Pointer to a new Scsi_Host **/ -struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht,int privsize) +struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht,int privsize, +struct device *dev) {struct Scsi_Host *shost;int index; - shost =kzalloc (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL ); + shost =kzalloc_node (sizeof (struct Scsi_Host ) + privsize,GFP_KERNEL , + dev ?dev_to_node (dev) :NUMA_NO_NODE );
drivers/scsi/hosts.c static const struct device_type scsi_host_type = {
Quoted 10 lines
drivers/scsi/hosts.c +2
-1if (!shost)return NULL ; -extern struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *,int ); +extern struct Scsi_Host *scsi_host_alloc (const struct scsi_host_template *sht, +int privsize,struct device *dev);extern int __must_check scsi_add_host_with_dma (struct Scsi_Host *,struct device *,struct device *);
scsi_add_host_with_dma() and scsi_add_host() do assignment of shost->dma_dev, so I think that could be moved to scsi_host_alloc().
I can imagine that we always know dev and dma_dev at Scsi_Host alloc time (and not just scsi_add_host()) time. However those would be very intrusive changes.
Let me consider this more. Maybe we can have a platform device version of shost alloc, as I can't imagine that we care about much more. Thanks!
Hannes Reinecke
maintainerRe: [PATCH v3 2/4] scsi: host: allocate struct Scsi_Host on the NUMA node of the host adapter
In reply to Sumit SaxenaQuoted 111 lines · Sumit Saxena
scsi_host_alloc()usedkzalloc(), which always picks an arbitrary node. Extend the function to accept a 'struct device *dev' parameter and usekzalloc_node()withdev_to_node(dev)so theScsi_Hoststruct lands on the same NUMA node as the HBA, mirroring the treatment already applied to structscsi_device, structscsi_target, andshost_data.When dev is NULL (legacy ISA/platform drivers without a
dma_dev) the allocation falls back toNUMA_NO_NODE, preserving existing behaviour.Update all in-tree callers:
- PCI-based HBA drivers pass&pdev->dev(or the equivalent struct member such as&phba->pcidev->dev,&h->pdev->dev,&ha->pdev->dev) so their host struct is placed on the adapter's node.
- Non-PCI drivers (ISA, Amiga, ARM PCMCIA, virtio, Hyper-V, PS3, …) pass NULL.
- libfc'slibfc_host_alloc()inline helper passes NULL; FC drivers that want NUMA awareness can open-code the call with their pdev.Suggested-by John Garry <[email protected]>Signed-off-by Sumit Saxena <[email protected]>--- drivers/scsi/3w-9xxx.c | 2 +- drivers/scsi/3w-sas.c | 2 +- drivers/scsi/3w-xxxx.c | 2 +- drivers/scsi/53c700.c | 2 +- drivers/scsi/BusLogic.c | 2 +- drivers/scsi/a100u2w.c | 2 +- drivers/scsi/a2091.c | 2 +- drivers/scsi/a3000.c | 2 +- drivers/scsi/aacraid/linit.c | 2 +- drivers/scsi/advansys.c | 6 +++--- drivers/scsi/aha152x.c | 2 +- drivers/scsi/aha1542.c | 2 +- drivers/scsi/aha1740.c | 2 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 2 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 2 +- drivers/scsi/aic94xx/aic94xx_init.c | 2 +- drivers/scsi/am53c974.c | 2 +- drivers/scsi/arcmsr/arcmsr_hba.c | 3 ++- drivers/scsi/arm/acornscsi.c | 2 +- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_1.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/oak.c | 2 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/atari_scsi.c | 2 +- drivers/scsi/atp870u.c | 2 +- drivers/scsi/bfa/bfad_im.c | 2 +- drivers/scsi/csiostor/csio_init.c | 4 ++-- drivers/scsi/dc395x.c | 2 +- drivers/scsi/dmx3191d.c | 2 +- drivers/scsi/elx/efct/efct_xport.c | 4 ++-- drivers/scsi/esas2r/esas2r_main.c | 2 +- drivers/scsi/fdomain.c | 2 +- drivers/scsi/fnic/fnic_main.c | 2 +- drivers/scsi/g_NCR5380.c | 2 +- drivers/scsi/gvp11.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 2 +- drivers/scsi/hosts.c | 6 ++++-- drivers/scsi/hpsa.c | 2 +- drivers/scsi/hptiop.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- drivers/scsi/imm.c | 2 +- drivers/scsi/initio.c | 2 +- drivers/scsi/ipr.c | 2 +- drivers/scsi/ips.c | 2 +- drivers/scsi/isci/init.c | 2 +- drivers/scsi/jazz_esp.c | 2 +- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/mac53c94.c | 2 +- drivers/scsi/mac_esp.c | 2 +- drivers/scsi/mac_scsi.c | 2 +- drivers/scsi/megaraid.c | 2 +- drivers/scsi/megaraid/megaraid_mbox.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/mesh.c | 2 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 ++-- drivers/scsi/mvme147.c | 2 +- drivers/scsi/mvsas/mv_init.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/myrb.c | 2 +- drivers/scsi/myrs.c | 2 +- drivers/scsi/ncr53c8xx.c | 2 +- drivers/scsi/nsp32.c | 2 +- drivers/scsi/pcmcia/nsp_cs.c | 2 +- drivers/scsi/pcmcia/qlogic_stub.c | 2 +- drivers/scsi/pcmcia/sym53c500_cs.c | 2 +- drivers/scsi/pm8001/pm8001_init.c | 2 +- drivers/scsi/pmcraid.c | 2 +- drivers/scsi/ppa.c | 2 +- drivers/scsi/ps3rom.c | 2 +- drivers/scsi/qla1280.c | 2 +- drivers/scsi/qla2xxx/qla_mid.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 2 +- drivers/scsi/qlogicfas.c | 2 +- drivers/scsi/qlogicpti.c | 2 +- drivers/scsi/scsi_debug.c | 2 +- drivers/scsi/sgiwd93.c | 2 +- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- drivers/scsi/snic/snic_main.c | 2 +- drivers/scsi/stex.c | 2 +- drivers/scsi/storvsc_drv.c | 2 +- drivers/scsi/sun3_scsi.c | 2 +- drivers/scsi/sun3x_esp.c | 2 +- drivers/scsi/sun_esp.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
Quoted 9 lines
drivers/scsi/virtio_scsi.c | 2 +- drivers/scsi/vmw_pvscsi.c | 2 +- drivers/scsi/wd719x.c | 2 +- drivers/scsi/xen-scsifront.c | 2 +- drivers/scsi/zorro_esp.c | 2 +- include/scsi/libfc.h | 2 +- include/scsi/scsi_host.h | 3 ++- 97 files changed, 107 insertions(+), 103 deletions(-)
Quite a lot of churn for such a (relatively) simple change.
I think it might be better to introduce a new function (scsi_host_alloc_node() ?) with the additional parameter, and make scsi_host_alloc() a wrapper around that.
That will reduce the size of this patch immensely.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Stefan Hajnoczi
reviewerRe: [PATCH v3 2/4] scsi: host: allocate struct Scsi_Host on the NUMA node of the host adapter
In reply to Sumit Saxenadrivers/scsi/virtio_scsi.c static int virtscsi_probe(struct virtio_device *vdev) · line 932
Quoted 10 lines · Sumit Saxena
drivers/scsi/virtio_scsi.c +1
-1@@ -929,7 +929,7 @@ static int virtscsi_probe(struct virtio_device *vdev) num_targets =virtscsi_config_get (vdev, max_target) +1 ; shost =scsi_host_alloc (&virtscsi_host_template, -struct_size (vscsi, req_vqs, num_queues)); +struct_size (vscsi, req_vqs, num_queues),NULL );
A virtio_device has a parent (this is the virtio transport, like virtio_pci) and that may have NUMA node.
drivers/virtio/virtio.c:register_virtio_device() could call set_dev_node(dev, dev_to_node(dev->parent)) to propagate the NUMA node to the virtio_device if it is not already automatically propagated.
Stefan
Sumit Saxena
maintainerPATCH v3 3/4 block: drop shared-tag fairness throttling
In reply to Sumit SaxenaFrom: Bart Van Assche <[email protected]>
Original patch [1] by Bart Van Assche; this version is rebased onto the current tree. In testing it improves IOPS by roughly 16-18% by removing the fair-sharing throttle on shared tag queues.
This patch removes the following code and structure members:
- The function hctx_may_queue().
- blk_mq_hw_ctx.nr_active and request_queue.nr_active_requests_shared_tags and also all the code that modifies these two member variables.
[1]: https://lore.kernel.org/linux-block/[email protected]/
--- block/blk-core.c | 2 - block/blk-mq-debugfs.c | 22 ++++++++- block/blk-mq-tag.c | 4 -- block/blk-mq.c | 17 +------ block/blk-mq.h | 100 ----------------------------------------- include/linux/blk-mq.h | 6 --- include/linux/blkdev.h | 2 - 7 files changed, 22 insertions(+), 131 deletions(-)
block/blk-core.c +0 -2
@@ -421,8 +421,6 @@ struct request_queue *blk_alloc_queue(struct queue_limits *lim, int node_id) q->node = node_id; -atomic_set (&q->nr_active_requests_shared_tags,0 ); -timer_setup (&q->timeout, blk_rq_timed_out_timer,0 );INIT_WORK (&q->timeout_work, blk_timeout_work);INIT_LIST_HEAD (&q->icq_list);
block/blk-mq-debugfs.c +21 -1
@@ -468,11 +468,31 @@ static int hctx_sched_tags_bitmap_show(void *data, struct seq_file *m)return 0 ; } +struct count_active_params { +struct blk_mq_hw_ctx *hctx; +int *active; +}; + +static bool hctx_count_active (struct request *rq,void *data) +{ +const struct count_active_params *params = data; + +if (rq->mq_hctx == params->hctx) + (*params->active)++; + +return true; +} +static int hctx_active_show (void *data,struct seq_file *m) {struct blk_mq_hw_ctx *hctx = data; +int active =0 ; +struct count_active_params params = { .hctx = hctx, .active = &active }; + +blk_mq_all_tag_iter (hctx->sched_tags ?: hctx->tags, hctx_count_active, + ¶ms); -seq_printf (m,"%d\n" ,__blk_mq_active_requests (hctx)); +seq_printf (m,"%d\n" , active);return 0 ; }
block/blk-mq-tag.c +0 -4
@@ -109,10 +109,6 @@ void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)static int __blk_mq_get_tag (struct blk_mq_alloc_data *data,struct sbitmap_queue *bt) { -if (!data->q->elevator && !(data->flags &BLK_MQ_REQ_RESERVED ) && - !hctx_may_queue (data->hctx, bt)) -return BLK_MQ_NO_TAG ; -if (data->shallow_depth)return sbitmap_queue_get_shallow (bt, data->shallow_depth);else
block/blk-mq.c +1 -16
@@ -489,8 +489,6 @@ __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data) } }while (data->nr_tags > nr); -if (!(data->rq_flags &RQF_SCHED_TAGS )) -blk_mq_add_active_requests (data->hctx, nr);/* caller already holds a reference, add for remainder */ percpu_ref_get_many (&data->q->q_usage_counter, nr -1 ); data->nr_tags -= nr;
@@ -587,8 +585,6 @@ static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data) goto retry; } -if (!(data->rq_flags &RQF_SCHED_TAGS )) -blk_mq_inc_active_requests (data->hctx); rq =blk_mq_rq_ctx_init (data,blk_mq_tags_from_data (data), tag);blk_mq_rq_time_init (rq, alloc_time_ns);return rq;
@@ -763,8 +759,6 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, tag =blk_mq_get_tag (&data);if (tag ==BLK_MQ_NO_TAG ) goto out_queue_exit; -if (!(data.rq_flags &RQF_SCHED_TAGS )) -blk_mq_inc_active_requests (data.hctx); rq =blk_mq_rq_ctx_init (&data,blk_mq_tags_from_data (&data), tag);blk_mq_rq_time_init (rq, alloc_time_ns); rq->__data_len =0 ;
@@ -807,10 +801,8 @@ static void __blk_mq_free_request(struct request *rq)blk_pm_mark_last_busy (rq); rq->mq_hctx =NULL ; -if (rq->tag !=BLK_MQ_NO_TAG ) { -blk_mq_dec_active_requests (hctx); +if (rq->tag !=BLK_MQ_NO_TAG )blk_mq_put_tag (hctx->tags, ctx, rq->tag); - }if (sched_tag !=BLK_MQ_NO_TAG )blk_mq_put_tag (hctx->sched_tags, ctx, sched_tag);blk_mq_sched_restart (hctx);
@@ -1188,8 +1180,6 @@ static inline void blk_mq_flush_tag_batch(struct blk_mq_hw_ctx *hctx, {struct request_queue *q = hctx->queue; -blk_mq_sub_active_requests (hctx, nr_tags); -blk_mq_put_tags (hctx->tags, tag_array, nr_tags);percpu_ref_put_many (&q->q_usage_counter, nr_tags); }
@@ -1875,9 +1865,6 @@ bool __blk_mq_alloc_driver_tag(struct request *rq)if (blk_mq_tag_is_reserved (rq->mq_hctx->sched_tags, rq->internal_tag)) { bt = &rq->mq_hctx->tags->breserved_tags; tag_offset =0 ; - }else { -if (!hctx_may_queue (rq->mq_hctx, bt)) -return false; } tag =__sbitmap_queue_get (bt);
@@ -1885,7 +1872,6 @@ bool __blk_mq_alloc_driver_tag(struct request *rq)return false; rq->tag = tag + tag_offset; -blk_mq_inc_active_requests (rq->mq_hctx);return true; }
@@ -4058,7 +4044,6 @@ blk_mq_alloc_hctx(struct request_queue *q, struct blk_mq_tag_set *set,if (!zalloc_cpumask_var_node (&hctx->cpumask, gfp, node)) goto free_hctx; -atomic_set (&hctx->nr_active,0 );if (node ==NUMA_NO_NODE ) node = set->numa_node; hctx->numa_node = node;
block/blk-mq.h +0 -100
115 lines not on this page · raw message
include/linux/blk-mq.h +0 -6
@@ -432,12 +432,6 @@ struct blk_mq_hw_ctx {/** @queue_num: Index of this hardware queue. */ unsigned int queue_num; -/** -* @nr_active: Number of active requests. Only used when a tag set is -* shared across request queues. -*/ -atomic_t nr_active; -/** @cpuhp_online: List to store request if CPU is going to die */ struct hlist_node cpuhp_online;/** @cpuhp_dead: List to store request if some CPU die. */
include/linux/blkdev.h +0 -2
@@ -567,8 +567,6 @@ struct request_queue {struct timer_list timeout;struct work_struct timeout_work; -atomic_t nr_active_requests_shared_tags; -struct blk_mq_tags *sched_shared_tags;struct list_head icq_list;
Signature · 1 line
2.43.7
Re: [PATCH v3 3/4] block: drop shared-tag fairness throttling
Just dropping the fairness was rejected before and there is no explanation here on why any of that has changed.
Quoted 10 lines · Sumit Saxena
From: Bart Van Assche <[email protected]>
Original patch [1] by Bart Van Assche; this version is rebased onto the current tree. In testing it improves IOPS by roughly 16-18% by removing the fair-sharing throttle on shared tag queues.
This patch removes the following code and structure members:
- The functionhctx_may_queue().
- blk_mq_hw_ctx.nr_active and request_queue.nr_active_requests_shared_tags and also all the code that modifies these two member variables.
.. and besides that, this commit message is still entirely useless as it doesn't explain any of the thoughts of why this change is safe and desirable. While the mechanics above are totally obvious from the code change itself.
Sumit Saxena
maintainerRe: [PATCH v3 3/4] block: drop shared-tag fairness throttling
Quoted 3 lines · Christoph Hellwig
Just dropping the fairness was rejected before and there is no explanation here on why any of that has changed.
I missed the fact that this patch had been previously rejected.
The motivation for this change stems from performance issue we encountered due to false sharing of the 'nr_active_requests_shared_tags' counter
on certain CPU architectures. I initially submitted a patch to move that counter to
its own cache line to avoid conflicts with 'nr_requests' and other hot fields
(see:
https://patchwork.kernel.org/project/linux-scsi/patch/[email protected]/
).
During the review, Bart shared his work, which eliminates the counter entirely by removing the fairness throttling. My testing confirmed that
this approach resolved the performance issues and improved IOPS. This patch is part of a larger set, and I have reported the cumulative performance
improvements in the cover letter.
Thanks,
Sumit
Quoted 11 lines · Sumit Saxena
Quoted 9 lines
From: Bart Van Assche <[email protected]>
Original patch [1] by Bart Van Assche; this version is rebased onto the current tree. In testing it improves IOPS by roughly 16-18% by removing the fair-sharing throttle on shared tag queues.
This patch removes the following code and structure members:
- The functionhctx_may_queue().
- blk_mq_hw_ctx.nr_active and
request_queue.nr_active_requests_shared_tags
Quoted 7 lines
Quoted 1 line
and also all the code that modifies these two member variables.
.. and besides that, this commit message is still entirely useless as it doesn't explain any of the thoughts of why this change is safe and desirable. While the mechanics above are totally obvious from the code change itself.
Re: [PATCH v3 3/4] block: drop shared-tag fairness throttling
Quoted 11 lines · Sumit Saxena
The motivation for this change stems from performance issue we encountered due to false sharing of the '
nr_active_requests_shared_tags' counter
on certain CPU architectures. I initially submitted a patch to move that counter to
its own cache line to avoid conflicts with 'nr_requests' and other hot fields
(see:
https://patchwork.kernel.org/project/linux-scsi/patch/[email protected]/
).
Quoted 7 lines
During the review, Bart shared his work, which eliminates the counter entirely by removing the fairness throttling. My testing confirmed that
this approach resolved the performance issues and improved IOPS. This patch is part of a larger set, and I have reported the cumulative performance
improvements in the cover letter.
So the problem is just the atomic operation accounting overhead? I previously thought the device just really needed to consume all the tags to hit performance.
Sumit Saxena
maintainerRe: [PATCH v3 3/4] block: drop shared-tag fairness throttling
Quoted 11 lines · Keith Busch
Quoted 9 lines · Sumit Saxena
The motivation for this change stems from performance issue we encountered due to false sharing of the '
nr_active_requests_shared_tags' counter
on certain CPU architectures. I initially submitted a patch to move that counter to
its own cache line to avoid conflicts with 'nr_requests' and other hot fields
(see:
https://patchwork.kernel.org/project/linux-scsi/patch/[email protected]/
Quoted 4 lines
Quoted 4 lines
).
During the review, Bart shared his work, which eliminates the counter entirely by removing the fairness throttling. My testing
confirmed
Quoted 9 lines
Quoted 5 lines
that
this approach resolved the performance issues and improved IOPS. This patch is part of a larger set, and I have reported the cumulative performance
improvements in the cover letter.So the problem is just the atomic operation accounting overhead? I previously thought the device just really needed to consume all the tags to hit performance.
That's correct, it's the atomic operation accounting overhead.
Thanks,
Sumit
Re: [PATCH v3 3/4] block: drop shared-tag fairness throttling
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
Just dropping the fairness was rejected before and there is no explanation here on why any of that has changed.
Hmm ... has anyone ever rejected this patch? Jens' latest feedback (May 2024) is available here:
https://lore.kernel.org/linux-block/[email protected]/
Thanks,
Bart.
Hannes Reinecke
maintainerRe: [PATCH v3 3/4] block: drop shared-tag fairness throttling
In reply to Sumit SaxenaQuoted 15 lines · Sumit Saxena
From: Bart Van Assche <[email protected]>
Original patch [1] by Bart Van Assche; this version is rebased onto the current tree. In testing it improves IOPS by roughly 16-18% by removing the fair-sharing throttle on shared tag queues.
This patch removes the following code and structure members:
- The functionhctx_may_queue().
- blk_mq_hw_ctx.nr_active and request_queue.nr_active_requests_shared_tags and also all the code that modifies these two member variables.[1]: https://lore.kernel.org/linux-block/[email protected]/
Signed-off-by Bart Van Assche <[email protected]>Signed-off-by Sumit Saxena <[email protected]>
Quoted 10 lines
--- block/blk-core.c | 2 - block/blk-mq-debugfs.c | 22 ++++++++- block/blk-mq-tag.c | 4 -- block/blk-mq.c | 17 +------ block/blk-mq.h | 100 ----------------------------------------- include/linux/blk-mq.h | 6 --- include/linux/blkdev.h | 2 - 7 files changed, 22 insertions(+), 131 deletions(-)
What tests did you perform?
I'm pretty sure you see an improvement when having just a few drives, but what about having a lot of them (ie tens of drives)? The whole point of this was to increase fairness between drives, so of course removing it will make an individual drive going faster ...
Maybe it's an idea to move the fairness algorithm into an I/O scheduler; that way we can keep the original behaviour yet get the performance increase if people want it.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH v3 3/4] block: drop shared-tag fairness throttling
Quoted 2 lines · Hannes Reinecke
The whole point of this was to increase fairness between drives, so of course removing it will make an individual drive going faster ...
Data that shows that fairness is preserved even with this patch applied is available here:
https://lore.kernel.org/linux-block/[email protected]/
Thanks,
Bart.
Sumit Saxena
maintainerRe: [PATCH v3 3/4] block: drop shared-tag fairness throttling
In reply to Hannes ReineckeQuoted 5 lines
What tests did you perform?
I'm pretty sure you see an improvement when having just a few drives, but what about having a lot of them (ie tens of drives)? The whole point of this was to increase fairness between drives, so of course removing it will make an individual drive going faster ...
Initially, we ran tests with 8 drives and saw positive results. However, we completed
tests with 16 drives and are seeing performance drops at higher iodepths (>=128) with this patch.
This appears to be due to the removal of the per-queue throttle (hctx_may_queue).
We are currently running additional tests to better understand this behavior. I will provide an update
once I have more meaningful data.
Thanks,
Sumit
Sumit Saxena
maintainerPATCH v3 4/4 scsi: use percpu counters for iostat counters in struct scsi_device
In reply to Sumit Saxenaiorequest_cnt and iodone_cnt are updated on every command dispatch and completion, often from different CPUs on high queue depth workloads. Using adjacent atomic_t fields causes cache line contention between the submission and completion paths.
Extend the same treatment to ioerr_cnt and iotmo_cnt so all four iostat counters in struct scsi_device use struct percpu_counter.
--- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_lib.c | 10 +++++----- drivers/scsi/scsi_scan.c | 8 ++++++++ drivers/scsi/scsi_sysfs.c | 23 ++++++++++++++--------- drivers/scsi/sd.c | 2 +- include/scsi/scsi_device.h | 9 +++++---- 6 files changed, 35 insertions(+), 21 deletions(-)
drivers/scsi/scsi_error.c +2 -2
@@ -349,7 +349,7 @@ enum blk_eh_timer_return scsi_timeout(struct request *req)trace_scsi_dispatch_cmd_timeout (scmd);scsi_log_completion (scmd,TIMEOUT_ERROR ); -atomic_inc (&scmd->device->iotmo_cnt); +percpu_counter_inc (&scmd->device->iotmo_cnt);if (host->eh_deadline !=-1 && !host->last_reset) host->last_reset = jiffies;
@@ -370,7 +370,7 @@ enum blk_eh_timer_return scsi_timeout(struct request *req)*/ if (test_and_set_bit (SCMD_STATE_COMPLETE , &scmd->state))return BLK_EH_DONE ; -atomic_inc (&scmd->device->iodone_cnt); +percpu_counter_inc (&scmd->device->iodone_cnt);if (scsi_abort_command (scmd) !=SUCCESS ) {set_host_byte (scmd,DID_TIME_OUT );scsi_eh_scmd_add (scmd);
drivers/scsi/scsi_lib.c +5 -5
@@ -1554,9 +1554,9 @@ static void scsi_complete(struct request *rq)INIT_LIST_HEAD (&cmd->eh_entry); -atomic_inc (&cmd->device->iodone_cnt); +percpu_counter_inc (&cmd->device->iodone_cnt);if (cmd->result) -atomic_inc (&cmd->device->ioerr_cnt); +percpu_counter_inc (&cmd->device->ioerr_cnt); disposition =scsi_decide_disposition (cmd);if (disposition !=SUCCESS &&scsi_cmd_runtime_exceeced (cmd))
@@ -1592,7 +1592,7 @@ static enum scsi_qc_status scsi_dispatch_cmd(struct scsi_cmnd *cmd)struct Scsi_Host *host = cmd->device->host;int rtn =0 ; -atomic_inc (&cmd->device->iorequest_cnt); +percpu_counter_inc (&cmd->device->iorequest_cnt);/* check if the device is still usable */ if (unlikely (cmd->device->sdev_state ==SDEV_DEL )) {
@@ -1614,7 +1614,7 @@ static enum scsi_qc_status scsi_dispatch_cmd(struct scsi_cmnd *cmd)*/ SCSI_LOG_MLQUEUE (3 ,scmd_printk (KERN_INFO , cmd,"queuecommand : device blocked\n" )); -atomic_dec (&cmd->device->iorequest_cnt); +percpu_counter_dec (&cmd->device->iorequest_cnt);return SCSI_MLQUEUE_DEVICE_BUSY ; }
@@ -1647,7 +1647,7 @@ static enum scsi_qc_status scsi_dispatch_cmd(struct scsi_cmnd *cmd)trace_scsi_dispatch_cmd_start (cmd); rtn = host->hostt->queuecommand (host, cmd);if (rtn) { -atomic_dec (&cmd->device->iorequest_cnt); +percpu_counter_dec (&cmd->device->iorequest_cnt);trace_scsi_dispatch_cmd_error (cmd, rtn);if (rtn !=SCSI_MLQUEUE_DEVICE_BUSY && rtn !=SCSI_MLQUEUE_TARGET_BUSY )
drivers/scsi/scsi_scan.c +8 -0
@@ -350,6 +350,14 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,scsi_sysfs_device_initialize (sdev); +if (percpu_counter_init (&sdev->iorequest_cnt,0 ,GFP_KERNEL ) || +percpu_counter_init (&sdev->iodone_cnt,0 ,GFP_KERNEL ) || +percpu_counter_init (&sdev->ioerr_cnt,0 ,GFP_KERNEL ) || +percpu_counter_init (&sdev->iotmo_cnt,0 ,GFP_KERNEL )) { + ret = -ENOMEM ; + goto out_device_destroy; + } +if (scsi_device_is_pseudo_dev (sdev))return sdev;
drivers/scsi/scsi_sysfs.c +14 -9
@@ -516,6 +516,10 @@ static void scsi_device_dev_release(struct device *dev)if (vpd_pgb7)kfree_rcu (vpd_pgb7, rcu);kfree (sdev->inquiry); +percpu_counter_destroy (&sdev->iotmo_cnt); +percpu_counter_destroy (&sdev->ioerr_cnt); +percpu_counter_destroy (&sdev->iodone_cnt); +percpu_counter_destroy (&sdev->iorequest_cnt);kfree (sdev);if (parent)
@@ -936,26 +940,27 @@ static ssize_t show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); + /* iostat counters are per-CPU sums (s64). Report width for tools. */ + return sysfs_emit(buf, "%zu\n", sizeof(s64) * 8); } static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL); -#define show_sdev_iostat (field) \ +#define show_sdev_iostat_percpu (field) \ static ssize_t \ show_iostat_##field(struct device *dev, struct device_attribute *attr, \ char *buf) \ { \ struct scsi_device *sdev = to_scsi_device(dev); \ - unsigned long long count = atomic_read(&sdev->field); \ - return snprintf(buf, 20, "0x%llx\n", count); \ + unsigned long long count = percpu_counter_sum(&sdev->field); \ + return sysfs_emit(buf, "0x%llx\n", count); \ } \ -static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL) +static DEVICE_ATTR(field, 0444, show_iostat_##field, NULL) -show_sdev_iostat (iorequest_cnt); -show_sdev_iostat (iodone_cnt); -show_sdev_iostat (ioerr_cnt); -show_sdev_iostat (iotmo_cnt); +show_sdev_iostat_percpu (iorequest_cnt); +show_sdev_iostat_percpu (iodone_cnt); +show_sdev_iostat_percpu (ioerr_cnt); +show_sdev_iostat_percpu (iotmo_cnt);static ssize_t sdev_show_modalias (struct device *dev,struct device_attribute *attr,char *buf)
drivers/scsi/sd.c +1 -1
@@ -4043,7 +4043,7 @@ static int sd_probe(struct scsi_device *sdp) sdkp->index = index; sdkp->max_retries =SD_MAX_RETRIES ;atomic_set (&sdkp->openers,0 ); -atomic_set (&sdkp->device->ioerr_cnt,0 ); +percpu_counter_set (&sdkp->device->ioerr_cnt,0 );if (!sdp->request_queue->rq_timeout) {if (sdp->type !=TYPE_MOD )
include/scsi/scsi_device.h +5 -4
@@ -9,6 +9,7 @@#include <scsi/scsi.h> #include <scsi/scsi_common.h> #include <linux/atomic.h> +#include <linux/percpu_counter.h> #include <linux/sbitmap.h> struct bsg_device ;
@@ -272,10 +273,10 @@ struct scsi_device {unsigned int max_device_blocked;/* what device_blocked counts down from */ #define SCSI_DEFAULT_DEVICE_BLOCKED 3 -atomic_t iorequest_cnt; -atomic_t iodone_cnt; -atomic_t ioerr_cnt; -atomic_t iotmo_cnt; +struct percpu_counter iorequest_cnt; +struct percpu_counter iodone_cnt; +struct percpu_counter ioerr_cnt; +struct percpu_counter iotmo_cnt;struct device sdev_gendev, sdev_dev;
Signature · 1 line
2.43.7
Re: [PATCH v3 4/4] scsi: use percpu counters for iostat counters in struct scsi_device
-- huge trim
Quoted 10 lines · Sumit Saxena
iorequest_cntandiodone_cntare updated on every command dispatch and completion, often from different CPUs on high queue depth workloads. Using adjacentatomic_tfields causes cache line contention between the submission and completion paths.Extend the same treatment to
ioerr_cntandiotmo_cntso all four iostat counters in structscsi_deviceuse structpercpu_counter.Suggested-by John Garry <[email protected]>Signed-off-by Sumit Saxena <[email protected]>
I think that Bart originally suggested this idea, not me.
https://lore.kernel.org/linux-scsi/[email protected]/
I just queried if we could use percpu_counter_init_many() with an array of counters, which you said you would check.
Thanks,
John
Sumit Saxena
maintainerRe: [PATCH v3 4/4] scsi: use percpu counters for iostat counters in struct scsi_device
Quoted 1 line
I think that Bart originally suggested this idea, not me.
You're right. I will ensure Bart is credited for his suggestions in the next revision.
Quoted 2 lines
https://lore.kernel.org/linux-scsi/[email protected]/
Quoted 3 lines
I just queried if we could use
percpu_counter_init_many()with an array of counters, which you said you would check.
I missed handling this part, rest of the feedback is incorporated in this patch.
I think we can use percpu_counter_init_many() in place of individual calls. I will
accommodate it in the next revision.
Thanks,
Sumit
Re: [PATCH v3 4/4] scsi: use percpu counters for iostat counters in struct scsi_device
In reply to Sumit SaxenaQuoted 10 lines · Sumit Saxena
iorequest_cntandiodone_cntare updated on every command dispatch and completion, often from different CPUs on high queue depth workloads. Using adjacentatomic_tfields causes cache line contention between the submission and completion paths.Extend the same treatment to
ioerr_cntandiotmo_cntso all four iostat counters in structscsi_deviceuse structpercpu_counter.Suggested-by John Garry <[email protected]>Signed-off-by Sumit Saxena <[email protected]>
Quoted 9 lines
--- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_lib.c | 10 +++++----- drivers/scsi/scsi_scan.c | 8 ++++++++ drivers/scsi/scsi_sysfs.c | 23 ++++++++++++++--------- drivers/scsi/sd.c | 2 +- include/scsi/scsi_device.h | 9 +++++---- 6 files changed, 35 insertions(+), 21 deletions(-)
Good idea.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich