From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Cc: "linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Robert Elliott <Elliott-VXdhtT5mjnY@public.gmane.org>
Subject: Re: [PATCH 8/8] IB/srp: Add multichannel support
Date: Thu, 02 Oct 2014 18:45:55 +0200 [thread overview]
Message-ID: <542D8143.3050305@acm.org> (raw)
In-Reply-To: <542C31C4.1020702-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
On 10/01/14 18:54, Jens Axboe wrote:
> Lets get rid of the blk_mq_tag struct and just have it be an u32 or
> something. We could potentially typedef it, but I'd prefer to just have
> it be an unsigned 32-bit int.
>
> Probably also need some init time safety checks that 16-bits is enough
> to hold BLK_MQ_MAX_DEPTH. Just in case that is ever bumped, or the queue
> prefixing changes.
>
> And I think we need to name this better. Your comment correctly
> describes that this generates a unique tag queue wide, but the name of
> the function implies that we just return the request tag. Most drivers
> wont use this. Perhaps add a queue flag that tells us that we should
> generate these tags and have it setup ala:
>
> u32 blk_mq_unique_rq_tag(struct request *rq)
> {
> struct request_queue *q = rq->q;
> u32 tag = rq->tag & ((1 << 16) - 1);
> struct blk_mq_hw_ctx *hctx;
>
> hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
> return tag | (hctx->queue_num << 16);
> }
>
> u32 blk_mq_rq_tag(struct request *rq)
> {
> struct request_queue *q = rq->q;
>
> if (q->mq_ops &&
> test_bit(QUEUE_FLAG_UNIQUE_TAGS, &q->queue_flags))
> return blk_mq_unique_rq_tag(rq);
>
> return rq->tag;
> }
Would it be acceptable to let blk_mq_rq_tag() always return the
hardware context number and the per-hctx tag ? Block and SCSI LLD
drivers that do not need the hardware context number can still use
rq->tag. Drivers that need both can use blk_mq_rq_tag(). That way we do
not have to introduce a new queue flag. How about the patch below
(which is still missing a BLK_MQ_MAX_DEPTH check):
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index c1b9242..8cfbc7b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -595,6 +595,30 @@ int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int tdepth)
return 0;
}
+/**
+ * blk_mq_rq_tag() - return a tag that is unique queue-wide
+ *
+ * The tag field in struct request is unique per hardware queue but not
+ * queue-wide. Hence this function.
+ *
+ * Note: When called for a non-multiqueue request queue, the hardware context
+ * index is set to zero.
+ */
+u32 blk_mq_rq_tag(struct request *rq)
+{
+ struct request_queue *q = rq->q;
+ struct blk_mq_hw_ctx *hctx;
+ int hwq = 0;
+
+ if (q->mq_ops) {
+ hctx = q->mq_ops->map_queue(q, rq->mq_ctx->cpu);
+ hwq = hctx->queue_num;
+ }
+
+ return blk_mq_build_rq_tag(hwq, rq->tag);
+}
+EXPORT_SYMBOL(blk_mq_rq_tag);
+
ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)
{
char *orig_page = page;
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index eac4f31..c5be535 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -166,6 +166,19 @@ bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
struct request *blk_mq_alloc_request(struct request_queue *q, int rw,
gfp_t gfp, bool reserved);
struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag);
+u32 blk_mq_rq_tag(struct request *rq);
+static inline u32 blk_mq_build_rq_tag(int hwq, int tag)
+{
+ return (hwq << 16) | (tag & ((1 << 16) - 1));
+}
+static inline u16 blk_mq_rq_tag_to_hwq(u32 rq_tag)
+{
+ return rq_tag >> 16;
+}
+static inline u16 blk_mq_rq_tag_to_tag(u32 rq_tag)
+{
+ return rq_tag & ((1 << 16) - 1);
+}
struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);
--
1.8.4.5
--
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:[~2014-10-02 16:45 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-19 12:55 [PATCH RFC 0/8] IB/srp: Add multichannel support Bart Van Assche
2014-09-19 12:56 ` Bart Van Assche
2014-09-19 18:02 ` Sagi Grimberg
2014-09-19 12:57 ` [PATCH 2/8] scsi-mq: Add support for multiple hardware queues Bart Van Assche
[not found] ` <541C281E.9090206-HInyCGIudOg@public.gmane.org>
2014-09-19 18:05 ` Sagi Grimberg
2014-09-19 18:11 ` Christoph Hellwig
[not found] ` <CAF9gx6JfP2bGyMauB6LzepZP_vKEvrd-sPZc5CRuOrtgQ_UCSw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-26 11:08 ` Ming Lei
[not found] ` <CACVXFVMiYsW=dszQ6mE-o_L8fEDdkO59vJ5qeHKch5c33K_QXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-26 14:02 ` Bart Van Assche
2014-09-19 12:57 ` [PATCH 3/8] scsi-mq: Pass hctx to low-level SCSI drivers Bart Van Assche
[not found] ` <541C27BF.6070609-HInyCGIudOg@public.gmane.org>
2014-09-19 12:58 ` [PATCH 4/8] IB/srp: Move ib_destroy_cm_id() call into srp_free_ch_ib() Bart Van Assche
[not found] ` <541C285B.5010309-HInyCGIudOg@public.gmane.org>
2014-09-19 18:10 ` Sagi Grimberg
2014-09-19 12:58 ` [PATCH 5/8] IB/srp: Remove stale connection retry mechanism Bart Van Assche
2014-09-19 18:25 ` Sagi Grimberg
[not found] ` <541C287D.1050900-HInyCGIudOg@public.gmane.org>
2014-09-20 17:45 ` Or Gerlitz
[not found] ` <CAJ3xEMhPKiut4MwZH9F7-T0+u7B6XPuh-FTZpA=Xe4ViAj5UUQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-02 10:34 ` Bart Van Assche
2014-09-19 13:00 ` [PATCH 8/8] IB/srp: Add multichannel support Bart Van Assche
[not found] ` <541C28E0.7010705-HInyCGIudOg@public.gmane.org>
2014-09-19 14:28 ` Ming Lei
[not found] ` <CACVXFVPzz37J-613NZCfPStUBxf0rLOtz71LJ07PpCxYg5nn+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-19 15:21 ` Bart Van Assche
[not found] ` <541C49EC.6030404-HInyCGIudOg@public.gmane.org>
2014-09-19 15:27 ` Ming Lei
2014-09-19 15:35 ` Bart Van Assche
2014-09-19 15:38 ` Jens Axboe
2014-09-19 17:30 ` Sagi Grimberg
2014-09-19 17:33 ` Jens Axboe
2014-09-19 18:11 ` Christoph Hellwig
[not found] ` <541C4DF1.4090604-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-01 16:08 ` Bart Van Assche
2014-10-01 16:54 ` Jens Axboe
2014-10-01 21:14 ` Christoph Hellwig
[not found] ` <542C31C4.1020702-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-02 16:45 ` Bart Van Assche [this message]
2014-10-02 16:55 ` Jens Axboe
[not found] ` <542D8368.8080604-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2014-10-03 13:01 ` Bart Van Assche
2014-10-03 14:24 ` Jens Axboe
[not found] ` <542D8143.3050305-HInyCGIudOg@public.gmane.org>
2014-10-02 17:30 ` Christoph Hellwig
2014-10-06 11:16 ` Bart Van Assche
[not found] ` <54327A21.6070202-HInyCGIudOg@public.gmane.org>
2014-10-10 20:16 ` Roland Dreier
2014-09-23 16:32 ` Sagi Grimberg
[not found] ` <5421A093.1070203-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-09-23 19:02 ` Bart Van Assche
2014-09-24 12:22 ` Sagi Grimberg
2014-09-24 13:13 ` Bart Van Assche
[not found] ` <5422C395.7090902-HInyCGIudOg@public.gmane.org>
2014-09-24 13:38 ` Sagi Grimberg
[not found] ` <5422C970.4050306-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-09-24 13:43 ` Sagi Grimberg
2014-10-07 12:51 ` Bart Van Assche
[not found] ` <5433E1B5.1030103-HInyCGIudOg@public.gmane.org>
2014-10-13 8:17 ` Sagi Grimberg
[not found] ` <543B8AB0.1090704-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-10-13 8:52 ` Bart Van Assche
2014-10-01 16:14 ` [PATCH RFC] scsi_tcq.h: Add support for multiple hardware queues Bart Van Assche
2014-09-19 12:59 ` [PATCH 6/8] IB/srp: Avoid that I/O hangs due to a cable pull during LUN scanning Bart Van Assche
2014-09-19 12:59 ` [PATCH 7/8] IB/srp: Separate target and channel variables Bart Van Assche
2014-09-19 18:47 ` Sagi Grimberg
[not found] ` <541C28C8.7000007-HInyCGIudOg@public.gmane.org>
2014-09-23 16:07 ` Sagi Grimberg
2014-09-23 20:00 ` Bart Van Assche
2014-09-19 18:31 ` [PATCH RFC 0/8] IB/srp: Add multichannel support Jens Axboe
2014-09-22 14:37 ` Christoph Hellwig
[not found] ` <20140922143731.GA15377-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-22 16:25 ` Bart Van Assche
2014-09-22 16:31 ` Jens Axboe
2014-09-22 16:39 ` Jens Axboe
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=542D8143.3050305@acm.org \
--to=bvanassche-hinycgiudog@public.gmane.org \
--cc=Elliott-VXdhtT5mjnY@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@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;
as well as URLs for NNTP newsgroup(s).