On Wed, Aug 07, 2019 at 01:42:40PM +0200, Douglas Gilbert wrote:
> Track the number of submitted and waiting (for read/receive)
> requests on each file descriptor with two atomic integers.
> This speeds sg_poll() and ioctl(SG_GET_NUM_WAITING) which
> are oft used with the asynchronous (non-blocking) interfaces.

The idea of just tracking a count here seems sensible.

Tiny nitpick below:

> +     else if (likely(sfp->cmd_q))
> +             p_res |= EPOLLOUT | EPOLLWRNORM;
> +     else if (atomic_read(&sfp->submitted) == 0)
>               p_res |= EPOLLOUT | EPOLLWRNORM;

Why not simply:

         else if (sfp->cmd_q || atomic_read(&sfp->submitted)
                p_res |= EPOLLOUT | EPOLLWRNORM;

Reply via email to