]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
eventpoll: rename ep_refcount_dec_and_test() to ep_put()
authorChristian Brauner <brauner@kernel.org>
Fri, 24 Apr 2026 13:46:37 +0000 (15:46 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 28 Apr 2026 15:27:27 +0000 (17:27 +0200)
ep_refcount_dec_and_test() mirrors refcount_dec_and_test() verbatim,
which reads fine at a call site like

  if (ep_refcount_dec_and_test(ep))
      ep_free(ep);

but awkward at

  WARN_ON_ONCE(ep_refcount_dec_and_test(ep));

and does not pair cleanly with ep_get(). Rename to the idiomatic
ep_put() and reword the kerneldoc to spell out the return-value
contract (caller is responsible for ep_free() iff the return is
true). Leave ep_put() as a bool-returning wrapper -- we cannot fold
ep_free() into it because ep_remove() calls it under ep->mtx and the
mutex would still be held when ep_free()'s mutex_destroy() ran (see
commit 8c2e52ebbe88 "eventpoll: don't decrement ep refcount while
still holding the ep mutex").

No functional change.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Link: https://patch.msgid.link/20260424-work-epoll-rework-v1-6-249ed00a20f3@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/eventpoll.c

index b6a14c69c4824bd7109509ad7944c929c6afd7ac..da31a3ac6057cad5bd89e97b463597821d1677ce 100644 (file)
@@ -969,9 +969,10 @@ static void ep_get(struct eventpoll *ep)
 }
 
 /*
- * Returns true if the event poll can be disposed
+ * Drop a reference to @ep; returns true iff it was the last, in which
+ * case the caller is responsible for ep_free().
  */
-static bool ep_refcount_dec_and_test(struct eventpoll *ep)
+static bool ep_put(struct eventpoll *ep)
 {
        if (!refcount_dec_and_test(&ep->refcount))
                return false;
@@ -1100,7 +1101,7 @@ static void ep_remove(struct eventpoll *ep, struct epitem *epi)
 
        ep_remove_file(ep, epi, file);
        ep_remove_epi(ep, epi);
-       WARN_ON_ONCE(ep_refcount_dec_and_test(ep));
+       WARN_ON_ONCE(ep_put(ep));
 }
 
 /*
@@ -1160,7 +1161,7 @@ static void ep_clear_and_put(struct eventpoll *ep)
        }
 
        mutex_unlock(&ep->mtx);
-       if (ep_refcount_dec_and_test(ep))
+       if (ep_put(ep))
                ep_free(ep);
 }
 
@@ -1339,7 +1340,7 @@ again:
 
                mutex_unlock(&ep->mtx);
 
-               if (ep_refcount_dec_and_test(ep))
+               if (ep_put(ep))
                        ep_free(ep);
                goto again;
        }