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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F3E5C7EE23 for ; Fri, 26 May 2023 08:43:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B73B6B0072; Fri, 26 May 2023 04:43:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83F826B0074; Fri, 26 May 2023 04:43:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E11E900002; Fri, 26 May 2023 04:43:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5A5986B0072 for ; Fri, 26 May 2023 04:43:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 25DBAA0165 for ; Fri, 26 May 2023 08:43:47 +0000 (UTC) X-FDA: 80831768094.14.0821E3F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 2E0B640008 for ; Fri, 26 May 2023 08:43:45 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b59M1NGd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685090625; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rO5u1LT/DkSYeKOoJRR+C9ZUgArTLbgJfPbLRFgEFXo=; b=TrQ702sc6P0tKHiqokZg/oj+LRSiLU2WPCpd2tMpY2HrT02vzhkUgAVK5KrxZAYmwCFaQE iHucjbOVZFGRpgvTv9jwSFI9Bw67C2iUQEq/YHH9bGGdCWeTZMRJaBopiiDy5/KWlO9iwS iOSVuwrs+OuFX6yDxIzMOLVBhWOoIAc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b59M1NGd; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685090625; a=rsa-sha256; cv=none; b=bn8TbW3GBBe0/Fe6/kCL/Zd9oWDKWOxOl0b6aWzAKilhpeiV+hG6yCJnCW3jqrvNuXArVo asqWRyHboJX1MCof5CJp6943T/518dm52jNLRFdugTQrIyYo5U4kbVzxm1nK3QtZ1JwL4U ABwlVVwm+Sbk6kE6ZTdq/0c6P5Psh8o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685090624; 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=rO5u1LT/DkSYeKOoJRR+C9ZUgArTLbgJfPbLRFgEFXo=; b=b59M1NGd1hODhNSLixFFto2feuyHJ0m9Tj0UJSZbQwLV+3rvuTGPc2bgCo7HJHSUyoz/t9 m4VBz8w+FLrY1FP1uzwy7nqRnDdaUhWSFeVSN3JzqVuxfuFZnNdKL6WiwPoVpnr3OyyySg 13owpzdlE+lHFyxyO04eyQXhdYhPKGw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-533-R5eE5ngcPYCRxtk71bmDRg-1; Fri, 26 May 2023 04:43:40 -0400 X-MC-Unique: R5eE5ngcPYCRxtk71bmDRg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB26D8007D9; Fri, 26 May 2023 08:43:39 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07FA1121314; Fri, 26 May 2023 08:43:36 +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: <89c7f535-8fc5-4480-845f-de94f335d332@lucifer.local> References: <89c7f535-8fc5-4480-845f-de94f335d332@lucifer.local> <20230525223953.225496-1-dhowells@redhat.com> <20230525223953.225496-2-dhowells@redhat.com> To: Lorenzo Stoakes Cc: dhowells@redhat.com, Christoph Hellwig , David Hildenbrand , Jens Axboe , Al Viro , Matthew Wilcox , Jan Kara , Jeff Layton , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton Subject: Re: [RFC PATCH v2 1/3] mm: Don't pin ZERO_PAGE in pin_user_pages() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <520729.1685090615.1@warthog.procyon.org.uk> Date: Fri, 26 May 2023 09:43:35 +0100 Message-ID: <520730.1685090615@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: 2E0B640008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: cwy9csayzd9u8fos9gmkamdnqsrao54b X-HE-Tag: 1685090625-277056 X-HE-Meta: U2FsdGVkX18H8P+9BeWdWSqddDJjg4Rq17ioOQr3CQrAsCoA2/g/i9tyIl+SA1qqon4fUAUo7FKlYFtMkcM5bBqZ0BD/jLsG8TY9r7iOa9sU2RJPvItNswFe/ZXxdHKkiBzi+fbtYULOEX+oiQFPfi82LHd+KPUbFu6STB74xWTLjrtddAIUr4drO0bG/pgDOHVXEYnCpbU4AATm/u69F1q/Sk89dDW0UK++jpR0MQerRe5wlJSInNa/dGWDkW/YO2F8/TWHXJEIpD151yA+EyKRSq3w0iqLu01vEzwhQ8PWDI3/fCjTKLTDg6KgB+AsXyFCRY8Kez4r+jRX6+Hyhl5ecEMNqogrqZK79wSZlhAthMTguZMYHs93uR5SqeNWnoQqSA8jp9LRzOOZn3nCQkYyMgMksVm4noOt8jwu+vzKVsCZmiN1AyEBPbouOCVIX9fEQA1Uw5acC9gVQzARhoucViprNzjv8f+ZwSvIbl1GrD10BaXu+umw8HrSCDhtqg4KmRdlB3xeTQtVxW+WjQcAMo7UpY/jiEVN3w+ZWcWZa9v+/6QNMIejeVDYwmyuKnjFFtYSUOkamWpq3tYATFgKbxVdPpBE26nht2NUIiMmVSwB8UdT4t7ZC4nqEKDnhpIiNhug1lh6umF8aa22JhImZBeT/0H522TYxldypehnSqEBNqroYIzq243BETrKrgcsuGV8ikD8Bu8AZ/IrUr0C68TwneUy5OoEXqmqFYOT2CoZc9trbTNjubG+R6IRSzxTkgiNS4KiKZ7+EN18FtMNUYhzI61+QI8ARodVTxF1Yn4IKMO1PO0ihDrfTQD+XoI2oLsGgsf9hb4/5KDEcr1rg6rZdPtRGx9VY94oI/Sx5liR9GPh5h7rsiI9562eJJLyM/PnydJ04tmcYZ6Zfnpm7T/A3DfSGT31kcFqR9r3sUWRY1o78z31XdbJhF/ezK31cAd64i/oASbD+Ot hRMkxwcG tj25MbqkhY2XcJMApUQ2MXIuPQB34WCTsKxP+GNgaXuVeoIBSdlYneD97+Z8zq2lsbkxX353aa9P95LvovePc/ebhO1vhDkPx78NI98G+ueC+gyp6SlWoH0PyeIBIy3hIn0tHq3e/k4hvvpq8cJ1MmAjADk88ca10mH0/ILKKQRPIl0pY8o9/+syB88Z6cFl0TV1KWRJjoUWqCXAsn10CZwMLkyvoH26kmTjU 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: Lorenzo Stoakes wrote: > I guess we're not quite as concerned about FOLL_GET because FOLL_GET should > be ephemeral and FOLL_PIN (horrifically) adds GUP_PIN_COUNTING_BIAS each > time? It's not that - it's that iov_iter_get_pages*() is a lot more commonly used at the moment, and we'd have to find *all* the places that things using that hand refs around. iov_iter_extract_pages(), on the other hand, is only used in two places with these patches and the pins are always released with unpin_user_page*() so it's a lot easier to audit. I could modify put_page(), folio_put(), etc. to ignore the zero pages, but that might have a larger performance impact. > > + if (is_zero_page(page)) > > + return page_folio(page); > > + > > This will capture huge page cases too which have folio->_pincount and thus > don't suffer the GUP_PIN_COUNTING_BIAS issue, however it is equally logical > to simply skip these when pinning. I'm not sure I understand. The zero page(s) is/are single-page folios? > This does make me think that we should just skip pinning for FOLL_GET cases > too - there's literally no sane reason we should be pinning zero pages in > any case (unless I'm missing something!) As mentioned above, there's a code auditing issue and a potential performance issue, depending on how it's done. > Another nitty thing that I noticed is, in is_longterm_pinnable_page():- > > /* The zero page may always be pinned */ > if (is_zero_pfn(page_to_pfn(page))) > return true; > > Which, strictly speaking I suppose we are 'pinning' it or rather allowing > the pin to succeed without actually pinning, but to be super pedantic > perhaps it's worth updating this comment too. Yeah. It is "pinnable" but no pin will actually be added. David