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 AE536C433EF for ; Thu, 3 Feb 2022 15:01:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 047DA8D0152; Thu, 3 Feb 2022 10:01:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F39A98D0129; Thu, 3 Feb 2022 10:01:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDACE8D0152; Thu, 3 Feb 2022 10:01:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id CDB528D0129 for ; Thu, 3 Feb 2022 10:01:27 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5C5559A278 for ; Thu, 3 Feb 2022 15:01:27 +0000 (UTC) X-FDA: 79101782214.27.5098860 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) by imf10.hostedemail.com (Postfix) with ESMTP id B8724C0014 for ; Thu, 3 Feb 2022 15:01:26 +0000 (UTC) Received: by mail-qv1-f48.google.com with SMTP id e17so2755191qvb.8 for ; Thu, 03 Feb 2022 07:01:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=rS/LGN0/YOa0OAM/80MdNEEJBLBrhqAWTkIJvDgXmcQ=; b=J5/OFB7pkOvdYeAJamQlMDZOqV7vskQPo1YiNSmzwJSTfJavvTf4/LPfcJQyaRXrad 9I3w3oH1O24svZm24QtX8bPN7QIUR+tQ6ILQVb149MO4tajjQTHtGN4Y3PgPt65S1JbG yUijflAg8s3MjaR8endHPJwnR9VD3RKHsp9yXvxpki/ER4NlbaFXDWqcWiZUngGnITpw zMKMzb9yH4Xj/9R/IeavEmOOrGrsD3Rg2cDlmWhVe6deN6T78lZJ/4WjWfv0leA1VDw0 /EkEjUxmffhHObJtWX6L3GUMwMqx6amoRcHfls/rswFInEA54A1XxhDtgYraICFwPPvA pACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rS/LGN0/YOa0OAM/80MdNEEJBLBrhqAWTkIJvDgXmcQ=; b=FYa9EoEb2ejjcERw2AW0wjnWAi7+7OahMCG4MoKTWhosNIOiERPJlLRwM5kA9IpC/V eXD023qRTM1V1bod0+cU4yZoafTS+dROR0AYGDU1d4ysof+5kZsh3wvGM1mXJhcir2LT 6CGSgV3VQi3i6t9BbzkPc2S8UP3Kic/k/r5ubKuOSP8cooPkpEuiLv783fDzKL2dXZoJ izlzH/SBIsJO3SYfd8ewcUfcAxEWA09lredXL6N+eOJiUCoiIY28tjmIzsrJqgdICGaK wc1mdz3VUiH5uBYvQvDSWfP5NZ7oJ+o03qJEVJNADry8aTPNyuQAzGbfVZEJ4snGUdns zLIw== X-Gm-Message-State: AOAM532jFg/gGnORcdsBuCTauYaTHxcusaUaAJqUu/dV5ueE1LMdg6Lw bXMlwIT7GzjPM1hYTIvradklxw== X-Google-Smtp-Source: ABdhPJwuj0w6gseoaq6YUerR8CwXsppvPjOuZlzTsVoRGzDgRs2E8JieoB+YdD5CT+WOl43dslA2mw== X-Received: by 2002:a05:6214:21a8:: with SMTP id t8mr31297193qvc.6.1643900485579; Thu, 03 Feb 2022 07:01:25 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id c78sm13372215qkg.42.2022.02.03.07.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 07:01:24 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1nFdbv-00BFJx-NQ; Thu, 03 Feb 2022 11:01:23 -0400 Date: Thu, 3 Feb 2022 11:01:23 -0400 From: Jason Gunthorpe To: Jan Kara Cc: John Hubbard , Andrew Morton , Peter Xu , David Hildenbrand , Lukas Bulwahn , Claudio Imbrenda , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , LKML , linux-mm@kvack.org Subject: Re: [PATCH v3 2/4] mm/gup: clean up follow_pfn_pte() slightly Message-ID: <20220203150123.GB8034@ziepe.ca> References: <20220203093232.572380-1-jhubbard@nvidia.com> <20220203093232.572380-3-jhubbard@nvidia.com> <20220203135352.55f35pztwmdx2rhk@quack3.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220203135352.55f35pztwmdx2rhk@quack3.lan> X-Rspam-User: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B8724C0014 X-Stat-Signature: j35wasshiaprpg19ngyt8x6skfdb6r7t Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b="J5/OFB7p"; spf=pass (imf10.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.219.48 as permitted sender) smtp.mailfrom=jgg@ziepe.ca; dmarc=none X-HE-Tag: 1643900486-46738 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: On Thu, Feb 03, 2022 at 02:53:52PM +0100, Jan Kara wrote: > On Thu 03-02-22 01:32:30, John Hubbard wrote: > > Regardless of any FOLL_* flags, get_user_pages() and its variants should > > handle PFN-only entries by stopping early, if the caller expected > > **pages to be filled in. > > > > This makes for a more reliable API, as compared to the previous approach > > of skipping over such entries (and thus leaving them silently > > unwritten). > > > > Cc: Peter Xu > > Cc: Lukas Bulwahn > > Suggested-by: Jason Gunthorpe > > Reviewed-by: Jason Gunthorpe > > Signed-off-by: John Hubbard > > mm/gup.c | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index 65575ae3602f..cad3f28492e3 100644 > > +++ b/mm/gup.c > > @@ -439,10 +439,6 @@ static struct page *no_page_table(struct vm_area_struct *vma, > > static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, > > pte_t *pte, unsigned int flags) > > { > > - /* No page to get reference */ > > - if (flags & (FOLL_GET | FOLL_PIN)) > > - return -EFAULT; > > - > > if (flags & FOLL_TOUCH) { > > pte_t entry = *pte; > > > > This will also modify the error code returned from follow_page(). Er, but isn't that the whole point of this entire design? It is what the commit that added it says: commit 1027e4436b6a5c413c95d95e50d0f26348a602ac Author: Kirill A. Shutemov Date: Fri Sep 4 15:47:55 2015 -0700 mm: make GUP handle pfn mapping unless FOLL_GET is requested With DAX, pfn mapping becoming more common. The patch adjusts GUP code to cover pfn mapping for cases when we don't need struct page to proceed. To make it possible, let's change follow_page() code to return -EEXIST error code if proper page table entry exists, but no corresponding struct page. __get_user_page() would ignore the error code and move to the next page frame. The immediate effect of the change is working MAP_POPULATE and mlock() on DAX mappings. > A quick audit shows that at least the user in mm/migrate.c will > propagate this error code to userspace and I'm not sure the change > in error code will not break something... EEXIST is a bit strange > error code to get from move_pages(2). That makes sense, maybe move_pages should squash the return codes to EEXIST? Jason