From: Jeff Moyer <jmoyer@redhat.com>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
JBottomley@parallels.com
Cc: Bart Van Assche <bvanassche@acm.org>
Subject: [patch,v3,repost 01/10] scsi: add scsi_host_alloc_node
Date: Tue, 27 Nov 2012 11:46:29 -0500 [thread overview]
Message-ID: <1354034799-8460-2-git-send-email-jmoyer@redhat.com> (raw)
In-Reply-To: <1354034799-8460-1-git-send-email-jmoyer@redhat.com>
Allow an LLD to specify on which numa node to allocate scsi data
structures. Thanks to Bart Van Assche for the suggestion.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
---
drivers/scsi/hosts.c | 13 +++++++++++--
include/scsi/scsi_host.h | 28 ++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 593085a..06ce602 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -336,16 +336,25 @@ static struct device_type scsi_host_type = {
**/
struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
{
+ return scsi_host_alloc_node(sht, privsize, NUMA_NO_NODE);
+}
+EXPORT_SYMBOL(scsi_host_alloc);
+
+struct Scsi_Host *scsi_host_alloc_node(struct scsi_host_template *sht,
+ int privsize, int node)
+{
struct Scsi_Host *shost;
gfp_t gfp_mask = GFP_KERNEL;
if (sht->unchecked_isa_dma && privsize)
gfp_mask |= __GFP_DMA;
- shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
+ shost = kzalloc_node(sizeof(struct Scsi_Host) + privsize,
+ gfp_mask, node);
if (!shost)
return NULL;
+ scsi_host_set_numa_node(shost, node);
shost->host_lock = &shost->default_lock;
spin_lock_init(shost->host_lock);
shost->shost_state = SHOST_CREATED;
@@ -443,7 +452,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
kfree(shost);
return NULL;
}
-EXPORT_SYMBOL(scsi_host_alloc);
+EXPORT_SYMBOL(scsi_host_alloc_node);
struct Scsi_Host *scsi_register(struct scsi_host_template *sht, int privsize)
{
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 4908480..438856d 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -732,6 +732,14 @@ struct Scsi_Host {
*/
struct device *dma_dev;
+#ifdef CONFIG_NUMA
+ /*
+ * Numa node this device is closest to, used for allocating
+ * data structures locally.
+ */
+ int numa_node;
+#endif
+
/*
* We should ensure that this is aligned, both for better performance
* and also because some compilers (m68k) don't automatically force
@@ -776,6 +784,8 @@ 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(struct scsi_host_template *, int);
+extern struct Scsi_Host *scsi_host_alloc_node(struct scsi_host_template *,
+ int, int);
extern int __must_check scsi_add_host_with_dma(struct Scsi_Host *,
struct device *,
struct device *);
@@ -919,6 +929,24 @@ static inline unsigned char scsi_host_get_guard(struct Scsi_Host *shost)
return shost->prot_guard_type;
}
+#ifdef CONFIG_NUMA
+static inline int scsi_host_get_numa_node(struct Scsi_Host *shost)
+{
+ return shost->numa_node;
+}
+
+static inline void scsi_host_set_numa_node(struct Scsi_Host *shost, int node)
+{
+ shost->numa_node = node;
+}
+#else /* CONFIG_NUMA */
+static inline int scsi_host_get_numa_node(struct Scsi_Host *shost)
+{
+ return NUMA_NO_NODE;
+}
+static inline void scsi_host_set_numa_node(struct Scsi_Host *shost, int node) {}
+#endif
+
/* legacy interfaces */
extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int);
extern void scsi_unregister(struct Scsi_Host *);
--
1.7.1
next prev parent reply other threads:[~2012-11-27 16:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 16:46 [patch,v3,repost 00/10] make I/O path allocations more numa-friendly Jeff Moyer
2012-11-27 16:46 ` Jeff Moyer [this message]
2012-11-27 16:46 ` [patch,v3,repost 02/10] scsi: make __scsi_alloc_queue numa-aware Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 03/10] scsi: make scsi_alloc_sdev numa-aware Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 04/10] scsi: allocate scsi_cmnd-s from the device's local numa node Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 05/10] sd: use alloc_disk_node Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 06/10] ata: use scsi_host_alloc_node Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 07/10] megaraid_sas: " Jeff Moyer
2012-12-04 1:41 ` adam radford
2012-11-27 16:46 ` [patch,v3,repost 08/10] mpt2sas: " Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 09/10] lpfc: " Jeff Moyer
2012-11-27 16:46 ` [patch,v3,repost 10/10] cciss: use blk_init_queue_node Jeff Moyer
2012-12-10 17:59 ` [patch,v3,repost 00/10] make I/O path allocations more numa-friendly Jeff Moyer
2012-12-11 10:13 ` James Bottomley
2012-12-14 16:05 ` Jeff Moyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354034799-8460-2-git-send-email-jmoyer@redhat.com \
--to=jmoyer@redhat.com \
--cc=JBottomley@parallels.com \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).