Hi,

On 2026. 11. 06. 10:05, Christian Brauner wrote:
On Tue, Oct 27, 2026 at 05:22:00PM +0100, Bence Csokas wrote:
Add __free() support to eventfd and update drm_syncobj to use it as an
example consumer.

A minor discrepancy I encountered is whether to put a semicolon after
DEFINE_FREE(). It seems some in-tree code does, some doesn't. In the end,
I followed the example set in core-api/cleanup.rst, and omitted it.

Signed-off-by: Bence Csokas <[email protected]>
---

I'm really having trouble seeing how this improves anything
significantly. Probably others have the same impression which is why
this doesn't get a lot of review.

The goal of the __free() API is to reduce the number of goto-based error paths. Normally, you'd have to keep the state of every local in your head for every early return. (Has it been initialized? Has it been consumed? Or does it need to be freed?) Then you need to arrange your "goto tree" (error labels) in a way that frees everything, and then for every early exit, jump to the correct one. This can be quite complex for some functions. Look at KVM or HyperV eventfd code, for example.

By contrast, you just mark the local var with _free() and an appropriate destructor snippet, and the consumption point (the point after which we don't need to free it on a return) with no_free_ptr(), and the compiler instruments every early return accordingly.

Bence

Reply via email to