Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp533715rwd; Wed, 31 May 2023 01:40:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wbJsVLiPptrBD2HGM3Gbyeqivu8JZFa9+4jy2U+nFQfCYhhkfS+3R9uf7ZegMbDoX9nfD X-Received: by 2002:a05:6870:d4d6:b0:18e:2b7e:a844 with SMTP id l22-20020a056870d4d600b0018e2b7ea844mr3111047oai.21.1685522446380; Wed, 31 May 2023 01:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685522446; cv=none; d=google.com; s=arc-20160816; b=qP8l74DgKOdP8esCZ6vOeGds9p/OoTcqAB6S+ufsyDFXixpWFS8fn/CFGDlHejR3p9 /hVFBiQYg1wxP52tet0Su4ayVkF9BmyViT1TKboGmX4/u4Pe1DZhyR/ZCW3TnNB6xhDg GNqsNJG6UHp8O4ytL9mISu5fx6Zt428IAUdIueAF5D9cIRNrUFJKQV9LLN0wD37WFlb5 DJcCbaKazglsoY12Rgd+nWb19upHRsbTMA97wSClH8UoOtDsAyF5ND4h5UcNNoaxXUxr 0nq5Fpd9aLSV8MqkZtx5FFCoOW6Hsdixc8ID2pu+E1JK+iAoqcJ4ydvU/c+eZYVn5siy z2Hg== 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-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=D2ZwdaLGqkNgpQd/gtgsXYogAn46nzSogOGGTIXtoVA=; b=M3N+s6DRxaJjqxFw/W1Q6Dv08TrwVCGWfHmHn6eZKWkk6THUp85L+pY5co9u5uNzdc /M+RnMJp5A2y0xtAuOWsjz97HKAqIC+2nytCqalCQlAD3zQYeu14UsPVoHJI9xFnCbHS JuoOytRD6v6S5obDSCxsPID3BM26Bz7qT1wo/wpF2CYPTGj5sQohgqV2XZYAIvO+MErL 9d5AYBIwIeeGquujdHBHcDF5gUstjAz6BGztgmfvK2VqPZ7ubq1KgqeYy94cctL6hRIF oEd2twU1zmatjgoYDXW15g6hAyEpI6vLGTHOnhm0Qrl/k95gU95X3NjwH8GpnXc8Zzc5 i+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HkNBGHhY; 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 x14-20020a63170e000000b0053476581befsi586862pgl.328.2023.05.31.01.40.32; Wed, 31 May 2023 01:40:46 -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=HkNBGHhY; 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 S234742AbjEaIhQ (ORCPT + 99 others); Wed, 31 May 2023 04:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234693AbjEaIhL (ORCPT ); Wed, 31 May 2023 04:37:11 -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 5E428185 for ; Wed, 31 May 2023 01:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685522162; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D2ZwdaLGqkNgpQd/gtgsXYogAn46nzSogOGGTIXtoVA=; b=HkNBGHhYAPjS8y/E37NU2RmMrgffeRY/Ztcy27DJMQGyh2VBAuw2BXC52Nd29EaO2TO1Dj /kkdt6iYtSry/7dS8J2DMx5wF2fLei2UA8MiaZ5AzVwxQHFWK+33UbX9Fc5oJnKp3XHWTc jCskUYdmN1stRJiqINvuCURn+weKObc= 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-477-akBoGxAJNLKPo3Ap7wG4_g-1; Wed, 31 May 2023 04:35:59 -0400 X-MC-Unique: akBoGxAJNLKPo3Ap7wG4_g-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 0837B800159; Wed, 31 May 2023 08:35:58 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32053112132C; Wed, 31 May 2023 08:35:53 +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: <20230526214142.958751-1-dhowells@redhat.com> <20230526214142.958751-2-dhowells@redhat.com> To: David Hildenbrand Cc: dhowells@redhat.com, Christoph Hellwig , Lorenzo Stoakes , 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: [PATCH v4 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: <510964.1685522152.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 31 May 2023 09:35:52 +0100 Message-ID: <510965.1685522152@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.3 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 David Hildenbrand wrote: > > Make pin_user_pages*() leave a ZERO_PAGE unpinned if it extracts a poi= nter > > to it from the page tables and make unpin_user_page*() correspondingly > > ignore a ZERO_PAGE when unpinning. We don't want to risk overrunning = a > > zero page's refcount as we're only allowed ~2 million pins on it - > > something that userspace can conceivably trigger. > = > 2 millions pins (FOLL_PIN, which increments the refcount by 1024) or 2 m= illion > references ? Definitely pins. It's tricky because we've been using "pinned" to mean he= ld by a refcount or held by a flag too. 2 million pins on the zero page is in the realms of possibility. It only takes 32768 64-page DIO writes. > > @@ -3079,6 +3096,9 @@ EXPORT_SYMBOL_GPL(get_user_pages_fast); > > * > > * FOLL_PIN means that the pages must be released via unpin_user_pag= e(). Please > > * see Documentation/core-api/pin_user_pages.rst for further details= . > > + * > > + * Note that if a zero_page is amongst the returned pages, it will no= t have > > + * pins in it and unpin_user_page() will not remove pins from it. > > */ > = > "it will not have pins in it" sounds fairly weird to a non-native speake= r. Oh, I know. The problem is that "pin" is now really ambiguous. Can we ch= ange "FOLL_PIN" to "FOLL_NAIL"? Or maybe "FOLL_SCREW" - your pages are screwed= if you use DIO and fork at the same time. > "Note that the refcount of any zero_pages returned among the pinned page= s will > not be incremented, and unpin_user_page() will similarly not decrement i= t." That's not really right (although it happens to be true), because we're talking primarily about the pin counter, not the refcount - and they may b= e separate. David