]> Git Repo - J-linux.git/commitdiff
eventfd: move 'eventfd-count' printing out of spinlock
authorWen Yang <[email protected]>
Mon, 15 Jan 2024 15:27:00 +0000 (23:27 +0800)
committerChristian Brauner <[email protected]>
Tue, 23 Jan 2024 16:56:29 +0000 (17:56 +0100)
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: Alexander Viro <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Dylan Yudaken <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Eric Biggers <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
fs/eventfd.c

index 0252b71099fbca0f8fa50252a4239be1e637221c..fc4d8109076392385d3b92907c692d6b3a57aada 100644 (file)
@@ -283,13 +283,18 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
 static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
 {
        struct eventfd_ctx *ctx = f->private_data;
+       __u64 cnt;
 
        spin_lock_irq(&ctx->wqh.lock);
-       seq_printf(m, "eventfd-count: %16llx\n",
-                  (unsigned long long)ctx->count);
+       cnt = ctx->count;
        spin_unlock_irq(&ctx->wqh.lock);
-       seq_printf(m, "eventfd-id: %d\n", ctx->id);
-       seq_printf(m, "eventfd-semaphore: %d\n",
+
+       seq_printf(m,
+                  "eventfd-count: %16llx\n"
+                  "eventfd-id: %d\n"
+                  "eventfd-semaphore: %d\n",
+                  cnt,
+                  ctx->id,
                   !!(ctx->flags & EFD_SEMAPHORE));
 }
 #endif
This page took 0.048559 seconds and 4 git commands to generate.