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 B76EAC4332B for ; Thu, 19 Mar 2020 08:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 869182072C for ; Thu, 19 Mar 2020 08:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584607368; bh=bc6Fify+38nZAY3Cia1aV1OdCk4gn2q4y8vjHO0jHQs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=XBlLJbYppdvt5KgsWK/bWQS5c48pZdscRvexQ6ecDMu4fN9diJQGDvcU1dP9DQmhy AGoTHz99/8VtrxAd1mQAcihAKuyn/Z3RcYhUC0micjJodB7GHI5pK/qVC+bVTKcgMM dOtPRxQ683Jkau2sGSEjh1+PGr9Fu75uIPaofbuM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725767AbgCSIms (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-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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