Re: [PATCH] netlink: introduce netlink poll to resolve fast return issue

From: Jakub Kicinski
Date: Tue Nov 07 2023 - 11:53:54 EST


On Tue, 7 Nov 2023 11:05:08 +0900 Jong eon Park wrote:
> The issue at hand is that once it occurs, users cannot escape from this
> "busy running" situation, and the inadequate handling of EPOLLERR by users
> imposes a heavy burden on the entire system, which seems quite harsh.
>
> The reason for a separate netlink poll is related to the netlink state.
> When it enters the NETLINK_S_CONGESTED state, sk can no longer receive or
> deliver skb, and the receive_queue must be completely emptied to clear the
> state. However, it was found that the NETLINK_S_CONGESTED state was still
> maintained even when the receive_queue was empty, which was incorrect, and
> that's why I implemented the handling in poll.

Why does the wake up happen in the first place?
I don't see anything special in the netlink code, so I'm assuming
it's because datagram_poll() returns EPOLLERR.

The man page says:

EPOLLERR
Error condition happened on the associated file
descriptor. This event is also reported for the write end
of a pipe when the read end has been closed.

epoll_wait(2) will always report for this event; it is not
necessary to set it in events when calling epoll_ctl().

To me that sounds like EPOLLERR is always implicitly enabled,
and should be handled by the application. IOW it's an pure application
bug.

Are you aware of any precedent for sockets adding in EPOLLOUT
when EPOLLERR is set?