From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 2/2] nvme-multipath: round-robin I/O policy
Date: Tue, 20 Nov 2018 17:42:35 +0100 [thread overview]
Message-ID: <20181120164235.GA3073@lst.de> (raw)
In-Reply-To: <20181115122927.40431-3-hare@suse.de>
On Thu, Nov 15, 2018@01:29:27PM +0100, Hannes Reinecke wrote:
> Add a simple round-robin I/O policy for multipathing.
>
> Signed-off-by: Hannes Reinecke <hare at suse.com>
> ---
> drivers/nvme/host/multipath.c | 46 +++++++++++++++++++++++++++++++++++++++++++
> drivers/nvme/host/nvme.h | 1 +
> 2 files changed, 47 insertions(+)
>
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 1f97293380e2..fed3eea9da9a 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -177,14 +177,52 @@ static inline bool nvme_path_is_optimized(struct nvme_ns *ns)
> ns->ana_state == NVME_ANA_OPTIMIZED;
> }
>
> +inline struct nvme_ns *__nvme_next_path(struct nvme_ns_head *head, int node,
> + struct nvme_ns *old)
This seems to miss a static. Also maybe put a rr in somewhere, e.g.:
static inline struct nvme_ns *
nvme_round_robin_path(struct nvme_ns_head *head, int node,
struct nvme_ns *old)
> + do {
> + ns = list_next_or_null_rcu(&head->list, &old->siblings,
> + struct nvme_ns, siblings);
> + if (!ns) {
> + ns = list_first_or_null_rcu(&head->list, struct nvme_ns,
> + siblings);
> + if (ns && ns == old)
> + /*
> + * The list consists of just one entry.
> + * Sorry for the noise :-)
> + */
> + return old;
> + else if (!ns)
No need for a else after a return.
> + break;
> + }
> + if (nvme_path_is_optimized(ns)) {
> + found = ns;
> + break;
> + }
So you never consider non-optimized paths here?
> inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
> {
> int node = numa_node_id();
> struct nvme_ns *ns;
>
> ns = srcu_dereference(head->current_path[node], &head->srcu);
> +retry:
> if (unlikely(!ns || !nvme_path_is_optimized(ns)))
> ns = __nvme_find_path(head, node);
> + else if (head->subsys->iopolicy == NVME_IOPOLICY_RR) {
> + ns = __nvme_next_path(head, node, ns);
> + if (!ns)
> + goto retry;
> + }
Can you move the __nvme_find_path call for the first path into
your round robing helper so that we can make this whole thing
a little cleaner? E.g.
if (head->subsys->iopolicy == NVME_IOPOLICY_RR)
return nvme_round_robin_path(head, node);
if (unlikely(!ns || !nvme_path_is_optimized(ns)))
ns = __nvme_find_path(head, node);
return ns;
> @@ -497,6 +535,7 @@ static const char *nvme_iopolicy_names[] = {
> [NVME_IOPOLICY_UNKNOWN] = "unknown",
> [NVME_IOPOLICY_NONE] = "none",
> [NVME_IOPOLICY_NUMA] = "numa",
> + [NVME_IOPOLICY_RR] = "round-robin",
I think you want to merge your I/O-policy attribute patch into this
one. And we should probably kill all entries except for numa and
round-robin.
> + struct nvme_subsystem *subsys =
> + container_of(dev, struct nvme_subsystem, dev);
>
> if (!strncmp(buf, "none", 4))
> iopolicy = NVME_IOPOLICY_NONE;
> else if (!strncmp(buf, "numa", 4))
> iopolicy = NVME_IOPOLICY_NUMA;
> + else if (!strncmp(buf, "round-robin", 11))
> + iopolicy = NVME_IOPOLICY_RR;
This could just loop over the above array for matches.
> + mutex_lock(&subsys->lock);
> + subsys->iopolicy = iopolicy;
> + mutex_unlock(&subsys->lock);
Rather pointless to take a lock for updating a single value.
Just use WRITE_ONCE/READ_ONCE.
next prev parent reply other threads:[~2018-11-20 16:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 12:29 [PATCH 0/2] nvme-multipath: round-robin I/O policy Hannes Reinecke
2018-11-15 12:29 ` [PATCH 1/2] nvme-multipath: add 'iopolicy' subsystem attribute Hannes Reinecke
2018-11-15 17:35 ` Sagi Grimberg
2018-11-16 8:07 ` Hannes Reinecke
2018-11-15 12:29 ` [PATCH 2/2] nvme-multipath: round-robin I/O policy Hannes Reinecke
2018-11-20 16:42 ` Christoph Hellwig [this message]
2018-11-20 20:30 ` Hannes Reinecke
2018-11-21 8:28 ` Christoph Hellwig
2018-11-21 11:24 ` Hannes Reinecke
[not found] ` <8a583536-151e-6f68-f4f9-98d8c4b853dd@broadcom.com>
2018-11-21 11:09 ` Hannes Reinecke
2018-11-22 13:52 ` Hannes Reinecke
2018-11-16 8:26 ` [PATCH 0/2] " Christoph Hellwig
2018-11-20 16:02 ` Hannes Reinecke
2018-11-20 16:19 ` Christoph Hellwig
2018-12-05 20:05 ` Ewan D. Milne
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=20181120164235.GA3073@lst.de \
--to=hch@lst.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.