Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2083634ybc; Wed, 13 Nov 2019 08:45:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxuzc4Sfx6bt0wC5YspqrqVn8zWKLpWb3znxfl+UR5R0bZ461dI1XgFV5Mev7LoXDIciImm X-Received: by 2002:a17:906:5251:: with SMTP id y17mr3787873ejm.108.1573663511098; Wed, 13 Nov 2019 08:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573663511; cv=none; d=google.com; s=arc-20160816; b=ikmOE4Fp7DtSCpnuuD8laQjNH77NI3Lth3AbD+y6nRH8koKgWbR2TY5ZcOYUD3Dv/U HQVxZXSZdJREqTfQvQsHSenSYgKjdjD57jsBnSuzQ0OFQ5FuVVOXKXb/v8OvzHqskjLP tyj6MXU4sGZfNWMv+EVf3lYCw5JXxvWQuRzkHsr1hjmXN+qhvHSaxb+caXyQd4KzuR85 ga1HzKFU4qIO1wO+hpShd+q3L6XHiAtBhjmADOkXlRyOZZRlJIoJICq3EA8QgRzG80Ug 8ZMg2fkJIVxm/6KTUdoCW907mLn/EJQmJlGGkN514e2kT+ijz3EBpLO0U/mubUMS5Rju 4FAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=MU+bqgJTwmlY+9RWJ1ObIMW6xWBeWJGRf9VG9VrutVo=; b=b+NDn7wHJExlO3zNJ0NoHjWLmlY4pnCOzNe/+2grAPFmkywzkfV320P/tQQ6jqFJjy OjrAjveHegUN7EiBk3X4W7YThT9BwV4OfgU9qkNrXCY44s93SmpE7C7Q4lkSsTx600Bv A+NtQ19OFYGEaBJyrYGiJf1FC8gHvdxQ53b+l2+ibCMMOW5junvaVhfawqibArn8tVfT T1CaR2Zk8tTPIShbn1hBA8QIYdEFXjsGdcws0vgXJsc4XR4C1sUpGYsprG9SibypxpEq GMe4H3/MdlMkI1EN9ep6MioJl2Dt4IZAy+o2KFsmXf8CJeCR2au4g/gvQe7/54F3Hy61 oqFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qh13si1496261ejb.407.2019.11.13.08.44.45; Wed, 13 Nov 2019 08:45:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727890AbfKMPi1 (ORCPT + 99 others); Wed, 13 Nov 2019 10:38:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:60096 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726335AbfKMPi1 (ORCPT ); Wed, 13 Nov 2019 10:38:27 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BC271B49B; Wed, 13 Nov 2019 15:38:23 +0000 (UTC) Subject: Re: [PATCH RFC 3/5] blk-mq: Facilitate a shared tags per tagset To: John Garry , "axboe@kernel.dk" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" Cc: "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "ming.lei@redhat.com" , "hare@suse.com" , "bvanassche@acm.org" , "chenxiang (M)" References: <1573652209-163505-1-git-send-email-john.garry@huawei.com> <1573652209-163505-4-git-send-email-john.garry@huawei.com> <32880159-86e8-5c48-1532-181fdea0df96@suse.de> <2cbf591c-8284-8499-7804-e7078cf274d2@huawei.com> From: Hannes Reinecke Openpgp: preference=signencrypt Autocrypt: addr=hare@suse.de; prefer-encrypt=mutual; keydata= mQINBE6KyREBEACwRN6XKClPtxPiABx5GW+Yr1snfhjzExxkTYaINHsWHlsLg13kiemsS6o7 qrc+XP8FmhcnCOts9e2jxZxtmpB652lxRB9jZE40mcSLvYLM7S6aH0WXKn8bOqpqOGJiY2bc 6qz6rJuqkOx3YNuUgiAxjuoYauEl8dg4bzex3KGkGRuxzRlC8APjHlwmsr+ETxOLBfUoRNuE b4nUtaseMPkNDwM4L9+n9cxpGbdwX0XwKFhlQMbG3rWA3YqQYWj1erKIPpgpfM64hwsdk9zZ QO1krgfULH4poPQFpl2+yVeEMXtsSou915jn/51rBelXeLq+cjuK5+B/JZUXPnNDoxOG3j3V VSZxkxLJ8RO1YamqZZbVP6jhDQ/bLcAI3EfjVbxhw9KWrh8MxTcmyJPn3QMMEp3wpVX9nSOQ tzG72Up/Py67VQe0x8fqmu7R4MmddSbyqgHrab/Nu+ak6g2RRn3QHXAQ7PQUq55BDtj85hd9 W2iBiROhkZ/R+Q14cJkWhzaThN1sZ1zsfBNW0Im8OVn/J8bQUaS0a/NhpXJWv6J1ttkX3S0c QUratRfX4D1viAwNgoS0Joq7xIQD+CfJTax7pPn9rT////hSqJYUoMXkEz5IcO+hptCH1HF3 qz77aA5njEBQrDRlslUBkCZ5P+QvZgJDy0C3xRGdg6ZVXEXJOQARAQABtCpIYW5uZXMgUmVp bmVja2UgKFN1U0UgTGFicykgPGhhcmVAc3VzZS5kZT6JAkEEEwECACsCGwMFCRLMAwAGCwkI BwMCBhUIAgkKCwQWAgMBAh4BAheABQJOisquAhkBAAoJEGz4yi9OyKjPOHoQAJLeLvr6JNHx GPcHXaJLHQiinz2QP0/wtsT8+hE26dLzxb7hgxLafj9XlAXOG3FhGd+ySlQ5wSbbjdxNjgsq FIj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bird/60.7.2 MIME-Version: 1.0 In-Reply-To: <2cbf591c-8284-8499-7804-e7078cf274d2@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/13/19 3:57 PM, John Garry wrote: > On 13/11/2019 14:06, Hannes Reinecke wrote: >> On 11/13/19 2:36 PM, John Garry wrote: >>> Some SCSI HBAs (such as HPSA, megaraid, mpt3sas, hisi_sas_v3 ..) support >>> multiple reply queues with single hostwide tags. >>> >>> In addition, these drivers want to use interrupt assignment in >>> pci_alloc_irq_vectors(PCI_IRQ_AFFINITY). However, as discussed in [0], >>> CPU hotplug may cause in-flight IO completion to not be serviced when an >>> interrupt is shutdown. >>> >>> To solve that problem, Ming's patchset to drain hctx's should ensure no >>> IOs are missed in-flight [1]. >>> >>> However, to take advantage of that patchset, we need to map the HBA HW >>> queues to blk mq hctx's; to do that, we need to expose the HBA HW >>> queues. >>> >>> In making that transition, the per-SCSI command request tags are no >>> longer unique per Scsi host - they are just unique per hctx. As such, >>> the >>> HBA LLDD would have to generate this tag internally, which has a certain >>> performance overhead. >>> >>> However another problem is that blk mq assumes the host may accept >>> (Scsi_host.can_queue * #hw queue) commands. In [2], we removed the Scsi >>> host busy counter, which would stop the LLDD being sent more than >>> .can_queue commands; however, we should still ensure that the block >>> layer >>> does not issue more than .can_queue commands to the Scsi host. >>> >>> To solve this problem, introduce a shared tags per blk_mq_tag_set, which >>> may be requested when allocating the tagset. >>> >>> New flag BLK_MQ_F_TAG_HCTX_SHARED should be set when requesting the >>> tagset. >>> >>> This is based on work originally from Ming Lei in [3]. >>> >>> [0] >>> https://lore.kernel.org/linux-block/alpine.DEB.2.21.1904051331270.1802@nanos.tec.linutronix.de/ >>> >>> [1] >>> https://lore.kernel.org/linux-block/20191014015043.25029-1-ming.lei@redhat.com/ >>> >>> [2] >>> https://lore.kernel.org/linux-scsi/20191025065855.6309-1-ming.lei@redhat.com/ >>> >>> [3] >>> https://lore.kernel.org/linux-block/20190531022801.10003-1-ming.lei@redhat.com/ >>> >>> >>> Signed-off-by: John Garry >>> --- >>>   block/blk-core.c       |  1 + >>>   block/blk-flush.c      |  2 + >>>   block/blk-mq-debugfs.c |  2 +- >>>   block/blk-mq-tag.c     | 85 ++++++++++++++++++++++++++++++++++++++++++ >>>   block/blk-mq-tag.h     |  1 + >>>   block/blk-mq.c         | 61 +++++++++++++++++++++++++----- >>>   block/blk-mq.h         |  9 +++++ >>>   include/linux/blk-mq.h |  3 ++ >>>   include/linux/blkdev.h |  1 + >>>   9 files changed, 155 insertions(+), 10 deletions(-) >>> >> [ .. ] >>> @@ -396,15 +398,17 @@ static struct request >>> *blk_mq_get_request(struct request_queue *q, >>>           blk_mq_tag_busy(data->hctx); >>>       } >>>   -    tag = blk_mq_get_tag(data); >>> -    if (tag == BLK_MQ_TAG_FAIL) { >>> -        if (clear_ctx_on_error) >>> -            data->ctx = NULL; >>> -        blk_queue_exit(q); >>> -        return NULL; >>> +    if (data->hctx->shared_tags) { >>> +        shared_tag = blk_mq_get_shared_tag(data); >>> +        if (shared_tag == BLK_MQ_TAG_FAIL) >>> +            goto err_shared_tag; >>>       } >>>   -    rq = blk_mq_rq_ctx_init(data, tag, data->cmd_flags, >>> alloc_time_ns); >>> +    tag = blk_mq_get_tag(data); >>> +    if (tag == BLK_MQ_TAG_FAIL) >>> +        goto err_tag; >>> + >>> +    rq = blk_mq_rq_ctx_init(data, tag, shared_tag, data->cmd_flags, >>> alloc_time_ns); >>>       if (!op_is_flush(data->cmd_flags)) { >>>           rq->elv.icq = NULL; >>>           if (e && e->type->ops.prepare_request) { > > Hi Hannes, > >> Why do you need to keep a parallel tag accounting between 'normal' and >> 'shared' tags here? >> Isn't is sufficient to get a shared tag only, and us that in lieo of the >> 'real' one? > > In theory, yes. Just the 'shared' tag should be adequate. > > A problem I see with this approach is that we lose the identity of which > tags are allocated for each hctx. As an example for this, consider > blk_mq_queue_tag_busy_iter(), which iterates the bits for each hctx. > Now, if you're just using shared tags only, that wouldn't work. > > Consider blk_mq_can_queue() as another example - this tells us if a hctx > has any bits unset, while with only using shared tags it would tell if > any bits unset over all queues, and this change in semantics could break > things. At a glance, function __blk_mq_tag_idle() looks problematic also. > > And this is where it becomes messy to implement. > Oh, my. Indeed, that's correct. But then we don't really care _which_ shared tag is assigned; so wouldn't be we better off by just having an atomic counter here? Cache locality will be blown anyway ... Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer