From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756166AbcIAVDM (ORCPT ); Thu, 1 Sep 2016 17:03:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37176 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756099AbcIAVDH (ORCPT ); Thu, 1 Sep 2016 17:03:07 -0400 Date: Thu, 1 Sep 2016 19:26:58 +0200 From: Oleg Nesterov To: Peter Zijlstra Cc: Ingo Molnar , Al Viro , Bart Van Assche , Johannes Weiner , Linus Torvalds , Neil Brown , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Message-ID: <20160901172658.GA14456@redhat.com> References: <20160826124453.GA28894@redhat.com> <20160826124528.GA28904@redhat.com> <20160901113919.GI10138@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160901113919.GI10138@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Sep 2016 17:27:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/01, Peter Zijlstra wrote: > > So mixing INTERRUPTIBLE and UNINTERRUPTIBLE and then not using > TASK_NORMAL for wakeups is a mis-feature/abuse of waitqueues IMO. Heh, agreed. When I was doing this fix I suddenly realize that I do not understand why do we have, say, wake_up_interruptible(). I mean, I can't imagine the "real" use-case when you actually want to wake up only the INTERRUPTIBLE tasks and leave the UNINTERRUPTIBLE sleeping. Exclusive or not. It seems that wake_up_interruptible() is mostly used simply because the caller knows that UNINTERRUPTIBLE waiters are not possible, this is often the case. > @@ -67,6 +70,16 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode, > { > wait_queue_t *curr, *next; > > +#ifdef CONFIG_DEBUG_WAITQUEUE > + if (q->state != -1) { > + /* > + * WARN if we have INTERRUPTIBLE and UNINTERRUPTIBLE > + * waiters and do not use TASK_NORMAL to wake. > + */ > + WARN_ON_ONCE(q->state != (mode & TASK_NORMAL)); > + } > +#endif Yes, perhaps... Actually, I think that TASK_NORMAL should be used even if wq mixes UNINTERRUPTIBLE and KILLABLE waiters. The fact that TASK_KILLABLE includes TASK_UNINTERRUPTIBLE is just "implementation detail" even if I do not think this will be ever changed. Oleg.