From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4E88C32771 for ; Wed, 22 Jan 2020 21:42:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9FA0D2465A for ; Wed, 22 Jan 2020 21:42:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VVI7R0cF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FA0D2465A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 437666B0006; Wed, 22 Jan 2020 16:42:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 40DF86B0007; Wed, 22 Jan 2020 16:42:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FDB66B0008; Wed, 22 Jan 2020 16:42:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 170CE6B0006 for ; Wed, 22 Jan 2020 16:42:30 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id C4E9D181AC9CC for ; Wed, 22 Jan 2020 21:42:29 +0000 (UTC) X-FDA: 76406594418.12.drum10_32d92357f3a51 X-HE-Tag: drum10_32d92357f3a51 X-Filterd-Recvd-Size: 5571 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Jan 2020 21:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579729348; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9sq0QraWPDpkXsBf/Rma/gL22oexCpF9Izn7HjkCvoE=; b=VVI7R0cF27ZGgs5GgGLQ2VwnIYgOWqumzsRWAOht2oz5WF81F9frUVNvRXNXJ11O0+BIMV DGZYOTMHc/8B/iYVymyRWcv+b8dXXvSPW5L7+izikzCaV99ajkGODkE8jlWsi4A7NwJFYb ENQqp1bO+uInaheLTbTXNNoMeYNhH8Y= 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-25-6Rm_4Rr4NsuN0Tp4M90w4g-1; Wed, 22 Jan 2020 16:42:26 -0500 X-MC-Unique: 6Rm_4Rr4NsuN0Tp4M90w4g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3694918C8C04; Wed, 22 Jan 2020 21:42:25 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-49.rdu2.redhat.com [10.10.120.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EE9F1001B11; Wed, 22 Jan 2020 21:42:23 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20200122193306.GB4675@bombadil.infradead.org> References: <20200122193306.GB4675@bombadil.infradead.org> <3577430.1579705075@warthog.procyon.org.uk> To: Matthew Wilcox Cc: dhowells@redhat.com, Alexander Viro , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] iov_iter: Add ITER_MAPPING MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3695538.1579729342.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 22 Jan 2020 21:42:22 +0000 Message-ID: <3695539.1579729342@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Matthew Wilcox wrote: > = > > + rcu_read_lock(); \ > > + for (page =3D xas_load(&xas); page; page =3D xas_next(&xas)) { \ > > + if (xas_retry(&xas, page)) \ > > + continue; \ > > + if (xa_is_value(page)) \ > > + break; \ > = > Do you also want to check for !page? That would be a bug in the caller. Well, I stated that one of the preconditions for using this was that the caller made sure that segment of the mapping was fully populated, so the c= heck ought to be unnecessary. > > + if (PageCompound(page)) \ > > + break; \ > = > It's perfectly legal to have compound pages in the page cache. Call > find_subpage(page, xas.xa_index) unconditionally. Yeah, I'm just not sure how to deal with them. > > + if (page_to_pgoff(page) !=3D xas.xa_index) \ > > + break; \ > = > ... and you can ditch this if the pages are pinned as find_subpage() > will bug in this case. Ok. > > + __v.bv_page =3D page; \ > > + offset =3D (i->mapping_start + skip) & ~PAGE_MASK; \ > > + seg =3D PAGE_SIZE - offset; \ > > + __v.bv_offset =3D offset; \ > > + __v.bv_len =3D min(n, seg); \ > > + (void)(STEP); \ > > + n -=3D __v.bv_len; \ > > + skip +=3D __v.bv_len; \ > = > Do we want STEP to be called with PAGE_SIZE chunks, or if they have a > THP, can we have it called with larger than a PAGE_SIZE chunk? It would mean that the STEP function would have to handle multiple pages, = some part(s) of which might need to be ignored and wouldn't be able to simply c= all memcpy_from/to_page(). > > +#define iterate_all_kinds(i, n, v, I, B, K, M) { \ > > if (likely(n)) { \ > > size_t skip =3D i->iov_offset; \ > > if (unlikely(i->type & ITER_BVEC)) { \ > > @@ -86,6 +119,9 @@ > > struct kvec v; \ > > iterate_kvec(i, n, v, kvec, skip, (K)) \ > > } else if (unlikely(i->type & ITER_DISCARD)) { \ > > + } else if (unlikely(i->type & ITER_MAPPING)) { \ > > + struct bio_vec v; \ > > + iterate_mapping(i, n, v, skip, (M)); \ > = > bio_vec? Yes - as a strictly temporary thing. I need a struct contains a page poin= ter, a start and a length, and constructing a struct bio_vec on the fly here al= lows the caller to potentially share code. For example: size_t _copy_from_iter_nocache(void *addr, size_t bytes, struct iov_it= er *i) { char *to =3D addr; if (unlikely(iov_iter_is_pipe(i))) { WARN_ON(1); return 0; } iterate_and_advance(i, bytes, v, __copy_from_user_inatomic_nocache((to +=3D v.iov_len) - v.iov_len, v.iov_base, v.iov_len), memcpy_from_page((to +=3D v.bv_len) - v.bv_len, v.bv_page, v.bv_offset, v.bv_len), ITER_BVEC ^^^^ memcpy((to +=3D v.iov_len) - v.iov_len, v.iov_base, v.iov_len), memcpy_from_page((to +=3D v.bv_len) - v.bv_len, v.bv_page, v.bv_offset, v.bv_len) ITER_MAPPING ^^^^ ) return bytes; } David