Skip to content

Commit 4263042

Browse files
blah325kawasaki
authored andcommitted
scsi: scan: allocate sdev and starget on the NUMA node of the host adapter
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. Signed-off-by: James Rizzo <[email protected]> Signed-off-by: Sumit Saxena <[email protected]>
1 parent 857ada9 commit 4263042

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/scsi/scsi_scan.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/kthread.h>
3535
#include <linux/spinlock.h>
3636
#include <linux/async.h>
37+
#include <linux/topology.h>
3738
#include <linux/slab.h>
3839
#include <linux/unaligned.h>
3940

@@ -286,9 +287,10 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
286287
int display_failure_msg = 1, ret;
287288
struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
288289
struct queue_limits lim;
290+
int node = dev_to_node(shost->dma_dev);
289291

290-
sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
291-
GFP_KERNEL);
292+
sdev = kzalloc_node(sizeof(*sdev) + shost->transportt->device_size,
293+
GFP_KERNEL, node);
292294
if (!sdev)
293295
goto out;
294296

@@ -501,8 +503,9 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
501503
struct scsi_target *starget;
502504
struct scsi_target *found_target;
503505
int error, ref_got;
506+
int node = dev_to_node(shost->dma_dev);
504507

505-
starget = kzalloc(size, GFP_KERNEL);
508+
starget = kzalloc_node(size, GFP_KERNEL, node);
506509
if (!starget) {
507510
printk(KERN_ERR "%s: allocation failure\n", __func__);
508511
return NULL;

0 commit comments

Comments
 (0)