From: Artur Barsegyan <a.barsegyan96@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: a.barsegyan96@gmail.com, skutepov@gmail.com,
Andrew Morton <akpm@linux-foundation.org>,
Lu Shuaibing <shuaibinglu@126.com>,
Manfred Spraul <manfred@colorfullife.com>,
Nathan Chancellor <natechancellor@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] ipc/msg.c: wake up senders until there is a queue empty capacity
Date: Sat, 23 May 2020 23:34:44 +0300 [thread overview]
Message-ID: <20200523203448.84235-1-a.barsegyan96@gmail.com> (raw)
Take into account the total size of the already enqueued messages of
previously handled senders before another one.
Otherwise, we have serious degradation of receiver throughput for
case with multiple senders because another sender wakes up,
checks the queue capacity and falls into sleep again.
Each round-trip wastes CPU time a lot and leads to perceptible
throughput degradation.
Source code of:
- sender/receiver
- benchmark script
- ready graphics of before/after results
is located here: https://github.com/artur-barsegyan/systemv_queue_research
Signed-off-by: Artur Barsegyan <a.barsegyan96@gmail.com>
---
ipc/msg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ipc/msg.c b/ipc/msg.c
index caca67368cb5..52d634b0a65a 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -214,6 +214,7 @@ static void ss_wakeup(struct msg_queue *msq,
struct msg_sender *mss, *t;
struct task_struct *stop_tsk = NULL;
struct list_head *h = &msq->q_senders;
+ size_t msq_quota_used = 0;
list_for_each_entry_safe(mss, t, h, list) {
if (kill)
@@ -233,7 +234,7 @@ static void ss_wakeup(struct msg_queue *msq,
* move the sender to the tail on behalf of the
* blocked task.
*/
- else if (!msg_fits_inqueue(msq, mss->msgsz)) {
+ else if (!msg_fits_inqueue(msq, msq_quota_used + mss->msgsz)) {
if (!stop_tsk)
stop_tsk = mss->tsk;
@@ -241,6 +242,7 @@ static void ss_wakeup(struct msg_queue *msq,
continue;
}
+ msq_quota_used += mss->msgsz;
wake_q_add(wake_q, mss->tsk);
}
}
--
2.19.1
next reply other threads:[~2020-05-23 20:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-23 20:34 Artur Barsegyan [this message]
2020-05-24 13:21 ` [PATCH] ipc/msg.c: wake up senders until there is a queue empty capacity Manfred Spraul
2020-05-26 7:56 ` Artur Barsegyan
2020-05-27 6:03 ` Manfred Spraul
2020-05-27 11:22 ` Artur Barsegyan
2020-06-01 14:02 ` Artur Barsegyan
2020-06-01 14:20 ` Manfred Spraul
2020-05-27 11:20 Artur Barsegyan
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=20200523203448.84235-1-a.barsegyan96@gmail.com \
--to=a.barsegyan96@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=natechancellor@gmail.com \
--cc=shuaibinglu@126.com \
--cc=skutepov@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).