From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751300AbdCJHA4 (ORCPT ); Fri, 10 Mar 2017 02:00:56 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:42609 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbdCJHAz (ORCPT ); Fri, 10 Mar 2017 02:00:55 -0500 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.26 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Fri, 10 Mar 2017 16:00:27 +0900 From: Byungchul Park To: , CC: , Subject: Re: [PATCH] sched: Wake up all non-exclusive waiters in __wake_up_common() Message-ID: <20170310070026.GF11100@X58A-UD3R> References: <1488932512-18999-1-git-send-email-byungchul.park@lge.com> MIME-Version: 1.0 In-Reply-To: <1488932512-18999-1-git-send-email-byungchul.park@lge.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/10 16:00:48, Serialize by Router on LGEKRMHUB03/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/10 16:00:48, Serialize complete at 2017/03/10 16:00:48 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 08, 2017 at 09:21:52AM +0900, Byungchul Park wrote: > __wake_up_common() should wake up all non-exclusive waiters and > exclusive waiters as many as nr_exclusive, but currently it does not. > > Consider a wait queue like the following for example: > > A(exclusive) -> B(non-exclusive) -> C(non-exclusive) > > Current code will wake up only A when nr_exclusive = 1, but has to wake > up A, B and C. Make it do as we expect. I'm wondering if I was wrong. Am I wrong? > > Signed-off-by: Byungchul Park > --- > kernel/sched/wait.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c > index 9453efe..0ea1083 100644 > --- a/kernel/sched/wait.c > +++ b/kernel/sched/wait.c > @@ -67,12 +67,23 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode, > { > wait_queue_t *curr, *next; > > + /* > + * We use nr_exclusive = 0 to wake up all no matter whether > + * WQ_FLAG_EXCLUSIVE is set. However, we have to distinguish > + * between the case and having finished all exclusive wake-up. > + * So make nr_exclusive non-zero in advance in the former case. > + */ > + nr_exclusive = nr_exclusive ?: -1; > + > list_for_each_entry_safe(curr, next, &q->task_list, task_list) { > unsigned flags = curr->flags; > > + if ((flags & WQ_FLAG_EXCLUSIVE) && !nr_exclusive) > + continue; > + > if (curr->func(curr, mode, wake_flags, key) && > - (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive) > - break; > + (flags & WQ_FLAG_EXCLUSIVE)) > + nr_exclusive--; > } > } > > -- > 1.9.1