From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933756AbcHDOKc (ORCPT ); Thu, 4 Aug 2016 10:10:32 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45154 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758646AbcHDOK2 (ORCPT ); Thu, 4 Aug 2016 10:10:28 -0400 Date: Thu, 4 Aug 2016 16:09:38 +0200 From: Peter Zijlstra To: Bart Van Assche Cc: Oleg Nesterov , "mingo@kernel.org" , Andrew Morton , Johannes Weiner , Neil Brown , Michael Shaver , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] sched: Avoid that __wait_on_bit_lock() hangs Message-ID: <20160804140938.GB24652@twins.programming.kicks-ass.net> References: <20160803181128.GH6879@twins.programming.kicks-ass.net> <11007730-3fa5-139a-8091-655743894ae8@sandisk.com> <20160803213006.GA11712@redhat.com> <17b65ff9-215f-ab74-9f5f-15dbd308d054@sandisk.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17b65ff9-215f-ab74-9f5f-15dbd308d054@sandisk.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 03, 2016 at 02:51:23PM -0700, Bart Van Assche wrote: > So I started testing the patch below that should fix the same hang but > without triggering any wait list corruption. > > diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c > index f15d6b6..4e3f651 100644 > --- a/kernel/sched/wait.c > +++ b/kernel/sched/wait.c > @@ -282,7 +282,7 @@ void abort_exclusive_wait(wait_queue_head_t *q, > wait_queue_t *wait, > spin_lock_irqsave(&q->lock, flags); > if (!list_empty(&wait->task_list)) > list_del_init(&wait->task_list); > - else if (waitqueue_active(q)) > + if (waitqueue_active(q)) > __wake_up_locked_key(q, mode, key); > spin_unlock_irqrestore(&q->lock, flags); > } So the problem with this patch is that it will violate the nr_exclusive semantics in that it can result in too many wakeups -- which is a much less severe (typically harmless) issue. We now always wake up the next waiter, even if there wasn't an actual wakeup we raced against. And if we then also get a wakeup, we can end up with 2 woken tasks (instead of the nr_exclusive=1). Now, since wait loops must all deal with spurious wakeups, this ends up as harmless overhead. But I'd still like to understand where we loose the wakeup. What are you doing to reproduce this issue?