Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2142092rwd; Fri, 26 May 2023 02:16:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5C+PF+p2pIbfWolLwZXXsmfaFagYk3xbzldjFD34ZtxheULhiF6GyVOrYBGBanpjZYRvF3 X-Received: by 2002:a05:6a20:1601:b0:10e:e813:46ed with SMTP id l1-20020a056a20160100b0010ee81346edmr1515449pzj.43.1685092598184; Fri, 26 May 2023 02:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685092598; cv=none; d=google.com; s=arc-20160816; b=c+ImdCpo/+tE6Jy0FvNEg60h9ifYzXA2kEGNbBG3rnBkkU5M8/ozRgD8+0mh0w2YeA MrkRu0vH3rkyGNxw3Km9mJailja5QGwcL7+XciRsPT1g8NoTk5QKWmgj4WaGty026wgs juZ30sZXdY6hajsczFYLdpxVlP3y572w1g7Rx5dRJdUhvsR2B+rfDzcYui3psS3D4lJW 0fDEqXCTO6/wze6vo1x5H4Jw+BDP//aVY4r3c0vRGA5xBXO5tNdlTEA8SsKwC7u9HTVk NZvl1kj4PzJuVDYN7Nu0uWtWXczVPHYu7NkxAx5qw1viNurZbQrKVFSD4i9Tv9FSDz81 QEBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=rO5u1LT/DkSYeKOoJRR+C9ZUgArTLbgJfPbLRFgEFXo=; b=C3ehh2brc7MtlLSizRpYu75FPbVKR3+5HR9/uu5/dE5mxC74/CnHRcQo5PvFG8riAi CFhB5ptijTU9vS2rGM+EhTL+WsD2RMmzQOsz6do0xkvUkNh3yGsQmexSIfYI/n1XqAv1 F6/ZF9JdYDGxHampwoP8bqSDo0QdPCbGPYyVFxznn1ErYHAm1DYYqNI0wrdwKj9KBnN2 mfvug/PjVHcfZ5BxYflIEsc3xnqYlD0TxWRdPA8xI6GtQWq+zhR1dSrtva00/fal4R4Z yT0uH4jBeMTpo391EOV6e0bfvXc0aDKbUtSWhgOZoqrOUFL/xq7w1QrxnSDl9q2ZxpEq iqeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QXn9MWUk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w67-20020a626246000000b0063b7acc199bsi737835pfb.65.2023.05.26.02.16.22; Fri, 26 May 2023 02:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QXn9MWUk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242761AbjEZIpA (ORCPT + 99 others); Fri, 26 May 2023 04:45:00 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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