From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 813DCC4332D for ; Thu, 19 Mar 2020 08:42:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51FED2072C for ; Thu, 19 Mar 2020 08:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584607372; bh=bc6Fify+38nZAY3Cia1aV1OdCk4gn2q4y8vjHO0jHQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=mMGlQ5j2eZSNW/iN6ifkzawJiwCLIHF1IzImsBbpgLYqx59t7KXPZyBOlxj6vtsbY eQrvDop20TCJybKuxeO/B9DpXZNSEbKw/L0ZGKUEeoMD7z/H8IV2twf6aJpmaV7vD/ I8CfdBv0natEYLqwPHqCFqiwWN3z4iOyE5cOW7qA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbgCSIms (ORCPT ); Thu, 19 Mar 2020 04:42:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:56754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgCSImr (ORCPT ); Thu, 19 Mar 2020 04:42:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9125A20724; Thu, 19 Mar 2020 08:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584607367; bh=bc6Fify+38nZAY3Cia1aV1OdCk4gn2q4y8vjHO0jHQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tziaOs8nF6qC2ZxtPxDt+NdfWpIrzDmvKzsswJgbGZoj8i6PseYVNTHnVQCWhF3l7 BlaCfZEzl2+/751CB3Sz2r9W2tBaPF/Ha6955QYPrXbnsfvJrB3QDPo2+ZfG4d0stK TebhEBXc4YrP7M09KzptbT9OYlt0nFKptulOurBg= Date: Thu, 19 Mar 2020 09:42:44 +0100 From: Greg Kroah-Hartman To: Thomas Gleixner Cc: LKML , Peter Zijlstra , Linus Torvalds , Ingo Molnar , Will Deacon , "Paul E . McKenney" , Joel Fernandes , Steven Rostedt , Randy Dunlap , Arnd Bergmann , Sebastian Andrzej Siewior , Logan Gunthorpe , Kurt Schwemmer , Bjorn Helgaas , linux-pci@vger.kernel.org, Felipe Balbi , linux-usb@vger.kernel.org, Kalle Valo , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Oleg Nesterov , Davidlohr Bueso , Michael Ellerman , linuxppc-dev@lists.ozlabs.org Subject: Re: [patch V2 11/15] completion: Use simple wait queues Message-ID: <20200319084244.GC3492783@kroah.com> References: <20200318204302.693307984@linutronix.de> <20200318204408.521507446@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200318204408.521507446@linutronix.de> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, Mar 18, 2020 at 09:43:13PM +0100, Thomas Gleixner wrote: > From: Thomas Gleixner > > completion uses a wait_queue_head_t to enqueue waiters. > > wait_queue_head_t contains a spinlock_t to protect the list of waiters > which excludes it from being used in truly atomic context on a PREEMPT_RT > enabled kernel. > > The spinlock in the wait queue head cannot be replaced by a raw_spinlock > because: > > - wait queues can have custom wakeup callbacks, which acquire other > spinlock_t locks and have potentially long execution times > > - wake_up() walks an unbounded number of list entries during the wake up > and may wake an unbounded number of waiters. > > For simplicity and performance reasons complete() should be usable on > PREEMPT_RT enabled kernels. > > completions do not use custom wakeup callbacks and are usually single > waiter, except for a few corner cases. > > Replace the wait queue in the completion with a simple wait queue (swait), > which uses a raw_spinlock_t for protecting the waiter list and therefore is > safe to use inside truly atomic regions on PREEMPT_RT. > > There is no semantical or functional change: > > - completions use the exclusive wait mode which is what swait provides > > - complete() wakes one exclusive waiter > > - complete_all() wakes all waiters while holding the lock which protects > the wait queue against newly incoming waiters. The conversion to swait > preserves this behaviour. > > complete_all() might cause unbound latencies with a large number of waiters > being woken at once, but most complete_all() usage sites are either in > testing or initialization code or have only a really small number of > concurrent waiters which for now does not cause a latency problem. Keep it > simple for now. > > The fixup of the warning check in the USB gadget driver is just a straight > forward conversion of the lockless waiter check from one waitqueue type to > the other. > > Signed-off-by: Thomas Gleixner > Cc: Arnd Bergmann > --- > V2: Split out the orinoco and usb gadget parts and amended change log > --- > drivers/usb/gadget/function/f_fs.c | 2 +- > include/linux/completion.h | 8 ++++---- > kernel/sched/completion.c | 36 +++++++++++++++++++----------------- > 3 files changed, 24 insertions(+), 22 deletions(-) For USB portion: Reviewed-by: Greg Kroah-Hartman From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4879C4332B for ; Thu, 19 Mar 2020 08:46:02 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 853A92072D for ; Thu, 19 Mar 2020 08:46:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="tziaOs8n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 853A92072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48jgVJ35MNzDrKd for ; Thu, 19 Mar 2020 19:46:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=tziaOs8n; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48jgQd0LKNzDrCC for ; Thu, 19 Mar 2020 19:42:49 +1100 (AEDT) Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9125A20724; Thu, 19 Mar 2020 08:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584607367; bh=bc6Fify+38nZAY3Cia1aV1OdCk4gn2q4y8vjHO0jHQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tziaOs8nF6qC2ZxtPxDt+NdfWpIrzDmvKzsswJgbGZoj8i6PseYVNTHnVQCWhF3l7 BlaCfZEzl2+/751CB3Sz2r9W2tBaPF/Ha6955QYPrXbnsfvJrB3QDPo2+ZfG4d0stK TebhEBXc4YrP7M09KzptbT9OYlt0nFKptulOurBg= Date: Thu, 19 Mar 2020 09:42:44 +0100 From: Greg Kroah-Hartman To: Thomas Gleixner Subject: Re: [patch V2 11/15] completion: Use simple wait queues Message-ID: <20200319084244.GC3492783@kroah.com> References: <20200318204302.693307984@linutronix.de> <20200318204408.521507446@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200318204408.521507446@linutronix.de> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Randy Dunlap , Peter Zijlstra , linux-pci@vger.kernel.org, Sebastian Andrzej Siewior , Oleg Nesterov , Joel Fernandes , Will Deacon , Ingo Molnar , Davidlohr Bueso , "Paul E . McKenney" , Arnd Bergmann , linuxppc-dev@lists.ozlabs.org, Steven Rostedt , Bjorn Helgaas , Kurt Schwemmer , Kalle Valo , Felipe Balbi , Logan Gunthorpe , linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, LKML , netdev@vger.kernel.org, Linus Torvalds , "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Mar 18, 2020 at 09:43:13PM +0100, Thomas Gleixner wrote: > From: Thomas Gleixner > > completion uses a wait_queue_head_t to enqueue waiters. > > wait_queue_head_t contains a spinlock_t to protect the list of waiters > which excludes it from being used in truly atomic context on a PREEMPT_RT > enabled kernel. > > The spinlock in the wait queue head cannot be replaced by a raw_spinlock > because: > > - wait queues can have custom wakeup callbacks, which acquire other > spinlock_t locks and have potentially long execution times > > - wake_up() walks an unbounded number of list entries during the wake up > and may wake an unbounded number of waiters. > > For simplicity and performance reasons complete() should be usable on > PREEMPT_RT enabled kernels. > > completions do not use custom wakeup callbacks and are usually single > waiter, except for a few corner cases. > > Replace the wait queue in the completion with a simple wait queue (swait), > which uses a raw_spinlock_t for protecting the waiter list and therefore is > safe to use inside truly atomic regions on PREEMPT_RT. > > There is no semantical or functional change: > > - completions use the exclusive wait mode which is what swait provides > > - complete() wakes one exclusive waiter > > - complete_all() wakes all waiters while holding the lock which protects > the wait queue against newly incoming waiters. The conversion to swait > preserves this behaviour. > > complete_all() might cause unbound latencies with a large number of waiters > being woken at once, but most complete_all() usage sites are either in > testing or initialization code or have only a really small number of > concurrent waiters which for now does not cause a latency problem. Keep it > simple for now. > > The fixup of the warning check in the USB gadget driver is just a straight > forward conversion of the lockless waiter check from one waitqueue type to > the other. > > Signed-off-by: Thomas Gleixner > Cc: Arnd Bergmann > --- > V2: Split out the orinoco and usb gadget parts and amended change log > --- > drivers/usb/gadget/function/f_fs.c | 2 +- > include/linux/completion.h | 8 ++++---- > kernel/sched/completion.c | 36 +++++++++++++++++++----------------- > 3 files changed, 24 insertions(+), 22 deletions(-) For USB portion: Reviewed-by: Greg Kroah-Hartman