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 C5468C3F68F for ; Fri, 24 Jan 2020 14:59:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B2C22071A for ; Fri, 24 Jan 2020 14:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PHq9XK6A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B2C22071A 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 1FBEA6B0005; Fri, 24 Jan 2020 09:59:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 187006B0006; Fri, 24 Jan 2020 09:59:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 027366B0007; Fri, 24 Jan 2020 09:59:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id DDB7A6B0005 for ; Fri, 24 Jan 2020 09:59:02 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 9340D180AD802 for ; Fri, 24 Jan 2020 14:59:02 +0000 (UTC) X-FDA: 76412835324.20.veil08_89125ca5cfa2f X-HE-Tag: veil08_89125ca5cfa2f X-Filterd-Recvd-Size: 3844 Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Jan 2020 14:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579877941; 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=BWoZ+zBogNKio10gnvI0VlupcEo0YcGdSxX1SnP4a38=; b=PHq9XK6AM8UwFKEvAg3ed2x61aMVG9IJxSrVJkK4/9x3YRc59XcpEw7PkEA1G0Vk+H+ArZ NR4cB3f9LP0Ssrg/rzyGiPBKz9ICo3fZeq0mN/Hu3h8eTBYqFVdq/n1ZUohMGh3BC7jqBb /DZYXMGZvebZD/djqcw0volzTsRVYPs= 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-22-hsJKDylHOVSmGyg0OUnwfA-1; Fri, 24 Jan 2020 09:58:53 -0500 X-MC-Unique: hsJKDylHOVSmGyg0OUnwfA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C268DBE8; Fri, 24 Jan 2020 14:58:41 +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 932AF867E4; Fri, 24 Jan 2020 14:58:38 +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: <20200124112109.GK4675@bombadil.infradead.org> References: <20200124112109.GK4675@bombadil.infradead.org> <20200122193306.GB4675@bombadil.infradead.org> <3577430.1579705075@warthog.procyon.org.uk> <3785795.1579777499@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: <911589.1579877917.1@warthog.procyon.org.uk> Date: Fri, 24 Jan 2020 14:58:37 +0000 Message-ID: <911590.1579877917@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: Okay, so this then? #define iterate_mapping(i, n, __v, skip, STEP) { \ struct page *page; \ size_t wanted = n, seg, offset; \ loff_t start = i->mapping_start + skip; \ pgoff_t index = start >> PAGE_SHIFT; \ \ XA_STATE(xas, &i->mapping->i_pages, index); \ \ rcu_read_lock(); \ for (page = xas_load(&xas); page; page = xas_next(&xas)) { \ if (xas_retry(&xas, page)) \ continue; \ if (WARN_ON(xa_is_value(page))) \ break; \ if (WARN_ON(PageHuge(page))) \ break; \ __v.bv_page = find_subpage(page, xas.xa_index); \ offset = (i->mapping_start + skip) & ~PAGE_MASK; \ seg = PAGE_SIZE - offset; \ __v.bv_offset = offset; \ __v.bv_len = min(n, seg); \ (void)(STEP); \ n -= __v.bv_len; \ skip += __v.bv_len; \ if (n == 0) \ break; \ } \ rcu_read_unlock(); \ n = wanted - n; \ } > We could also have an ITER_XARRAY which you just pass &mapping->i_pages > to. I don't think you use any other part of the mapping, so that would > be a more generic version that is equally efficient. I could give that a go. Out of interest, are there any other users of xarray that might use it that don't have a mapping handy? David