From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [180.246.144.41]) by gnuweeb.org (Postfix) with ESMTPSA id DE0B2807CA; Tue, 16 Aug 2022 16:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1660668815; bh=ziWwSGsSbku5xl02qFf7bql3OqSVtIOmUsBdWs19PEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HaKF6RtnaazrUrAxu1iD6IsfqJMm1N69RN5cli99yDEr04LaVuWBkZI3+s8GvctL7 Lz5f++urGemwAFzKgIXlAZjhhFGM0bf63UQGV1uVJFiVFqsguw//Tk3RhsLzrCeYYc /0oms3hvrJ2//CbWWs8Giv+4S/dJCm4sqs5Tg679DmLc22rTY6xd1mFyIBjLltnrA6 s3HiR56Y1IGroXWVjrTqHIJyTdmP9voBP4gg/9AKEJ2oK1VKvqrRe5ZzDgp5pyhiyI c391Eh7zWNBfisv0LlOcQn0ozEZN/JZDn3iu4hWXaT32TnmV/IC7qQbBPlIUdyj9a4 r1kG1UbicOmEA== From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Ammar Faizi , GNU/Weeb Mailing List Subject: [PATCH ncns v1 4/4] chnet: ring: Only notify CQE free slot when it's available Date: Tue, 16 Aug 2022 23:53:14 +0700 Message-Id: <20220816165314.3875649-5-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816165314.3875649-1-ammarfaizi2@gnuweeb.org> References: <20220816165314.3875649-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: In `CNRingCtx::WaitCQE`, we don't actually always need to call `NotifyWaitCQEFreeSlot()`. To reduce the call overhead, just check whether the CQE slot is available or not. If it's available, then call it, otherwise, just don't. Signed-off-by: Ammar Faizi --- chnet/chnet_ring.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chnet/chnet_ring.cc b/chnet/chnet_ring.cc index e9d0d57..5c6c14c 100644 --- a/chnet/chnet_ring.cc +++ b/chnet/chnet_ring.cc @@ -375,10 +375,12 @@ void CNRingCtx::WaitCQE(uint32_t to_wait) if (to_wait > max_to_wait) to_wait = max_to_wait; - NotifyWaitCQEFreeSlot(); - std::unique_lock cqe_lock(state_->cqe_lock_); cq_size = cqe_size(); + + if (cq_size < cq_mask + 1) + NotifyWaitCQEFreeSlot(); + if (to_wait <= cq_size) return; -- Ammar Faizi