[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220131133612.GW8034@ziepe.ca>
Date: Mon, 31 Jan 2022 09:36:12 -0400
From: Jason Gunthorpe <jgg@...pe.ca>
To: John Hubbard <jhubbard@...dia.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Peter Xu <peterx@...hat.com>, Jan Kara <jack@...e.cz>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Alex Williamson <alex.williamson@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Jérôme Glisse <jglisse@...hat.com>,
LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH 4/4] mm/gup: remove get_user_pages_locked()
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
Powered by blists - more mailing lists