Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp895281pxb; Tue, 1 Feb 2022 12:39:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzB5k+sIOfQZi2OaGk84lKBYOYdt+S/vJhYq5AvcZOS/hWrqARYwcWbAcObnq2S63RoKQ6W X-Received: by 2002:a17:90a:fe88:: with SMTP id co8mr4380403pjb.11.1643747977642; Tue, 01 Feb 2022 12:39:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643747977; cv=none; d=google.com; s=arc-20160816; b=L53L9NXUhI4R4sXowyBSK79l+gQJxC/QiPgKg9KmRMt3zZltO7pIC6inwmghAwJPa1 96nfa9xFEfazWAcGQVsiXQWqcLJ2ao0R+uH013nP5qbFEOEpBmJuQtmYw50hRiDawVZn qHgl0pvrjozlY6/GddE2gMdQtwUrl1j6j8EsyQGIMeU2k5oC7ETy9Y1D0g/K7R3WetsE 1Yz+DvaA5keNW98IBhd7jc2eBA7jcv39lA0+DsLBfhzgZZ8jI2nHrAJw09OwhDoPHX7i yelzJxWKoio3xwKhYvhhC0nC8+LGTXKpVP13w3KLH199SVwCd2xtgj7+Ux7G53pt/MS1 MZ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PEer8tHTGOMBB45BNBliWIb1NwPck3iboeLwpq12AUQ=; b=mRJx2VKocFhivh0LaY6eRTpdCamgZirekB+odCEG80XgmYRahD668KIvLnr1pyIFxR aW/SDA+zJo2FIE4ZArxK9qWwB2ldSa0X9FbhTNWP0t/wej/8rDhBeYSlZIS7aRju+bOI AMFqWEJbKpZsuy8JvRFznB54kML3J5o1qxjjZGTOo1usuHrRNEYOgNFHdY48gnfOvLXh vx3667bb9EHDeW7XDBb8B5HQADXYedfFpXiLyjmr3rpcSI3Nj4VuMZlCF1xwTeRharOb F/llxN/6vFtohsipSgsRwxER2zlACg45gMRYf8TecFRtnKfVzm3qzoqvOQKoKCdTsnyj 1QEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="GAZFseV/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si19634990plx.255.2022.02.01.12.39.25; Tue, 01 Feb 2022 12:39:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="GAZFseV/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378032AbiAaNgQ (ORCPT + 99 others); Mon, 31 Jan 2022 08:36:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377496AbiAaNgP (ORCPT ); Mon, 31 Jan 2022 08:36:15 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D49C061714 for ; Mon, 31 Jan 2022 05:36:14 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id b5so11365393qtq.11 for ; Mon, 31 Jan 2022 05:36:14 -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=PEer8tHTGOMBB45BNBliWIb1NwPck3iboeLwpq12AUQ=; b=GAZFseV/rySaS1H2s/o7SLuHE6htq36AAAz2Gg5dLp+rLpPCZJ8owShGHKizWzYrfK lj4d2iowhMaamMT6sMCIyVDaAvAYhVAOwKj9VoTMWDbf7fYPRcekJyVouJgxocp4hSyN ASGbJDEm6ZyQgGb7g1OiLCdKOXrscvCkhaLtDsLYVCdER06z5XbrCJYLJ7/C1Tcadi6j lSI4ACyvSzq0dpW/CdWeg4yMIDOE6QdCcEfHuYZWS4U58Ig3Dr3IKuEWAHiSyBa20eRD j93VpppgeW+YfpZxFPoyFc141sSMloI9rS+8prqata9kfhkNfBWkZf3xkKNuFX2rJYNL cvmg== 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=PEer8tHTGOMBB45BNBliWIb1NwPck3iboeLwpq12AUQ=; b=BgyCX7dw+dpHrmnWzHzuyzTUQQ6pv466d6I38HI1TWf+gBF/269EexSluUdzxBPj5l VtMaUDfDRmm1XUouv3aGbXE5fM3YB6ERdRTtO31PUAhHltiTewglZKK+D1p0RqmHv3z8 7MqwFdNZWqZPnpDhfooXpO+Zj+RBqXOQo4/HBSF4rbtkEzfHtu7A0Ij1X4TOxBrl7tMO zDLhbOTtamt73MEuuJbZRMGmvAg7Xj9HeadWDeRj2a9uprREeolDtYCVOLuvvR8yj4Xv +hFaJ+73hGC0qcavaxsEYHGg14IVqWJbhFeIfJW2SETWUJ38u//RgGy+UuG5dRvsdH2F AZBg== X-Gm-Message-State: AOAM530hCVC0s5YC6W7etrQK5mwrTbzgJ7KFxjHB5YrydYXB1dyeEBLK X5R8V+v6w8t70Ctp4BB2oMKSS56bxARRdg== X-Received: by 2002:a05:622a:13ca:: with SMTP id p10mr14925312qtk.294.1643636173870; Mon, 31 Jan 2022 05:36:13 -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 22sm8132398qtw.75.2022.01.31.05.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 05:36:13 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1nEWqq-009WAO-6O; Mon, 31 Jan 2022 09:36:12 -0400 Date: Mon, 31 Jan 2022 09:36:12 -0400 From: Jason Gunthorpe To: John Hubbard Cc: Andrew Morton , Peter Xu , Jan Kara , Claudio Imbrenda , "Kirill A . Shutemov" , Alex Williamson , Andrea Arcangeli , =?utf-8?B?SsOpcsO0bWU=?= Glisse , LKML , linux-mm@kvack.org Subject: Re: [PATCH 4/4] mm/gup: remove get_user_pages_locked() Message-ID: <20220131133612.GW8034@ziepe.ca> References: <20220131051752.447699-1-jhubbard@nvidia.com> <20220131051752.447699-5-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220131051752.447699-5-jhubbard@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 30, 2022 at 09:17:52PM -0800, John Hubbard wrote: > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 028e8dd82b44..040d88354cfa 100644 > +++ b/mm/mempolicy.c > @@ -907,17 +907,15 @@ static void get_policy_nodemask(struct mempolicy *p, nodemask_t *nodes) > static int lookup_node(struct mm_struct *mm, unsigned long addr) > { > struct page *p = NULL; > - int err; > + int ret; > > - int locked = 1; > - err = get_user_pages_locked(addr & PAGE_MASK, 1, 0, &p, &locked); > - if (err > 0) { > - err = page_to_nid(p); > + mmap_assert_locked(mm); > + ret = get_user_pages(addr & PAGE_MASK, 1, 0, &p, NULL); > + if (ret > 0) { > + ret = page_to_nid(p); > put_page(p); > } > - if (locked) > - mmap_read_unlock(mm); > - return err; > + return ret; > } > > /* Retrieve NUMA policy */ > @@ -968,15 +966,15 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, > if (flags & MPOL_F_NODE) { > if (flags & MPOL_F_ADDR) { > /* > - * Take a refcount on the mpol, lookup_node() > - * will drop the mmap_lock, so after calling > - * lookup_node() only "pol" remains valid, "vma" > - * is stale. > + * Take a refcount on the mpol, because we are about to > + * drop the mmap_lock, after which only "pol" remains > + * valid, "vma" is stale. > */ > pol_refcount = pol; > vma = NULL; > mpol_get(pol); > err = lookup_node(mm, addr); > + mmap_read_unlock(mm); How about move the mmap_read_unlock up one line and then use get_user_pages_fast() I'm guessing in most cases here the PTE will be present so that should be a net win? Jason