Re: [PATCH v3 4/8] iommufd: Add iommufd fault object

From: Jason Gunthorpe
Date: Fri Mar 22 2024 - 13:22:42 EST


On Wed, Mar 20, 2024 at 04:18:05PM +0000, Shameerali Kolothum Thodi wrote:
>
> What I have noticed is that,
> -read interface works fine and I can receive struct tiommu_hwpt_pgfault data.
> -But once Guest handles the page faults and returns the page response,
> the write to fault fd never reaches the kernel. The sequence is like below,
>
> sqe = io_uring_get_sqe(ring);
> io_uring_prep_write(sqe, hwpt->fault_fd, resp, sizeof(*resp), 0);
> io_uring_sqe_set_data(sqe, resp);
> io_uring_submit(ring);
> ret = io_uring_wait_cqe(ring, &cqe);
> ....
> Please find the function here[2]
>
> The above cqe wait never returns and hardware times out without receiving
> page response. My understanding of io_uring default op is that it tries to
> issue an sqe as non-blocking first. But it looks like the above write sequence
> ends up in kernel poll_wait() as well.Not sure how we can avoid that for
> write.

Ah, right, it is because poll can't be choosy about read/write, it has
to work equally for both directions. iommufd_fault_fops_poll() never
returns EPOLLOUT

It should just always return EPOLLOUT because we don't have any queue
to manage.

Jason