Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp281945ybk; Sat, 9 May 2020 02:45:09 -0700 (PDT) X-Google-Smtp-Source: APiQypKl/y7/CX1aHkg2ohZdb4vZkawMYVAqKQ6UVbO+cyFzbRhSr6K7xuIy1ULv9M4XRlcU1W9W X-Received: by 2002:a17:906:7d1:: with SMTP id m17mr5206018ejc.247.1589017509021; Sat, 09 May 2020 02:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589017509; cv=none; d=google.com; s=arc-20160816; b=tyKUn/0gIFmxo2AMzeFjV+tMxCluArX+F3uwosppT1lXAKa6jaPd+j0AhoRIX+1Mjk JFACFZXLAMaTyxvyzz/SKh5lrxLu9z15IErCHdkN/FQdHnZGS+wUgliXuDYR723OcUZM PbQCTr6fc7Hrx3/hQ8WuUlrHAZ4AbxrSaKEZvJCXRbyqP7YqFMS9y2q9ujbniTVDfDYa TRE1zOCQLDJBbUAbExRPHcrFKqRy7M7yyjE6S68MfTJNbfzMV1iVsvozqsCRFAm0zIfk T2wQewQ98OHWWiMJu9TXQeyTo69GmyDPSLRVEkA0W7cBL7ZDQWEhsNAO2VfviT/kJLrD gkVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=l8D8Ae345rAYDqawjkcSExOxW2YprJe5XqaST1kNQ6s=; b=yJgtDBsxHt6yuvB1pVoTkD7HbISxl7b5jSr6uj4Zy5ugCY3T7RCXLG+81EKg+TsQlD TlfWmQ0wVQvq71hQ0D6hdIfq5T85JUNPgMlxjpW2In5cHXKUq6MBh/VMBamWYU3fB3Pq VNU1Bx+i3KTrGxfpyNy9TTs6CzdL7uOmifHz9askpiLNNCrE9qqZ7pf80aL9s+ft0UFi PvZMI4OFpei256yWkjSUAmtWIwnuc6MQC/+QVEYPb7i4QSSlgBfZJWK94zr3q1uErptY o84IZjVfgWPLfXcbPaaOFt6luM3OPyNpU2hC/1qlYTjWSj/r42vqJ/XC5t3itxOdVesi R7KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=blAbgB6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si2539711edw.278.2020.05.09.02.44.46; Sat, 09 May 2020 02:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=blAbgB6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbgEIJn0 (ORCPT + 99 others); Sat, 9 May 2020 05:43:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60593 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726885AbgEIJn0 (ORCPT ); Sat, 9 May 2020 05:43:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589017404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l8D8Ae345rAYDqawjkcSExOxW2YprJe5XqaST1kNQ6s=; b=blAbgB6LYoumV5wXSHp6j+mMGsHOFMYCLHYR1SKUb0oVrpjtb3sjxnjSeHwM20DBLlt4ru GfZMUNq4rcMXLfqyBy9FZAJ5i5q+QjmwHGnK2UE0UwnxVuxCOQUySVpB8hosvaOD2SkTdJ rPtg5XirLtJXwZOTt3ku0hE2HuS03ro= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-rAyD8qh5NLyXbbJ-2MeO7Q-1; Sat, 09 May 2020 05:43:22 -0400 X-MC-Unique: rAyD8qh5NLyXbbJ-2MeO7Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3763C107ACCA; Sat, 9 May 2020 09:43:20 +0000 (UTC) Received: from T590 (ovpn-12-90.pek2.redhat.com [10.72.12.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15F1D5D9CD; Sat, 9 May 2020 09:43:10 +0000 (UTC) Date: Sat, 9 May 2020 17:43:06 +0800 From: Ming Lei To: Baolin Wang Cc: Sagi Grimberg , Christoph Hellwig , axboe@kernel.dk, Ulf Hansson , Adrian Hunter , Arnd Bergmann , Linus Walleij , Paolo Valente , Orson Zhai , Chunyan Zhang , linux-mmc , linux-block , LKML Subject: Re: [RFC PATCH v2 1/7] block: Extand commit_rqs() to do batch processing Message-ID: <20200509094306.GA1414369@T590> References: <20200427154645.GA1201@infradead.org> <20200508214639.GA1389136@T590> <20200508232222.GA1391368@T590> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 09, 2020 at 04:57:48PM +0800, Baolin Wang wrote: > On Sat, May 9, 2020 at 7:22 AM Ming Lei wrote: > > > > Hi Sagi, > > > > On Fri, May 08, 2020 at 03:19:45PM -0700, Sagi Grimberg wrote: > > > Hey Ming, > > > > > > > > Would it make sense to elevate this flag to a request_queue flag > > > > > (QUEUE_FLAG_ALWAYS_COMMIT)? > > > > > > > > request queue flag usually is writable, however this case just needs > > > > one read-only flag, so I think it may be better to make it as > > > > tagset/hctx flag. > > > > > > I actually intended it to be writable. > > > > > > > > I'm thinking of a possibility that an I/O scheduler may be used > > > > > to activate this functionality rather than having the driver set > > > > > it necessarily... > > > > > > > > Could you explain a bit why I/O scheduler should activate this > > > > functionality? > > > > > > Sure, I've recently seen some academic work showing the benefits > > > of batching in tcp/ip based block drivers. The problem with the > > > approaches taken is that I/O scheduling is exercised deep down in the > > > driver, which is not the direction I'd like to go if we are want > > > to adopt some of the batching concepts. > > > > > > I spent some (limited) time thinking about this, and it seems to > > > me that there is an opportunity to implement this as a dedicated > > > I/O scheduler, and tie it to driver specific LLD stack optimizations > > > (net-stack for example) relying on the commit_rq/bd->last hints. > > > > > > When scanning the scheduler code, I noticed exactly the phenomenon that > > > this patchset is attempting to solve and Christoph referred me to it. > > > Now I'm thinking if we can extend this batching optimization for both > > > use-cases. > > > > Got it, thanks for the sharing. > > > > > > > > > batching submission may be good for some drivers, and currently > > > > we only do it in limited way. One reason is that there is extra > > > > cost for full batching submission, such as this patch requires > > > > one extra .commit_rqs() for each dispatch, and lock is often needed > > > > in this callback. > > > > > > That is not necessarily the case at all. > > > > So far, all in-tree .commit_rqs() implementation requires lock. > > > > > > > > > IMO it can be a win for some slow driver or device, but may cause > > > > a little performance drop for fast driver/device especially in workload > > > > of not-batching submission. > > > > > > You're mostly correct. This is exactly why an I/O scheduler may be > > > applicable here IMO. Mostly because I/O schedulers tend to optimize for > > > something specific and always present tradeoffs. Users need to > > > understand what they are optimizing for. > > > > > > Hence I'd say this functionality can definitely be available to an I/O > > > scheduler should one exist. > > > > > > > I guess it is just that there can be multiple requests available from > > scheduler queue. Actually it can be so for other non-nvme drivers in > > case of none, such as SCSI. > > > > Another way is to use one per-task list(such as plug list) to hold the > > requests for dispatch, then every drivers may see real .last flag, so they > > may get chance for optimizing batch queuing. I will think about the > > idea further and see if it is really doable. > > How about my RFC v1 patch set[1], which allows dispatching more than > one request from the scheduler to support batch requests? > > [1] > https://lore.kernel.org/patchwork/patch/1210034/ > https://lore.kernel.org/patchwork/patch/1210035/ Basically, my idea is to dequeue request one by one, and for each dequeued request: - we try to get a budget and driver tag, if both succeed, add the request to one per-task list which can be stored in stack variable, then continue to dequeue more request - if either budget or driver tag can't be allocated for this request, marks the last request in the per-task list as .last, and send the batching requests stored in the list to LLD - when queueing batching requests to LLD, if one request isn't queued to driver successfully, calling .commit_rqs() like before, meantime adding the remained requests in the per-task list back to scheduler queue or hctx->dispatch. One issue is that this way might degrade sequential IO performance if the LLD just tells queue busy to blk-mq via return value of .queue_rq(), so I guess we still may need one flag, such as BLK_MQ_F_BATCHING_SUBMISSION. thanks, Ming