From patchwork Sat Feb 3 04:21:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10198305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A93A60388 for ; Sat, 3 Feb 2018 04:22:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BB0528C2E for ; Sat, 3 Feb 2018 04:22:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E64528C6C; Sat, 3 Feb 2018 04:22:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B020028C2E for ; Sat, 3 Feb 2018 04:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbeBCEWY (ORCPT ); Fri, 2 Feb 2018 23:22:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43512 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751796AbeBCEWX (ORCPT ); Fri, 2 Feb 2018 23:22:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AC79C0587F0; Sat, 3 Feb 2018 04:22:23 +0000 (UTC) Received: from localhost (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 126DC8A984; Sat, 3 Feb 2018 04:22:11 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , Mike Snitzer Cc: linux-scsi@vger.kernel.org, Hannes Reinecke , Arun Easi , Omar Sandoval , "Martin K . Petersen" , James Bottomley , Christoph Hellwig , Don Brace , Kashyap Desai , Peter Rivera , Paolo Bonzini , Laurence Oberman , Ming Lei Subject: [PATCH 4/5] scsi: introduce force_blk_mq Date: Sat, 3 Feb 2018 12:21:11 +0800 Message-Id: <20180203042112.15239-5-ming.lei@redhat.com> In-Reply-To: <20180203042112.15239-1-ming.lei@redhat.com> References: <20180203042112.15239-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 03 Feb 2018 04:22:23 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From scsi driver view, it is a bit troublesome to support both blk-mq and non-blk-mq at the same time, especially when drivers need to support multi hw-queue. This patch introduces 'force_blk_mq' to scsi_host_template so that drivers can provide blk-mq only support, so driver code can avoid the trouble for supporting both. This patch may clean up driver a lot by providing blk-mq only support, espeically it is easier to convert multiple reply queues into blk_mq's MQ for the following purposes: 1) use blk_mq multiple hw queue to deal with allocated irq vectors of all offline CPU affinity[1]: [1] https://marc.info/?l=linux-kernel&m=151748144730409&w=2 Now 84676c1f21e8ff5(genirq/affinity: assign vectors to all possible CPUs) has been merged to V4.16-rc, and it is easy to allocate all offline CPUs for some irq vectors, this can't be avoided even though the allocation is improved. So all these drivers have to avoid to ask HBA to complete request in reply queue which hasn't online CPUs assigned. This issue can be solved generically and easily via blk_mq(scsi_mq) multiple hw queue by mapping each reply queue into hctx. 2) some drivers[1] require to complete request in the submission CPU for avoiding hard/soft lockup, which is easily done with blk_mq, so not necessary to reinvent wheels for solving the problem. [2] https://marc.info/?t=151601851400001&r=1&w=2 Sovling the above issues for non-MQ path may not be easy, or introduce unnecessary work, especially we plan to enable SCSI_MQ soon as discussed recently[3]: [3] https://marc.info/?l=linux-scsi&m=151727684915589&w=2 Cc: Hannes Reinecke Cc: Arun Easi Cc: Omar Sandoval , Cc: "Martin K. Petersen" , Cc: James Bottomley , Cc: Christoph Hellwig , Cc: Don Brace Cc: Kashyap Desai Cc: Peter Rivera Cc: Laurence Oberman Cc: Mike Snitzer Signed-off-by: Ming Lei Reviewed-by: Hannes Reinecke --- drivers/scsi/hosts.c | 1 + include/scsi/scsi_host.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index fe3a0da3ec97..c75cebd7911d 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -471,6 +471,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->dma_boundary = 0xffffffff; shost->use_blk_mq = scsi_use_blk_mq; + shost->use_blk_mq = scsi_use_blk_mq || !!shost->hostt->force_blk_mq; device_initialize(&shost->shost_gendev); dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index a8b7bf879ced..4118760e5c32 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -452,6 +452,9 @@ struct scsi_host_template { /* True if the controller does not support WRITE SAME */ unsigned no_write_same:1; + /* tell scsi core we support blk-mq only */ + unsigned force_blk_mq:1; + /* * Countdown for host blocking with no commands outstanding. */