public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Alviro Iskandar Setiawan <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
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	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 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<std::mutex> cqe_lock(state_->cqe_lock_);
 	cq_size = cqe_size();
+
+	if (cq_size < cq_mask + 1)
+		NotifyWaitCQEFreeSlot();
+
 	if (to_wait <= cq_size)
 		return;
 
-- 
Ammar Faizi


  parent reply	other threads:[~2022-08-16 16:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 16:53 [PATCH ncns v1 0/4] chnet ring cleanups Ammar Faizi
2022-08-16 16:53 ` [PATCH ncns v1 1/4] chnet: ring: Refactor SQE handling Ammar Faizi
2022-08-16 16:53 ` [PATCH ncns v1 2/4] chnet: ring: Improve `PostCQE()` waiting mechanism Ammar Faizi
2022-08-16 16:53 ` [PATCH ncns v1 3/4] chnet: ring: Make sure we are holding the lock when calling `cqe_size()` Ammar Faizi
2022-08-16 16:53 ` Ammar Faizi [this message]
2022-08-16 17:12   ` [PATCH ncns v1 4/4] chnet: ring: Only notify CQE free slot when it's available Alviro Iskandar Setiawan
2022-08-16 17:17     ` Ammar Nofan Faizi
2022-08-16 17:23       ` Alviro Iskandar Setiawan
2022-08-16 17:24 ` [PATCH ncns v1 0/4] chnet ring cleanups Alviro Iskandar Setiawan

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox