Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbbDGRsH (ORCPT ); Tue, 7 Apr 2015 13:48:07 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:33163 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753270AbbDGRsF (ORCPT ); Tue, 7 Apr 2015 13:48:05 -0400 Message-ID: <55241851.7060704@colorfullife.com> Date: Tue, 07 Apr 2015 19:48:01 +0200 From: Manfred Spraul User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Sebastian Andrzej Siewior , linux-kernel@vger.kernel.org CC: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Darren Hart , Steven Rostedt , fredrik.markstrom@windriver.com, Davidlohr Bueso Subject: Re: [PATCH 3/3] ipc/mqueue: remove STATE_PENDING References: <1428419030-20030-1-git-send-email-bigeasy@linutronix.de> <1428419030-20030-4-git-send-email-bigeasy@linutronix.de> In-Reply-To: <1428419030-20030-4-git-send-email-bigeasy@linutronix.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2209 Lines: 59 On 04/07/2015 05:03 PM, Sebastian Andrzej Siewior wrote: > This patch moves the wakeup_process() invocation so it is not done under > the info->lock. With this change, the waiter is woken up once it is > "ready" which means its state is STATE_READY and it does not need to loop > on SMP if it is still in STATE_PENDING. > In the timeout case we still need to grab the info->lock to verify the state. > > This change should also avoid the introduction of preempt_disable() in > -RT which avoids a busy-loop which pools for the STATE_PENDING -> STATE_READY > change if the waiter has a higher priority compared to the waker. > @@ -909,9 +905,8 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) > * bypasses the message array and directly hands the message over to the > * receiver. > * The receiver accepts the message and returns without grabbing the queue > - * spinlock. Therefore an intermediate STATE_PENDING state and memory barriers > - * are necessary. The same algorithm is used for sysv semaphores, see > - * ipc/sem.c for more details. > + * spinlock. The same algorithm is used for sysv semaphores, see ipc/sem.c > + * for more details. No. With your change, ipc/sem.c and ipc/msg.c use different algorithms. Please update the comment and describe the new approach: Current approach: - set pointer to message - STATE_PENDING - wake_up_process() - STATE_READY (now the receiver can continue) New approach: - set pointer to message - get_task_struct - STATE_READY (now the receiver can continue, e.g. woken up due to an unrelated SIGKILL) - wake_up_process() - put_task_struct() > + if (r_sender) { > + wake_up_process(r_sender); > + put_task_struct(r_sender); > + } > ret = 0; Could you double-check that it is safe to call wake_up_process on a killed and reaped thread, only with a get_task_struct reference? And: please test it, too. (patch the kernel so that you can trigger this case). -- Manfred -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/