From: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
To: linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
James Smart <james.smart-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
Keith Busch <keith.busch-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH rfc 2/3] RDMA/core: expose cpu affinity based completion vector lookup
Date: Sun, 2 Jul 2017 18:01:33 +0300 [thread overview]
Message-ID: <1499007694-7231-3-git-send-email-sagi@grimberg.me> (raw)
In-Reply-To: <1499007694-7231-1-git-send-email-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
A ULP might want to lookup an optimal completion vector based on
a given cpu core affinity. Expose a lookup routine for it iterating
on the device completion vectors searching a vector with affinity
matching the given cpu.
Signed-off-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
---
drivers/infiniband/core/verbs.c | 41 +++++++++++++++++++++++++++++++++++++++++
include/rdma/ib_verbs.h | 3 +++
2 files changed, 44 insertions(+)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 4792f5209ac2..f0dfb1ca952b 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2099,3 +2099,44 @@ void ib_drain_qp(struct ib_qp *qp)
ib_drain_rq(qp);
}
EXPORT_SYMBOL(ib_drain_qp);
+
+/**
+ * ib_find_cpu_vector() - Find the first completion vector mapped to a given cpu core
+ * @device: rdma device
+ * @cpu: cpu for the corresponding completion vector affinity
+ * @vector: output target completion vector
+ *
+ * If the device expose vector affinity we will search each of the vectors
+ * and if we find one that gives us the desired cpu core we return true
+ * and assign @vector to the corresponding completion vector. Otherwise
+ * we return false. We stop at the first appropriate completion vector
+ * we find as we don't have any preference for multiple vectors with the
+ * same affinity.
+ */
+bool ib_find_cpu_vector(struct ib_device *device, unsigned int cpu,
+ unsigned int *vector)
+{
+ bool found = false;
+ unsigned int c;
+ int vec;
+
+ for (vec = 0; vec < device->num_comp_vectors; vec++) {
+ const struct cpumask *mask;
+
+ mask = ib_get_vector_affinity(device, vec);
+ if (!mask)
+ goto out;
+
+ for_each_cpu(c, mask) {
+ if (c == cpu) {
+ *vector = vec;
+ found = true;
+ goto out;
+ }
+ }
+ }
+
+out:
+ return found;
+}
+EXPORT_SYMBOL(ib_find_cpu_vector);
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 2349143297c9..8af48ef811f8 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -3662,4 +3662,7 @@ ib_get_vector_affinity(struct ib_device *device, int comp_vector)
}
+bool ib_find_cpu_vector(struct ib_device *device, unsigned int cpu,
+ unsigned int *vector);
+
#endif /* IB_VERBS_H */
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-07-02 15:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-02 15:01 [PATCH rfc 0/3] Expose cpu mapping hints to a nvme target port Sagi Grimberg
[not found] ` <1499007694-7231-1-git-send-email-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-02 15:01 ` [PATCH rfc 1/3] nvmet: allow assignment of a cpulist for each nvmet port Sagi Grimberg
2017-07-02 15:01 ` Sagi Grimberg [this message]
[not found] ` <1499007694-7231-3-git-send-email-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-13 15:50 ` [PATCH rfc 2/3] RDMA/core: expose cpu affinity based completion vector lookup Christoph Hellwig
[not found] ` <20170713155000.GA2577-jcswGhMUV9g@public.gmane.org>
2017-07-13 16:30 ` Sagi Grimberg
2017-07-02 15:01 ` [PATCH rfc 3/3] nvmet-rdma: assign cq completion vector based on the port allowed cpus Sagi Grimberg
[not found] ` <1499007694-7231-4-git-send-email-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-13 15:50 ` Christoph Hellwig
[not found] ` <20170713155003.GB2577-jcswGhMUV9g@public.gmane.org>
2017-07-13 16:37 ` Sagi Grimberg
[not found] ` <da6a9e33-163e-4964-8305-614b7b830c17-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-13 17:16 ` Christoph Hellwig
2017-07-13 17:19 ` Chuck Lever
[not found] ` <C2439AB7-BC2E-4B71-87CA-3F8313282828-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2017-07-13 17:24 ` Christoph Hellwig
[not found] ` <20170713172437.GA5236-jcswGhMUV9g@public.gmane.org>
2017-07-13 17:31 ` Chuck Lever
2017-07-02 16:30 ` [PATCH rfc 0/3] Expose cpu mapping hints to a nvme target port Max Gurtovoy
[not found] ` <b77be367-6cbc-c12c-8135-eddff0aec90e-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-07-02 17:41 ` Sagi Grimberg
[not found] ` <e33f16a7-4e1d-7fd6-6d2c-5a5bac450c73-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-03 9:52 ` Max Gurtovoy
[not found] ` <8a5f82d8-e475-5f0e-9110-8b2c68580988-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-07-03 10:14 ` Sagi Grimberg
2017-07-10 6:08 ` Sagi Grimberg
[not found] ` <70d04521-df66-d847-1f46-c35ba5de4053-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-07-11 7:27 ` Leon Romanovsky
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=1499007694-7231-3-git-send-email-sagi@grimberg.me \
--to=sagi-nqwnxtmzq1alnmji0ikvqw@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=james.smart-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=keith.busch-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.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