* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:21 ` jhubbard
@ 2019-08-08 23:21 ` John Hubbard
2019-08-08 23:30 ` jhubbard
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: John Hubbard @ 2019-08-08 23:21 UTC (permalink / raw)
On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
> + if (!ret)
> goto inval;
> }
> +
> + paddr = page_to_phys(page);
> + 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);
> + paddr = paddr & ~((1UL << *pageshift) - 1);
> *gpa = uv_soc_phys_ram_to_gpa(paddr);
> - *pageshift = ps;
Why are you no longer setting *pageshift? There are a couple of callers
that both use this variable.
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:21 ` jhubbard
2019-08-08 23:21 ` John Hubbard
@ 2019-08-08 23:30 ` jhubbard
2019-08-08 23:30 ` John Hubbard
2019-08-09 9:44 ` linux.bhar
2019-08-09 9:44 ` linux.bhar
2019-08-09 9:52 ` linux.bhar
3 siblings, 2 replies; 18+ messages in thread
From: jhubbard @ 2019-08-08 23:30 UTC (permalink / raw)
On 8/8/19 4:21 PM, John Hubbard wrote:
> On 8/8/19 11:55 AM, Bharath Vedartham wrote:
> ...
>> if (is_gru_paddr(paddr))
>> goto inval;
>> - paddr = paddr & ~((1UL << ps) - 1);
>> + paddr = paddr & ~((1UL << *pageshift) - 1);
>> *gpa = uv_soc_phys_ram_to_gpa(paddr);
>> - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
>
>
...and once that's figured out, I can fix it up here and send it up with
the next misc callsites series. I'm also inclined to make the commit
log read more like this:
sgi-gru: Remove *pte_lookup functions, convert to put_user_page*()
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
As part of this conversion, the *pte_lookup functions can be removed and
be easily replaced with get_user_pages_fast() functions. In the case of
atomic lookup, __get_user_pages_fast() is used, because it does not fall
back to the slow path: get_user_pages(). get_user_pages_fast(), on the other
hand, first calls __get_user_pages_fast(), but then falls back to the
slow path if __get_user_pages_fast() fails.
Also: remove unnecessary CONFIG_HUGETLB ifdefs.
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:30 ` jhubbard
@ 2019-08-08 23:30 ` John Hubbard
2019-08-09 9:44 ` linux.bhar
1 sibling, 0 replies; 18+ messages in thread
From: John Hubbard @ 2019-08-08 23:30 UTC (permalink / raw)
On 8/8/19 4:21 PM, John Hubbard wrote:
> On 8/8/19 11:55 AM, Bharath Vedartham wrote:
> ...
>> if (is_gru_paddr(paddr))
>> goto inval;
>> - paddr = paddr & ~((1UL << ps) - 1);
>> + paddr = paddr & ~((1UL << *pageshift) - 1);
>> *gpa = uv_soc_phys_ram_to_gpa(paddr);
>> - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
>
>
...and once that's figured out, I can fix it up here and send it up with
the next misc callsites series. I'm also inclined to make the commit
log read more like this:
sgi-gru: Remove *pte_lookup functions, convert to put_user_page*()
For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().
This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").
As part of this conversion, the *pte_lookup functions can be removed and
be easily replaced with get_user_pages_fast() functions. In the case of
atomic lookup, __get_user_pages_fast() is used, because it does not fall
back to the slow path: get_user_pages(). get_user_pages_fast(), on the other
hand, first calls __get_user_pages_fast(), but then falls back to the
slow path if __get_user_pages_fast() fails.
Also: remove unnecessary CONFIG_HUGETLB ifdefs.
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:30 ` jhubbard
2019-08-08 23:30 ` John Hubbard
@ 2019-08-09 9:44 ` linux.bhar
2019-08-09 9:44 ` Bharath Vedartham
1 sibling, 1 reply; 18+ messages in thread
From: linux.bhar @ 2019-08-09 9:44 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:30:48PM -0700, John Hubbard wrote:
> On 8/8/19 4:21 PM, John Hubbard wrote:
> > On 8/8/19 11:55 AM, Bharath Vedartham wrote:
> > ...
> >> if (is_gru_paddr(paddr))
> >> goto inval;
> >> - paddr = paddr & ~((1UL << ps) - 1);
> >> + paddr = paddr & ~((1UL << *pageshift) - 1);
> >> *gpa = uv_soc_phys_ram_to_gpa(paddr);
> >> - *pageshift = ps;
> >
> > Why are you no longer setting *pageshift? There are a couple of callers
> > that both use this variable.
> >
> >
>
> ...and once that's figured out, I can fix it up here and send it up with
> the next misc callsites series. I'm also inclined to make the commit
> log read more like this:
>
> sgi-gru: Remove *pte_lookup functions, convert to put_user_page*()
>
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
>
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
>
> As part of this conversion, the *pte_lookup functions can be removed and
> be easily replaced with get_user_pages_fast() functions. In the case of
> atomic lookup, __get_user_pages_fast() is used, because it does not fall
> back to the slow path: get_user_pages(). get_user_pages_fast(), on the other
> hand, first calls __get_user_pages_fast(), but then falls back to the
> slow path if __get_user_pages_fast() fails.
>
> Also: remove unnecessary CONFIG_HUGETLB ifdefs.
Sounds great! I will send the next version with an updated changelog!
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-09 9:44 ` linux.bhar
@ 2019-08-09 9:44 ` Bharath Vedartham
0 siblings, 0 replies; 18+ messages in thread
From: Bharath Vedartham @ 2019-08-09 9:44 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:30:48PM -0700, John Hubbard wrote:
> On 8/8/19 4:21 PM, John Hubbard wrote:
> > On 8/8/19 11:55 AM, Bharath Vedartham wrote:
> > ...
> >> if (is_gru_paddr(paddr))
> >> goto inval;
> >> - paddr = paddr & ~((1UL << ps) - 1);
> >> + paddr = paddr & ~((1UL << *pageshift) - 1);
> >> *gpa = uv_soc_phys_ram_to_gpa(paddr);
> >> - *pageshift = ps;
> >
> > Why are you no longer setting *pageshift? There are a couple of callers
> > that both use this variable.
> >
> >
>
> ...and once that's figured out, I can fix it up here and send it up with
> the next misc callsites series. I'm also inclined to make the commit
> log read more like this:
>
> sgi-gru: Remove *pte_lookup functions, convert to put_user_page*()
>
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
>
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
>
> As part of this conversion, the *pte_lookup functions can be removed and
> be easily replaced with get_user_pages_fast() functions. In the case of
> atomic lookup, __get_user_pages_fast() is used, because it does not fall
> back to the slow path: get_user_pages(). get_user_pages_fast(), on the other
> hand, first calls __get_user_pages_fast(), but then falls back to the
> slow path if __get_user_pages_fast() fails.
>
> Also: remove unnecessary CONFIG_HUGETLB ifdefs.
Sounds great! I will send the next version with an updated changelog!
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:21 ` jhubbard
2019-08-08 23:21 ` John Hubbard
2019-08-08 23:30 ` jhubbard
@ 2019-08-09 9:44 ` linux.bhar
2019-08-09 9:44 ` Bharath Vedartham
2019-08-09 18:03 ` jhubbard
2019-08-09 9:52 ` linux.bhar
3 siblings, 2 replies; 18+ messages in thread
From: linux.bhar @ 2019-08-09 9:44 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
> > + if (!ret)
> > goto inval;
> > }
> > +
> > + paddr = page_to_phys(page);
> > + 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);
> > + paddr = paddr & ~((1UL << *pageshift) - 1);
> > *gpa = uv_soc_phys_ram_to_gpa(paddr);
> > - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
Hi John,
I did set *pageshift. The if statement above sets *pageshift. ps was
used to retrive the pageshift value when the pte_lookup functions were
present. ps was passed by reference to those functions and set by them.
But here since we are trying to remove those functions, we don't need ps
and we directly set *pageshift to HPAGE_SHIFT or PAGE_SHIFT based on the
type of vma.
Hope this clears things up?
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-09 9:44 ` linux.bhar
@ 2019-08-09 9:44 ` Bharath Vedartham
2019-08-09 18:03 ` jhubbard
1 sibling, 0 replies; 18+ messages in thread
From: Bharath Vedartham @ 2019-08-09 9:44 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
> > + if (!ret)
> > goto inval;
> > }
> > +
> > + paddr = page_to_phys(page);
> > + 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);
> > + paddr = paddr & ~((1UL << *pageshift) - 1);
> > *gpa = uv_soc_phys_ram_to_gpa(paddr);
> > - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
Hi John,
I did set *pageshift. The if statement above sets *pageshift. ps was
used to retrive the pageshift value when the pte_lookup functions were
present. ps was passed by reference to those functions and set by them.
But here since we are trying to remove those functions, we don't need ps
and we directly set *pageshift to HPAGE_SHIFT or PAGE_SHIFT based on the
type of vma.
Hope this clears things up?
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-09 9:44 ` linux.bhar
2019-08-09 9:44 ` Bharath Vedartham
@ 2019-08-09 18:03 ` jhubbard
2019-08-09 18:03 ` John Hubbard
1 sibling, 1 reply; 18+ messages in thread
From: jhubbard @ 2019-08-09 18:03 UTC (permalink / raw)
On 8/9/19 2:44 AM, Bharath Vedartham wrote:
> On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
>> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
>>> + if (!ret)
>>> goto inval;
>>> }
>>> +
>>> + paddr = page_to_phys(page);
>>> + 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);
>>> + paddr = paddr & ~((1UL << *pageshift) - 1);
>>> *gpa = uv_soc_phys_ram_to_gpa(paddr);
>>> - *pageshift = ps;
>>
>> Why are you no longer setting *pageshift? There are a couple of callers
>> that both use this variable.
> Hi John,
>
> I did set *pageshift. The if statement above sets *pageshift. ps was
> used to retrive the pageshift value when the pte_lookup functions were
> present. ps was passed by reference to those functions and set by them.
> But here since we are trying to remove those functions, we don't need ps
> and we directly set *pageshift to HPAGE_SHIFT or PAGE_SHIFT based on the
> type of vma.
>
> Hope this clears things up?
>
Right you are, sorry for overlooking that. Looks good.
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-09 18:03 ` jhubbard
@ 2019-08-09 18:03 ` John Hubbard
0 siblings, 0 replies; 18+ messages in thread
From: John Hubbard @ 2019-08-09 18:03 UTC (permalink / raw)
On 8/9/19 2:44 AM, Bharath Vedartham wrote:
> On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
>> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
>>> + if (!ret)
>>> goto inval;
>>> }
>>> +
>>> + paddr = page_to_phys(page);
>>> + 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);
>>> + paddr = paddr & ~((1UL << *pageshift) - 1);
>>> *gpa = uv_soc_phys_ram_to_gpa(paddr);
>>> - *pageshift = ps;
>>
>> Why are you no longer setting *pageshift? There are a couple of callers
>> that both use this variable.
> Hi John,
>
> I did set *pageshift. The if statement above sets *pageshift. ps was
> used to retrive the pageshift value when the pte_lookup functions were
> present. ps was passed by reference to those functions and set by them.
> But here since we are trying to remove those functions, we don't need ps
> and we directly set *pageshift to HPAGE_SHIFT or PAGE_SHIFT based on the
> type of vma.
>
> Hope this clears things up?
>
Right you are, sorry for overlooking that. Looks good.
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread
* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-08 23:21 ` jhubbard
` (2 preceding siblings ...)
2019-08-09 9:44 ` linux.bhar
@ 2019-08-09 9:52 ` linux.bhar
2019-08-09 9:52 ` Bharath Vedartham
3 siblings, 1 reply; 18+ messages in thread
From: linux.bhar @ 2019-08-09 9:52 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
> > + if (!ret)
> > goto inval;
> > }
> > +
> > + paddr = page_to_phys(page);
> > + 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);
> > + paddr = paddr & ~((1UL << *pageshift) - 1);
> > *gpa = uv_soc_phys_ram_to_gpa(paddr);
> > - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
I ll send v5 once your convinced by my argument that ps is not necessary
to set *pageshift and that *pageshift is being set.
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread* [Linux-kernel-mentees] [PATCH v4 1/1] sgi-gru: Remove *pte_lookup functions
2019-08-09 9:52 ` linux.bhar
@ 2019-08-09 9:52 ` Bharath Vedartham
0 siblings, 0 replies; 18+ messages in thread
From: Bharath Vedartham @ 2019-08-09 9:52 UTC (permalink / raw)
On Thu, Aug 08, 2019 at 04:21:44PM -0700, John Hubbard wrote:
> On 8/8/19 11:55 AM, 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 ? FOLL_WRITE : 0, &page);
> > + if (!ret)
> > goto inval;
> > }
> > +
> > + paddr = page_to_phys(page);
> > + 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);
> > + paddr = paddr & ~((1UL << *pageshift) - 1);
> > *gpa = uv_soc_phys_ram_to_gpa(paddr);
> > - *pageshift = ps;
>
> Why are you no longer setting *pageshift? There are a couple of callers
> that both use this variable.
I ll send v5 once your convinced by my argument that ps is not necessary
to set *pageshift and that *pageshift is being set.
Thank you
Bharath
>
> thanks,
> --
> John Hubbard
> NVIDIA
^ permalink raw reply [flat|nested] 18+ messages in thread