2020-01-08 13:01:43

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH rdma-rc 3/3] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling

Hi Leon,

On Thu, 19 Dec 2019, Leon Romanovsky wrote:
> From: Yishai Hadas <[email protected]>
>
> As VMAs for a given range might not be available as part of the
> registration phase in ODP, IB_ACCESS_HUGETLB/page_shift must be checked
> as part of the page fault flow.
>
> If the application didn't mmap the backed memory with huge pages or
> released part of that hugepage area, an error will be set as part of the
> page fault flow once be detected.
>
> Fixes: 0008b84ea9af ("IB/umem: Add support to huge ODP")
> Signed-off-by: Yishai Hadas <[email protected]>
> Reviewed-by: Artemy Kovalyov <[email protected]>
> Reviewed-by: Aviad Yehezkel <[email protected]>
> Signed-off-by: Leon Romanovsky <[email protected]>

Thanks for your patch!

> --- a/drivers/infiniband/core/umem_odp.c
> +++ b/drivers/infiniband/core/umem_odp.c
> @@ -241,22 +241,10 @@ struct ib_umem_odp *ib_umem_odp_get(struct ib_udata *udata, unsigned long addr,
> umem_odp->umem.owning_mm = mm = current->mm;
> umem_odp->notifier.ops = ops;
>
> - umem_odp->page_shift = PAGE_SHIFT;
> - if (access & IB_ACCESS_HUGETLB) {
> - struct vm_area_struct *vma;
> - struct hstate *h;
> -
> - down_read(&mm->mmap_sem);
> - vma = find_vma(mm, ib_umem_start(umem_odp));
> - if (!vma || !is_vm_hugetlb_page(vma)) {
> - up_read(&mm->mmap_sem);
> - ret = -EINVAL;
> - goto err_free;
> - }
> - h = hstate_vma(vma);
> - umem_odp->page_shift = huge_page_shift(h);
> - up_read(&mm->mmap_sem);
> - }
> + if (access & IB_ACCESS_HUGETLB)
> + umem_odp->page_shift = HPAGE_SHIFT;
> + else
> + umem_odp->page_shift = PAGE_SHIFT;
>
> umem_odp->tgid = get_task_pid(current->group_leader, PIDTYPE_PID);
> ret = ib_init_umem_odp(umem_odp, ops);

[email protected] reports for linux-next/m68k-allmodconfig/m68k:

drivers/infiniband/core/umem_odp.c:245:26: error: 'HPAGE_SHIFT' undeclared (first use in this function); did you mean 'PAGE_SHIFT'?

Should this depend on some HUGETLBFS option?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


2020-01-08 15:25:59

by Yishai Hadas

[permalink] [raw]
Subject: Re: [PATCH rdma-rc 3/3] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling

On 1/8/2020 2:56 PM, Geert Uytterhoeven wrote:
>     Hi Leon,
>
> On Thu, 19 Dec 2019, Leon Romanovsky wrote:
>> From: Yishai Hadas <[email protected]>
>>
>> As VMAs for a given range might not be available as part of the
>> registration phase in ODP, IB_ACCESS_HUGETLB/page_shift must be checked
>> as part of the page fault flow.
>>
>> If the application didn't mmap the backed memory with huge pages or
>> released part of that hugepage area, an error will be set as part of the
>> page fault flow once be detected.
>>
>> Fixes: 0008b84ea9af ("IB/umem: Add support to huge ODP")
>> Signed-off-by: Yishai Hadas <[email protected]>
>> Reviewed-by: Artemy Kovalyov <[email protected]>
>> Reviewed-by: Aviad Yehezkel <[email protected]>
>> Signed-off-by: Leon Romanovsky <[email protected]>
>
> Thanks for your patch!
>
>> --- a/drivers/infiniband/core/umem_odp.c
>> +++ b/drivers/infiniband/core/umem_odp.c
>> @@ -241,22 +241,10 @@ struct ib_umem_odp *ib_umem_odp_get(struct
>> ib_udata *udata, unsigned long addr,
>>     umem_odp->umem.owning_mm = mm = current->mm;
>>     umem_odp->notifier.ops = ops;
>>
>> -    umem_odp->page_shift = PAGE_SHIFT;
>> -    if (access & IB_ACCESS_HUGETLB) {
>> -        struct vm_area_struct *vma;
>> -        struct hstate *h;
>> -
>> -        down_read(&mm->mmap_sem);
>> -        vma = find_vma(mm, ib_umem_start(umem_odp));
>> -        if (!vma || !is_vm_hugetlb_page(vma)) {
>> -            up_read(&mm->mmap_sem);
>> -            ret = -EINVAL;
>> -            goto err_free;
>> -        }
>> -        h = hstate_vma(vma);
>> -        umem_odp->page_shift = huge_page_shift(h);
>> -        up_read(&mm->mmap_sem);
>> -    }
>> +    if (access & IB_ACCESS_HUGETLB)
>> +        umem_odp->page_shift = HPAGE_SHIFT;
>> +    else
>> +        umem_odp->page_shift = PAGE_SHIFT;
>>
>>     umem_odp->tgid = get_task_pid(current->group_leader, PIDTYPE_PID);
>>     ret = ib_init_umem_odp(umem_odp, ops);
>
> [email protected] reports for linux-next/m68k-allmodconfig/m68k:
>
>     drivers/infiniband/core/umem_odp.c:245:26: error: 'HPAGE_SHIFT'
> undeclared (first use in this function); did you mean 'PAGE_SHIFT'?
>
> Should this depend on some HUGETLBFS option?
>

Thanks for pointing on,
We would expect to use #ifdef CONFIG_HUGETLB_PAGE as done in below
kernel code [1] that also used HPAGE_SHIFT.

I'll send some patch to 'for-next' to handle it.

[1]
https://elixir.bootlin.com/linux/v5.3-rc7/source/drivers/misc/sgi-gru/grufault.c#L183