Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3922784imw; Mon, 11 Jul 2022 19:59:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sG2nG/TNSThE32c8QfDS/PDo2otrihMuSz4Mh6TtH0ARzAYIwQLfCjgWHcu+gd9r2qhAH6 X-Received: by 2002:a17:902:d544:b0:16b:d981:5c2e with SMTP id z4-20020a170902d54400b0016bd9815c2emr21317505plf.22.1657594754543; Mon, 11 Jul 2022 19:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657594754; cv=none; d=google.com; s=arc-20160816; b=Ot/2+mxyydNcxYxhknOFqpk7KfmFBO0nE4vLr0OEC4CV9KopWamDkmR5eqdDkUHgwu bpZq6vW8OScvRi76sUHixcu3D/mzAWATNMYP3frSMa78aBxdzs0YGNeIZwtxeRgK0l3Z 9EjcMtWBJ86/ErVDlnfVq+I36pjcMfE1s0GiRADFzsG8Yg1UaDSaCue2vrAl0JhU+VEi 2N5Y4T30vovRorwnrh/i/3rxdIHrgHBSdDgjt0YdUKlIZZ8/aqUlK+j/evGYHU3RxWXy sVNm3FeEWEEt9ykOovNvCziFuBF2xsh4EutoPTL4+YU5qOXwxTumkYcPThi5TJF6KpD/ +UPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x1/jSIRVCmdrp57N6o2GT3cX8fSlWGgTPHdnSTG+KfQ=; b=JF04HpL4E/IdvtCPjV4up2ySXpjCVPWJPcj3SyRfx1OMuoK8WGKKeHIZBMhLBt7ujv oYt2uzyMZ85ASqP9tQi1zquOpc3lwoDiXGScGUHJnqLoGvIPrzDI8EonRgTO2NXY0MbF v5e6cgLJWn0l2SRRDSxDFCRmNZUWhYWoXILmbpdWrTq/TjqzAC5wpBNTYYQCWvfv6X+6 Ili6B1fPSijDaKkPO0jLpKuq10s6XFt7W7/+WpicaxAo4vchoaOsBquZyV85LMIsrJAe kp0gcINtILfLFL/xqKdE6dboFY0YYy/oEy67CoN82Slbaho8iCe/f83EWx8zMYQDNg3F iuWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zt2hFRNb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x22-20020a1709027c1600b0016a6d44257csi10819904pll.589.2022.07.11.19.59.02; Mon, 11 Jul 2022 19:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zt2hFRNb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231502AbiGLCrR (ORCPT + 99 others); Mon, 11 Jul 2022 22:47:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbiGLCrP (ORCPT ); Mon, 11 Jul 2022 22:47:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 47C458CCA2 for ; Mon, 11 Jul 2022 19:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657594034; 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=x1/jSIRVCmdrp57N6o2GT3cX8fSlWGgTPHdnSTG+KfQ=; b=Zt2hFRNbJI0oL3dqhcZkhxDObX0UAUPlajKapQGui84aZuXXliqu7wNIdz79lJsYa7gVQ+ rWn68vPiHFCT5E5LSrsP6W0/HlqfgqvyR9x39s+m09BSAqrA9B+glWGsqioRJ2tc4ity2D FYICWzsNNifUgChgfi8Wjai0xZOHqVc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-344-exFlLAfsO4GNH_20BlqzDQ-1; Mon, 11 Jul 2022 22:47:03 -0400 X-MC-Unique: exFlLAfsO4GNH_20BlqzDQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD41C2806AB5; Tue, 12 Jul 2022 02:47:02 +0000 (UTC) Received: from T590 (ovpn-8-24.pek2.redhat.com [10.72.8.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4987440D282E; Tue, 12 Jul 2022 02:46:56 +0000 (UTC) Date: Tue, 12 Jul 2022 10:46:49 +0800 From: Ming Lei To: Ziyang Zhang Cc: Gabriel Krisman Bertazi , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, Xiaoguang Wang Subject: Re: [PATCH V4 2/2] ublk_drv: add UBLK_IO_REFETCH_REQ for supporting to build as module Message-ID: References: <20220711022024.217163-1-ming.lei@redhat.com> <20220711022024.217163-3-ming.lei@redhat.com> <87lesze7o3.fsf@collabora.com> <1f021cc5-3cbe-a69d-7d50-8c758174d178@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f021cc5-3cbe-a69d-7d50-8c758174d178@linux.alibaba.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 12, 2022 at 10:26:47AM +0800, Ziyang Zhang wrote: > On 2022/7/12 04:06, Gabriel Krisman Bertazi wrote: > > Ming Lei writes: > > > >> Add UBLK_IO_REFETCH_REQ command to fetch the incoming io request in > >> ubq daemon context, so we can avoid to call task_work_add(), then > >> it is fine to build ublk driver as module. > >> > >> In this way, iops is affected a bit, but just by ~5% on ublk/null, > >> given io_uring provides pretty good batching issuing & completing. > >> > >> One thing to be careful is race between ->queue_rq() and handling > >> abort, which is avoided by quiescing queue when aborting queue. > >> Except for that, handling abort becomes much easier with > >> UBLK_IO_REFETCH_REQ since aborting handler is strictly exclusive with > >> anything done in ubq daemon kernel context. > > > > Hi Ming, > > > > FWIW, I'm not very fond this change. It adds complexity to the kernel > > driver and to the userspace server implementation, who now have to deal > > with different interface semantics just because the driver was built-in > > or built as a module. I don't think the tristate support warrants such > > complexity. I was hoping we might get away with exporting that symbol > > or adding a built-in ubd-specific wrapper that can be exported and > > invokes task_work_add. > > > > Either way, Alibaba seems to consider this feature useful, and if that > > is the case, we can just not use it on our side. > > Our app handles IOs itself with network(RPC) and internal memory pool > so UBLK_IO_REFETCH_REQ > (actually I think it is like NEED_GET_DATA in the earlist version :) ) > is helpful to us because we can assign data buffer address AFTER the app > gets one IO requests(WRITE, with data size) and we avoid PRE-allocating buffers. Maybe you can consider to switch to pre-allocation. The patch[1] for pinning io vm pages in the io lifetime has been done, just not included in this patchset, and it passes all the builtin tests, but there is still space for further optimization. With that patchset[1] in, io pages becomes pinned during whole io handling time, after io is done, mm can reclaim these pages without needing to swapout. It works like madvise(MADV_DONTNEED). [1] https://github.com/ming1/linux/commits/ubd-master Thanks, Ming