Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753695AbdF2TJZ (ORCPT ); Thu, 29 Jun 2017 15:09:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:45454 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751681AbdF2TJM (ORCPT ); Thu, 29 Jun 2017 15:09:12 -0400 Date: Thu, 29 Jun 2017 12:08:54 -0700 From: Davidlohr Bueso To: "Luis R. Rodriguez" Cc: Linus Torvalds , Thomas Gleixner , Peter Zijlstra , DanielWagnerwagi@monom.org, Boqun Feng , Marcelo Tosatti , Paul Gortmaker , Ming Lei , "Li, Yi" , "AKASHI, Takahiro" , Jakub Kicinski , Greg Kroah-Hartman , "Paul E. McKenney" , Linux Kernel Mailing List , "Eric W. Biederman" , Petr Mladek , Andrew Lutomirski , Kees Cook , David Howells , Alan Cox , "Theodore Ts'o" , oss-drivers@netronome.com Subject: Re: [PATCH] firmware: wake all waiters Message-ID: <20170629190854.GE3954@linux-80c1.suse> References: <20170623233702.20564-1-jakub.kicinski@netronome.com> <20170626233030.GI21846@wotan.suse.de> <20170627001534.GK21846@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20170627001534.GK21846@wotan.suse.de> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2596 Lines: 58 On Tue, 27 Jun 2017, Luis R. Rodriguez wrote: > * As a side effect of this; the data structures are slimmer. > * >- * One would recommend using this wait queue where possible. >+ * NOTE: swait is for cases of extreme memory considerations and some very >+ * special realtime issues, where it saves a couple of bytes in structures that >+ * need close packing. As such its very special-use. Consider using regular >+ * waits queues from wait.h instead *first*. How about the following? diff --git a/include/linux/swait.h b/include/linux/swait.h index 4a4e180d0a35..f72f274f2a5f 100644 --- a/include/linux/swait.h +++ b/include/linux/swait.h @@ -9,13 +9,16 @@ /* * Simple wait queues * - * While these are very similar to the other/complex wait queues (wait.h) the - * most important difference is that the simple waitqueue allows for - * deterministic behaviour -- IOW it has strictly bounded IRQ and lock hold - * times. + * While these are very similar to regular wait queues (wait.h) the most + * important difference is that the simple waitqueue allows for deterministic + * behaviour -- IOW it has strictly bounded IRQ and lock hold times. * - * In order to make this so, we had to drop a fair number of features of the - * other waitqueue code; notably: + * Mainly, this is accomplished by two things. Firstly not allowing swake_up_all + * from IRQ disabled, and dropping the lock upon every wakeup, giving a higher + * priority task a chance to run. + * + * Secondly, we had to drop a fair number of features of the other waitqueue + * code; notably: * * - mixing INTERRUPTIBLE and UNINTERRUPTIBLE sleeps on the same waitqueue; * all wakeups are TASK_NORMAL in order to avoid O(n) lookups for the right @@ -24,12 +27,14 @@ * - the exclusive mode; because this requires preserving the list order * and this is hard. * - * - custom wake functions; because you cannot give any guarantees about - * random code. - * - * As a side effect of this; the data structures are slimmer. + * - custom wake callback functions; because you cannot give any guarantees + * about random code. This also allows swait to be used in RT, such that + * raw spinlock can be used for the swait queue head. * - * One would recommend using this wait queue where possible. + * As a side effect of these; the data structures are slimmer albeit more ad-hoc. + * For all the above, note that simple wait queues should _only_ be used under + * very specific realtime constraints -- it is best to stick with the regular + * wait queues in most cases. */ struct task_struct;