All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aadeshveer Singh <aadeshveer07@gmail.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, farosas@suse.de,
	Aadeshveer Singh <aadeshveer07@gmail.com>
Subject: [PATCH] migration: use eventfd functions instead of bare read/write
Date: Thu, 14 May 2026 13:21:37 +0530	[thread overview]
Message-ID: <20260514075136.301706-2-aadeshveer07@gmail.com> (raw)

Replace read() and write() syscalls on eventfd with glibc wrappers
eventfd_read() and eventfd_write(), to make code more robust, readable
and future-proof.

Signed-off-by: Aadeshveer Singh <aadeshveer07@gmail.com>
---
 migration/postcopy-ram.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index f5ef93f193..16113b166d 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -1330,12 +1330,12 @@ static void *postcopy_ram_fault_thread(void *opaque)
         }
 
         if (pfd[1].revents) {
-            uint64_t tmp64 = 0;
+            eventfd_t tmp_event = 0;
 
             /* Consume the signal */
-            if (read(mis->userfault_event_fd, &tmp64, 8) != 8) {
+            if (eventfd_read(mis->userfault_event_fd, &tmp_event)) {
                 /* Nothing obviously nicer than posting this error. */
-                error_report("%s: read() failed", __func__);
+                error_report("%s: eventfd_read() failed", __func__);
             }
 
             if (qatomic_read(&mis->fault_thread_quit)) {
@@ -1773,13 +1773,11 @@ void postcopy_temp_page_reset(PostcopyTmpPage *tmp_page)
 
 void postcopy_fault_thread_notify(MigrationIncomingState *mis)
 {
-    uint64_t tmp64 = 1;
-
     /*
      * Wakeup the fault_thread.  It's an eventfd that should currently
      * be at 0, we're going to increment it to 1
      */
-    if (write(mis->userfault_event_fd, &tmp64, 8) != 8) {
+    if (eventfd_write(mis->userfault_event_fd, 1)) {
         /* Not much we can do here, but may as well report it */
         error_report("%s: incrementing failed: %s", __func__,
                      strerror(errno));
-- 
2.54.0



             reply	other threads:[~2026-05-14  7:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14  7:51 Aadeshveer Singh [this message]
2026-05-15 14:42 ` [PATCH] migration: use eventfd functions instead of bare read/write Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514075136.301706-2-aadeshveer07@gmail.com \
    --to=aadeshveer07@gmail.com \
    --cc=farosas@suse.de \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.