From patchwork Mon Aug 15 13:09:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12943571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B812DC28B2B for ; Mon, 15 Aug 2022 13:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232444AbiHONVZ (ORCPT ); Mon, 15 Aug 2022 09:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbiHONVX (ORCPT ); Mon, 15 Aug 2022 09:21:23 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6585618B0E for ; Mon, 15 Aug 2022 06:21:22 -0700 (PDT) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27EMGK75029646 for ; Mon, 15 Aug 2022 06:21:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=elo11oeZTA1gSvwZSKIWM7v1BAL4ib92riEy4sbRovY=; b=DtqsC80pbkqM73COuqxddmo2GugwpPZOyI3wwJ7MFHSc7VBO4uNrpEIEEF21sdBpbaxg YXzj65OZcJ8d/BXtywbTxs9bVCCW4C4npO81ah+vQBfJvp+yBfEmSqJwvIJO+g4cYWVK ZNcAjzLcJ2BZ2kC877Flgtaw5myj0S+0Dx4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hx9pyj4qx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 15 Aug 2022 06:21:21 -0700 Received: from twshared6324.05.ash7.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 15 Aug 2022 06:21:20 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 640DF49B7311; Mon, 15 Aug 2022 06:09:55 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , Dylan Yudaken Subject: [PATCH liburing 09/11] expose CQ ring overflow state Date: Mon, 15 Aug 2022 06:09:45 -0700 Message-ID: <20220815130947.1002152-10-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220815130947.1002152-1-dylany@fb.com> References: <20220815130947.1002152-1-dylany@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: Qwn1kOZM7EHPi9AtzHlujcm_Ht0Wp4qi X-Proofpoint-ORIG-GUID: Qwn1kOZM7EHPi9AtzHlujcm_Ht0Wp4qi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-15_08,2022-08-15_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Allow the application to easily view if the CQ ring is in overflow state in case it would like to explicitly flush using io_uring_get_events. Explicit flushing can be useful for applications that prefer to have reduced latency on CQs than to process as many as possible. Signed-off-by: Dylan Yudaken --- src/include/liburing.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index 6b25c358c63f..47668c3f26a7 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -1064,6 +1064,15 @@ static inline unsigned io_uring_cq_ready(const struct io_uring *ring) return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead; } +/* + * Returns true if there are overflow entries waiting to be flushed onto + * the CQ ring + */ +static inline bool io_uring_cq_has_overflow(const struct io_uring *ring) +{ + return IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_CQ_OVERFLOW; +} + /* * Returns true if the eventfd notification is currently enabled */