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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 160B3C7EE2F for ; Fri, 26 May 2023 08:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242781AbjEZIpB (ORCPT ); Fri, 26 May 2023 04:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242800AbjEZIok (ORCPT ); Fri, 26 May 2023 04:44:40 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D4911B3 for ; Fri, 26 May 2023 01:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685090625; 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=QXn9MWUk2FPbUN3jbknddRY9KLSzIVSi2VA++cjTuC1pSTGNTU6wiIvEmFmOzFz/wKl/2k PF/3Z/76NEB5E9/heGq3r5261iOCDKsBI47a0BLzPHZ+JZeCpwhaLnC+8umFunhknviHxQ LeDUUKyQjO2xApm7khqkC/6gnN9pc3U= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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