From: Hillf Danton <hdanton@sina.com>
To: Bharath Vedartham <linux.bhar@gmail.com>
Cc: sivanich@sgi.com, arnd@arndb.de, ira.weiny@intel.com,
jhubbard@nvidia.com, jglisse@redhat.com,
gregkh@linuxfoundation.org, william.kucharski@oracle.com,
hch@lst.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v3 1/1] sgi-gru: Remove *pte_lookup functions
Date: Sat, 27 Jul 2019 17:22:28 +0800 [thread overview]
Message-ID: <1564170120-11882-2-git-send-email-linux.bhar@gmail.com> (raw)
Message-ID: <20190727092228.XllsRDGhGOyPEWHo58xPSCPro1CpujN2jTCLitTC_pk@z> (raw)
In-Reply-To: <1564170120-11882-1-git-send-email-linux.bhar@gmail.com>
On Fri, 26 Jul 2019 12:42:26 -0700 (PDT) Bharath Vedartham wrote:
>
> static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
> int write, int atomic, unsigned long *gpa, int *pageshift)
> {
> struct mm_struct *mm = gts->ts_mm;
> struct vm_area_struct *vma;
> unsigned long paddr;
> - int ret, ps;
> + int ret;
> + struct page *page;
>
> vma = find_vma(mm, vaddr);
> if (!vma)
> @@ -263,21 +187,33 @@ static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
>
> /*
> * Atomic lookup is faster & usually works even if called in non-atomic
> - * context.
> + * context. get_user_pages_fast does atomic lookup before falling back to
> + * slow gup.
> */
> rmb(); /* Must/check ms_range_active before loading PTEs */
> - ret = atomic_pte_lookup(vma, vaddr, write, &paddr, &ps);
> - if (ret) {
> - if (atomic)
> + if (atomic) {
> + ret = __get_user_pages_fast(vaddr, 1, write, &page);
> + if (!ret)
> goto upm;
> - if (non_atomic_pte_lookup(vma, vaddr, write, &paddr, &ps))
> + } else {
> + ret = get_user_pages_fast(vaddr, 1, write, &page);
> + if (!ret)
> goto inval;
> }
> +
> + paddr = page_to_phys(page);
You may drop find_vma() above if PageHuge(page) makes sense here.
> + put_user_page(page);
> +
> + if (unlikely(is_vm_hugetlb_page(vma)))
> + *pageshift = HPAGE_SHIFT;
> + else
> + *pageshift = PAGE_SHIFT;
> +
> if (is_gru_paddr(paddr))
> goto inval;
> - paddr = paddr & ~((1UL << ps) - 1);
> - *gpa = uv_soc_phys_ram_to_gpa(paddr);
> - *pageshift = ps;
> + paddr = paddr & ~((1UL << *pageshift) - 1);
> + *gpa = uv_soc_phys_ram_to_gpa(paddr);
> +
> return VTOP_SUCCESS;
>
> inval:
> --
> 2.7.4
next prev parent reply other threads:[~2019-07-27 9:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 19:41 [PATCH v3 0/1] get_user_pages changes Bharath Vedartham
2019-07-26 19:42 ` Bharath Vedartham [this message]
2019-07-27 9:22 ` [PATCH v3 1/1] sgi-gru: Remove *pte_lookup functions Hillf Danton
2019-07-28 17:56 ` Bharath Vedartham
2019-07-29 6:48 ` Christoph Hellwig
2019-07-30 10:26 ` Bharath Vedartham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1564170120-11882-2-git-send-email-linux.bhar@gmail.com \
--to=hdanton@sina.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=ira.weiny@intel.com \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux.bhar@gmail.com \
--cc=sivanich@sgi.com \
--cc=william.kucharski@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox