lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 24 May 2020 15:21:31 +0200
From:   Manfred Spraul <manfred@...orfullife.com>
To:     Artur Barsegyan <a.barsegyan96@...il.com>
Cc:     skutepov@...il.com, Andrew Morton <akpm@...ux-foundation.org>,
        Lu Shuaibing <shuaibinglu@....com>,
        Nathan Chancellor <natechancellor@...il.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ipc/msg.c: wake up senders until there is a queue empty
 capacity

Hello Artur,

On 5/23/20 10:34 PM, Artur Barsegyan wrote:
> 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

Thanks for analyzing the issue!

> Signed-off-by: Artur Barsegyan <a.barsegyan96@...il.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);

You have missed the case of a do_msgsnd() that doesn't enqueue the message:

Situation:

- 2 messages of type 1 in the queue (2x8192 bytes, queue full)

- 6 senders waiting to send messages of type 2

- 6 receivers waiting to get messages of type 2.

If now a receiver reads one message of type 1, then all 6 senders can send.

WIth your patch applied, only one sender sends the message to one 
receiver, and the remaining 10 tasks continue to sleep.


Could you please check and (assuming that you agree) run your benchmarks 
with the patch applied?

--

     Manfred




View attachment "0002-ipc-msg.c-Handle-case-of-senders-not-enqueuing-the-m.patch" of type "text/x-patch" (2617 bytes)

Powered by blists - more mailing lists