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=-6.0 required=3.0 tests=BAYES_00,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 DDC90C43460 for ; Mon, 26 Apr 2021 19:23:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6970A611ED for ; Mon, 26 Apr 2021 19:23:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6970A611ED 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 D44166B0070; Mon, 26 Apr 2021 15:23:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF47D6B0071; Mon, 26 Apr 2021 15:23:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6E836B0072; Mon, 26 Apr 2021 15:23:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 8DFFC6B0070 for ; Mon, 26 Apr 2021 15:23:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 49F3F8249980 for ; Mon, 26 Apr 2021 19:23:57 +0000 (UTC) X-FDA: 78075493314.03.AF98200 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 9BB442000267 for ; Mon, 26 Apr 2021 19:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619465036; 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=4SqDWTwGLz0yG83bRGbUR1MGHDhF5H6AJtqMldOHVmY=; b=LIPJxIL6mPG49c8UviGhh5RGcznz8kPm7uGS0QQKM3iVSEe5+RemkEwthRkmPBgps2wJ5u LId7j4lsf5PNr8QQZ5H9u8XC83MAOh0fv+Iyp8ovtYql34uGNGlMDET4ZDY7gjGVdPhC6b bZ8jOJR7CSm6S1TTHuYSoaieHUCcGa8= 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-166-BAwWcPM1PsiTJg_KTP0EFA-1; Mon, 26 Apr 2021 15:23:54 -0400 X-MC-Unique: BAwWcPM1PsiTJg_KTP0EFA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBE0418A08DD; Mon, 26 Apr 2021 19:23:52 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-124.rdu2.redhat.com [10.10.112.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 363631A353; Mon, 26 Apr 2021 19:23:32 +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: References: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> <161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk> To: Al Viro Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, Dave Wysochanski , Marc Dionne , "Matthew Wilcox (Oracle)" , Christoph Hellwig , linux-mm@kvack.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 01/31] iov_iter: Add ITER_XARRAY MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3651950.1619465011.1@warthog.procyon.org.uk> Date: Mon, 26 Apr 2021 20:23:31 +0100 Message-ID: <3651951.1619465011@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9BB442000267 X-Stat-Signature: i1ckesdjzjudxa9k1h9uyfi9hibszzto Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619465038-561501 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: Al Viro wrote: > On Fri, Apr 23, 2021 at 02:28:01PM +0100, David Howells wrote: > > -#define iterate_all_kinds(i, n, v, I, B, K) { \ > > +#define iterate_xarray(i, n, __v, skip, STEP) { \ > > + struct page *head = NULL; \ > > + size_t wanted = n, seg, offset; \ > > + loff_t start = i->xarray_start + skip; \ > > + pgoff_t index = start >> PAGE_SHIFT; \ > > + int j; \ > > + \ > > + XA_STATE(xas, i->xarray, index); \ > > + \ > > + rcu_read_lock(); \ > > + xas_for_each(&xas, head, ULONG_MAX) { \ > > + if (xas_retry(&xas, head)) \ > > + continue; \ > > OK, now I'm really confused; what's to guarantee that restart will not have > you hit the same entry more than once? STEP might be e.g. > > memcpy_to_page(v.bv_page, v.bv_offset, > (from += v.bv_len) - v.bv_len, v.bv_len) > > which is clearly not idempotent - from gets incremented, after all. > What am I missing here? I really need to defer this question to Willy, but as I understand it, xas_retry() only restarts the current iteration. Referring to the comment on xas_reset(): * Resets the error or walk state of the @xas so future walks of the * array will start from the root. Use this if you have dropped the * xarray lock and want to reuse the xa_state. I think that the walk returns to the bottom of the tree and whilst xarray presents an interface that appears to be a contiguous array, it's actually a tree internally - and 'root' is the root of the tree, not the head of the array. Basically, I think it throws away its cached iteration state - which might have been modified - and rewalks the tree to get back to the same index. David