Skip to content

Commit bd46543

Browse files
tasksetbrauner
authored andcommitted
eventfd: move 'eventfd-count' printing out of spinlock
When printing eventfd->count, interrupts will be disabled and a spinlock will be obtained, competing with eventfd_write(). By moving the "eventfd-count" print out of the spinlock and merging multiple seq_printf() into one, it could improve a bit, just like timerfd_show(). Signed-off-by: Wen Yang <wenyang.linux@foxmail.com> Link: https://lore.kernel.org/r/tencent_B0B3D2BD9861FD009E03AB18A81783322709@qq.com Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Jens Axboe <axboe@kernel.dk> Cc: Christian Brauner <brauner@kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dylan Yudaken <dylany@fb.com> Cc: David Woodhouse <dwmw@amazon.co.uk> Cc: Matthew Wilcox <willy@infradead.org> Cc: Eric Biggers <ebiggers@google.com> Cc: <linux-fsdevel@vger.kernel.org> Cc: <linux-kernel@vger.kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 3948aba commit bd46543

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/eventfd.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,18 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
283283
static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
284284
{
285285
struct eventfd_ctx *ctx = f->private_data;
286+
__u64 cnt;
286287

287288
spin_lock_irq(&ctx->wqh.lock);
288-
seq_printf(m, "eventfd-count: %16llx\n",
289-
(unsigned long long)ctx->count);
289+
cnt = ctx->count;
290290
spin_unlock_irq(&ctx->wqh.lock);
291-
seq_printf(m, "eventfd-id: %d\n", ctx->id);
292-
seq_printf(m, "eventfd-semaphore: %d\n",
291+
292+
seq_printf(m,
293+
"eventfd-count: %16llx\n"
294+
"eventfd-id: %d\n"
295+
"eventfd-semaphore: %d\n",
296+
cnt,
297+
ctx->id,
293298
!!(ctx->flags & EFD_SEMAPHORE));
294299
}
295300
#endif

0 commit comments

Comments
 (0)