RE: [外部邮件] Re: [PATCH] RDMA/core: Prevent soft lockup during large user memory region cleanup

Li,Rongqing
2025-11-13T07:38:55Z

> On 2025/11/11 15:01, lirongqing wrote:
> > From: Li RongQing <lirongqing@baidu.com>
> >
> > When a process exits with numerous large, pinned memory regions
> > consisting of 4KB pages, the cleanup of the memory region through
> > __ib_umem_release() may cause soft lockups. This is because
> > unpin_user_page_range_dirty_lock()
> > is called in a tight loop for unpin and releasing page without
> > yielding the CPU.
> >
> > Fix the soft lockup by adding cond_resched() calls in
> > __ib_umem_release
> >
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > ---
> > drivers/infiniband/core/umem.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/infiniband/core/umem.c
> > b/drivers/infiniband/core/umem.c index c5b6863..70c1520 100644
> > --- a/drivers/infiniband/core/umem.c
> > +++ b/drivers/infiniband/core/umem.c
> > @@ -59,6 +59,7 @@ static void __ib_umem_release(struct ib_device *dev,
> struct ib_umem *umem, int d
> > unpin_user_page_range_dirty_lock(sg_page(sg),
> > DIV_ROUND_UP(sg->length, PAGE_SIZE), make_dirty);
> >
> > + cond_resched();
>
> If the soft lockup is caused by unpin_user_page_range_dirty_lock(),
> cond_resched() should probably be inside the for_each_sgtable_sg loop.
>

Ok, it is more reasonable to move it inside the loop, and calling cond_resched per 2M should have little performance impact, and don't need to limit the calling speed.

Thanks

-Li

> Junxian
>
> > sg_free_append_table(&umem->sgt_append);
> > }
> >