From nobody Tue Apr 7 21:27:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773257971; cv=none; d=zohomail.com; s=zohoarc; b=E8bHRqrCjlrCxVus+w/UUaNYiGYsjgmR8RW/r4v9FQOUe1uay1pR/Svcs8NLh2qsAP192oeParyb1iNMKlf+IqxI3g1JXpL8hjK+UB+A0+AzaBj8VP58lPjfwmxjupTNwXD2k1VutZPmb6R+mBjUi01R2Hp0s8g2s90OXV7H7K4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773257971; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6vzz9Em0KSbrhkHesHlqNxtS8peJgOmDFWhY/5MeZqU=; b=MaKRThzzav6aC1wXZsglxWVJhhf+equ4Tu1EIfCfD3Pd4Fah2OGqcPsHDbHHogoy79VWwia/ZtMYezGkV0G4vclZiBCO0zHC24/3+Qmy4d5O1zsyxTCwLqpmjiwfqcoNWM9YQbF585HF7VrT2kBhO7ZjQC0LaMIYpTFcqbrx15k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177325797190563.962832539865985; Wed, 11 Mar 2026 12:39:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0PON-0006oE-JS; Wed, 11 Mar 2026 15:38:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0POM-0006kH-Cn; Wed, 11 Mar 2026 15:38:50 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0POK-0000ek-Rl; Wed, 11 Mar 2026 15:38:50 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A24B9192112; Wed, 11 Mar 2026 22:34:29 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id E63E337C477; Wed, 11 Mar 2026 22:35:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1773257669; bh=jQENt2AgbC8mZlxJWiyfg+ZVOWKHlOxsAGIiAZSIphk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X3SVdkPzeuTkqxA5h2CHpjXHl1QRSB5JDGLQaqRxJzvvMzoFj+5UYSmaRHmdu3c2z IMivtLFhkeuCYV9DScEsFYp3ezxMAw6kodL3wd24avngKEDO5SigDyf957J1owg/A1 Xo7zP8ByP4nen595S/Pcxh0rLn4hOgAy4ThEzxhBaN0hXpt0yfngvrBSFQW3Xk6/hO GlmryJ5VucAHVNNQt4UJVQ4J7HJbJLKZDOWHMLsBMH8uV7uw5rPtDur2lOTpNaahhz zmZf4Z4r0syzXaANtGUgFJl5r56eLwhOjP6KaxfXcGx6wxvYGHOO/iDJaUt8q8+fsu 12xOpoWcVeS5A== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Jens Axboe , Stefan Hajnoczi , Michael Tokarev Subject: [Stable-10.2.2 42/53] fdmon-io_uring: check CQ ring directly in gsource_check Date: Wed, 11 Mar 2026 22:34:35 +0300 Message-ID: <20260311193449.1096110-42-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1773257973383154100 Content-Type: text/plain; charset="utf-8" From: Jens Axboe gsource_check() only looks at the ppoll revents for the io_uring fd, but CQEs can be posted during gsource_prepare()'s io_uring_submit() call via kernel task_work processing on syscall exit. These completions are already sitting in the CQ ring but the ring fd may not be signaled yet, causing gsource_check() to return false. Add a fallback io_uring_cq_ready() check so completions that arrive during submission are dispatched immediately rather than waiting for the next ppoll() cycle. Signed-off-by: Jens Axboe Message-ID: <20260213143225.161043-3-axboe@kernel.dk> Signed-off-by: Stefan Hajnoczi (cherry picked from commit 961fcc0f22768e7c3432fc645b93dc7cd4932fae) Signed-off-by: Michael Tokarev diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c index d0b56127c6..b81e412402 100644 --- a/util/fdmon-io_uring.c +++ b/util/fdmon-io_uring.c @@ -344,7 +344,19 @@ static void fdmon_io_uring_gsource_prepare(AioContext = *ctx) static bool fdmon_io_uring_gsource_check(AioContext *ctx) { gpointer tag =3D ctx->io_uring_fd_tag; - return g_source_query_unix_fd(&ctx->source, tag) & G_IO_IN; + + /* Check ppoll revents (normal path) */ + if (g_source_query_unix_fd(&ctx->source, tag) & G_IO_IN) { + return true; + } + + /* + * Also check for CQEs that may have been posted during prepare's + * io_uring_submit() via task_work on syscall exit. Without this, + * the main loop can miss completions and sleep in ppoll() until the + * next timer fires. + */ + return io_uring_cq_ready(&ctx->fdmon_io_uring); } =20 /* Dispatch CQE handlers that are ready */ --=20 2.47.3