Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9206356rwp; Thu, 20 Jul 2023 00:52:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFG897ndbKShIlSiNYX02vbZf/bc25NndzAgB4IdIxAM7mqVPOAQnRNZVJwcXWrb/7Zde26 X-Received: by 2002:a17:906:3015:b0:994:34a6:50cf with SMTP id 21-20020a170906301500b0099434a650cfmr4028440ejz.49.1689839571442; Thu, 20 Jul 2023 00:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689839571; cv=none; d=google.com; s=arc-20160816; b=hcRHX3rNITuckIPZFK6HqzkfJG+9YfburVUzIGm987a9vwMZJ/Yb9roPw38Qz5tvtQ s0RglkzdaPDJvN42x00x0KzpY8tNw3fsAHTmE2/e3txb22IktHH7eSOgtB23kD3ZzF2o eEWlbN0MWkyMKEgwhQgnAPkUXGjne2jIbRGdWGUvDY0EZ3sV0R5gWSt+wwP8fKpYzUMH ur/ukNMZf837OPbLO3tEMMcyWZEaheX5PFS87sTz4KrqtHl/y/7L99Nxfi+Wrg2Nq9gz n+cDa3beB0ajI8tW6hYYEAlIiSPZHsNy73FMATtJNiVZuOo0XYBRoy3BO/PcljnyJIR7 JFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=a0IV7oU5X6rrGGO6XSfVofpSeXCRWXztXChqXSJhj8Y=; fh=JgPwpjSn9AQMkl4Jz0gtjj9+I7WEsL1DQwLyd2HNSh8=; b=WiHjqRhTD3I7oocsvOZ3crrhGsM+++aRxiBfIuQjfGbWQkw4lhLTD1DQ+HUuUzO7Lq YexXIjhbNwBzdwzHiCx4SieAyISYuYXY+zrla2jQ8CaeR/4F7ltwA6RUkz++dLDT/qlN EY+hcvSIQXDc13sN99Zs3gOPT/Oddi4LFxxf1r3oJHbn/qeTt3olUCqMUHHA7/ZlX4eK RfbuOqeARi95MpcFblY8JpS3Wz9tAg4eXdoXGmnQd/5vD5Oc/3xAcwFZIkyaGBMGohWs pnSuK6i8p5D98Yts2CXD8mYeacLzlbbJ1ZLc+UrB4HTzqHhEbHcVtWLdj+kiJ+k3WRfH 58uQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rk3-20020a170907214300b00992c195ac80si324017ejb.357.2023.07.20.00.52.27; Thu, 20 Jul 2023 00:52:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231769AbjGTHvA (ORCPT + 99 others); Thu, 20 Jul 2023 03:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbjGTHu5 (ORCPT ); Thu, 20 Jul 2023 03:50:57 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1BB12128; Thu, 20 Jul 2023 00:50:55 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 7C7756732D; Thu, 20 Jul 2023 09:50:50 +0200 (CEST) Date: Thu, 20 Jul 2023 09:50:50 +0200 From: Christoph Hellwig To: Nitesh Shetty Cc: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Keith Busch , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, bvanassche@acm.org, ming.lei@redhat.com, dlemoal@kernel.org, nitheshshetty@gmail.com, gost.dev@samsung.com, Vincent Fu , Anuj Gupta , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v13 3/9] block: add emulation for copy Message-ID: <20230720075050.GB5042@lst.de> References: <20230627183629.26571-1-nj.shetty@samsung.com> <20230627183629.26571-4-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230627183629.26571-4-nj.shetty@samsung.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 > +static void *blkdev_copy_alloc_buf(sector_t req_size, sector_t *alloc_size, > + gfp_t gfp_mask) > +{ > + int min_size = PAGE_SIZE; > + void *buf; > + > + while (req_size >= min_size) { > + buf = kvmalloc(req_size, gfp_mask); > + if (buf) { > + *alloc_size = req_size; > + return buf; > + } > + /* retry half the requested size */ > + req_size >>= 1; > + } > + > + return NULL; Is there any good reason for using vmalloc instead of a bunch of distcontiguous pages? > + ctx = kzalloc(sizeof(struct copy_ctx), gfp_mask); > + if (!ctx) > + goto err_ctx; I'd suspect it would be better to just allocte a single buffer and only have a single outstanding copy. That will reduce the bandwith you can theoretically get, but copies tend to be background operations anyway. It will reduce the required memory, and thus the chance for this operation to fail on a loaded system. It will also dramatically reduce the effect on memory managment. > + read_bio = bio_map_kern(in, buf, buf_len, gfp_mask); > + if (IS_ERR(read_bio)) > + goto err_read_bio; > + > + write_bio = bio_map_kern(out, buf, buf_len, gfp_mask); > + if (IS_ERR(write_bio)) > + goto err_write_bio; bio_map_kern is only for passthrough I/Os. You need to use a bio_add_page loop here. > index 336146798e56..f8c80940c7ad 100644 > --- a/include/linux/blk_types.h > +++ b/include/linux/blk_types.h > @@ -562,4 +562,9 @@ struct cio { > atomic_t refcount; > }; > > +struct copy_ctx { > + struct cio *cio; > + struct work_struct dispatch_work; > + struct bio *write_bio; > +}; This is misnamed as it's only used by the fallback code, and also should be private to blk-lib.c.