Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2212557imu; Sun, 18 Nov 2018 18:42:34 -0800 (PST) X-Google-Smtp-Source: AJdET5cdKCXeKGwiXOzMTwmiPeHwa9V64EIVSbB+Lor4MLQtuOvqK29gHJP+fMvILVF+iU6UD+8g X-Received: by 2002:a62:5793:: with SMTP id i19mr17056320pfj.49.1542595354627; Sun, 18 Nov 2018 18:42:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542595354; cv=none; d=google.com; s=arc-20160816; b=egHRX7SCSM1ZF//A808KPwLUjT2l3HsI/SyNkjl+Wm8oWcZaDjhMIbcuu14LKQbNrG fF/BEhctkR5jXBmjhW5UNt+xWQ7ScVpe+IHVeWnGJSZofa7B79otbMeb6kUDOZX/pIhV G0iUS9fo8kQpUFEGOhpIeoj+A84xmUX9Po9QWPde94T8WF8eqEiwjDM/zP1Z4yAZtoKy FMhXyXJscxrnwKXS1s/Mc2ocAw2IaZnYSCykIoNk7se/YeB3irbP2/aAO4I4nD3zswhZ 1cknKNXANgVSD/v0wQTT+GQ1LvqtWJxwponVhtSF4QRydTixNOPtwvs/mXzf6XgQiUbc AEyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gNwpFnsOIZ2wGpGAg2giE/TOV5mrysTALe6ljo/rN6w=; b=KW0X0ikcUi+Y57EoyJWIStGOlEnRfZEgFCX7xCh7vdlAaFtMEvaAx/GegoVWgkXCU/ qqEOr4Z/fMhW+TbgJZzat0HWcpKi5esSDinQ8ZcHKXP9SER1o5+/Al28Yl2fJ3DeMDgP zOIKypANYfReP+QE4D1rg6vNf/oqOK0WBwj11Udd0+EmW4bAxCXw3FQeEPRuR31s5Tke yhf2VgLwlm6gK5resfXvYmK3IiBYKftEKn963wbRK1Ukwq2sJBJU8OV7s9wb5yDPRUOD 0PThGjMGWb9sGKbDEC9BDfl9HLiMOpf635yXgHAI1wwxd/oIu3RAqXc0tN1l6NmbJmW6 WvvQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si36618724pgq.36.2018.11.18.18.42.19; Sun, 18 Nov 2018 18:42:34 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbeKSMr4 (ORCPT + 99 others); Mon, 19 Nov 2018 07:47:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbeKSMr4 (ORCPT ); Mon, 19 Nov 2018 07:47:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D76B3082A20; Mon, 19 Nov 2018 02:25:50 +0000 (UTC) Received: from ming.t460p (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0741177C0; Mon, 19 Nov 2018 02:25:30 +0000 (UTC) Date: Mon, 19 Nov 2018 10:25:26 +0800 From: Ming Lei To: Omar Sandoval Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V10 01/19] block: introduce multi-page page bvec helpers Message-ID: <20181119022525.GD10838@ming.t460p> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-2-ming.lei@redhat.com> <20181115182559.GA9348@vader> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115182559.GA9348@vader> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 19 Nov 2018 02:25:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 10:25:59AM -0800, Omar Sandoval wrote: > On Thu, Nov 15, 2018 at 04:52:48PM +0800, Ming Lei wrote: > > This patch introduces helpers of 'mp_bvec_iter_*' for multipage > > bvec support. > > > > The introduced helpers treate one bvec as real multi-page segment, > > which may include more than one pages. > > > > The existed helpers of bvec_iter_* are interfaces for supporting current > > bvec iterator which is thought as single-page by drivers, fs, dm and > > etc. These introduced helpers will build single-page bvec in flight, so > > this way won't break current bio/bvec users, which needn't any change. > > > > Cc: Dave Chinner > > Cc: Kent Overstreet > > Cc: Mike Snitzer > > Cc: dm-devel@redhat.com > > Cc: Alexander Viro > > Cc: linux-fsdevel@vger.kernel.org > > Cc: Shaohua Li > > Cc: linux-raid@vger.kernel.org > > Cc: linux-erofs@lists.ozlabs.org > > Cc: David Sterba > > Cc: linux-btrfs@vger.kernel.org > > Cc: Darrick J. Wong > > Cc: linux-xfs@vger.kernel.org > > Cc: Gao Xiang > > Cc: Christoph Hellwig > > Cc: Theodore Ts'o > > Cc: linux-ext4@vger.kernel.org > > Cc: Coly Li > > Cc: linux-bcache@vger.kernel.org > > Cc: Boaz Harrosh > > Cc: Bob Peterson > > Cc: cluster-devel@redhat.com > > Reviewed-by: Omar Sandoval > > But a couple of comments below. > > > Signed-off-by: Ming Lei > > --- > > include/linux/bvec.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++--- > > 1 file changed, 60 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/bvec.h b/include/linux/bvec.h > > index 02c73c6aa805..8ef904a50577 100644 > > --- a/include/linux/bvec.h > > +++ b/include/linux/bvec.h > > @@ -23,6 +23,44 @@ > > #include > > #include > > #include > > +#include > > + > > +/* > > + * What is multi-page bvecs? > > + * > > + * - bvecs stored in bio->bi_io_vec is always multi-page(mp) style > > + * > > + * - bvec(struct bio_vec) represents one physically contiguous I/O > > + * buffer, now the buffer may include more than one pages after > > + * multi-page(mp) bvec is supported, and all these pages represented > > + * by one bvec is physically contiguous. Before mp support, at most > > + * one page is included in one bvec, we call it single-page(sp) > > + * bvec. > > + * > > + * - .bv_page of the bvec represents the 1st page in the mp bvec > > + * > > + * - .bv_offset of the bvec represents offset of the buffer in the bvec > > + * > > + * The effect on the current drivers/filesystem/dm/bcache/...: > > + * > > + * - almost everyone supposes that one bvec only includes one single > > + * page, so we keep the sp interface not changed, for example, > > + * bio_for_each_segment() still returns bvec with single page > > + * > > + * - bio_for_each_segment*() will be changed to return single-page > > + * bvec too > > + * > > + * - during iterating, iterator variable(struct bvec_iter) is always > > + * updated in multipage bvec style and that means bvec_iter_advance() > > + * is kept not changed > > + * > > + * - returned(copied) single-page bvec is built in flight by bvec > > + * helpers from the stored multipage bvec > > + * > > + * - In case that some components(such as iov_iter) need to support > > + * multi-page bvec, we introduce new helpers(mp_bvec_iter_*) for > > + * them. > > + */ > > This comment sounds more like a commit message (i.e., how were things > before, and how are we changing them). In a couple of years when I read > this code, I probably won't care how it was changed, just how it works. > So I think a comment explaining the concepts of multi-page and > single-page bvecs is very useful, but please move all of the "foo was > changed" and "before mp support" type stuff to the commit message. OK. > > > /* > > * was unsigned short, but we might as well be ready for > 64kB I/O pages > > @@ -50,16 +88,35 @@ struct bvec_iter { > > */ > > #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) > > > > -#define bvec_iter_page(bvec, iter) \ > > +#define mp_bvec_iter_page(bvec, iter) \ > > (__bvec_iter_bvec((bvec), (iter))->bv_page) > > > > -#define bvec_iter_len(bvec, iter) \ > > +#define mp_bvec_iter_len(bvec, iter) \ > > min((iter).bi_size, \ > > __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) > > > > -#define bvec_iter_offset(bvec, iter) \ > > +#define mp_bvec_iter_offset(bvec, iter) \ > > (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) > > > > +#define mp_bvec_iter_page_idx(bvec, iter) \ > > + (mp_bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) > > + > > +/* > > + * of single-page(sp) segment. > > + * > > + * This helpers are for building sp bvec in flight. > > + */ > > +#define bvec_iter_offset(bvec, iter) \ > > + (mp_bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) > > + > > +#define bvec_iter_len(bvec, iter) \ > > + min_t(unsigned, mp_bvec_iter_len((bvec), (iter)), \ > > + (PAGE_SIZE - (bvec_iter_offset((bvec), (iter))))) > > The parentheses around (bvec_iter_offset((bvec), (iter))) and > (PAGE_SIZE - (bvec_iter_offset((bvec), (iter)))) are unnecessary > clutter. This looks easier to read to me: Good catch! Thanks, Ming