Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp398646ybg; Thu, 19 Mar 2020 01:43:33 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt+x9BSE3ZmL1S4VfECnEn8re41W1vca3Uh8rzU59XjCfTMhzpynac1YcK+nu4vfWK94UQw X-Received: by 2002:a9d:734f:: with SMTP id l15mr1440977otk.55.1584607413742; Thu, 19 Mar 2020 01:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584607413; cv=none; d=google.com; s=arc-20160816; b=vBtHISmWPgBliKJjPSmqKPlOdghHVJq7RJzXL7/wfTgIteZWiaGsbFQKJTFLS5lslt Gau074wASwD8avPjJTeNxnbGfjXkRKnXxR2qzewWhw7qnbo+s0Gn36Pm/gTlyL5jTVIo kG45WMLGGR4LA3Zy+K8MI/zrfzfY6Nge0sjj1JVVthMVf5uylQCRQu7o5AVqOk2IgOG/ fjwvpcACq6SzMobByPAeHmTfWceBkAOPT0vOH7zMN3QR5phqS0RyfHLIhuOrB5NcDXhX JosHfceeRdstPgWDBvfAlWFFiReF7lC9tPFKiacTw7tDCohBrRBXS3FJNBjQlD2jMbzP z2CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8XHATQ6dLljxZApGziB8LDfvuhhC+oHwfokeJGCc7ms=; b=zJRy7Ggb69efKAAPbp3VArRMUKyPer5kFK+jNFuqSvTn5gpp9kTwCuTFO6VK9kVA+A DbBSRqoUtf/UuhOCrWz3Lag3by9du6eAY6fQyqTb414tEz6687NmZ4ZK+LNO7utbGwYE u5OzTfndCZCFQlDEjDmuYdu7aydB2OmJs1YVGlvd+jh3cTGr7VxuSerMKgG7mozbnMtM 0nHaKg+d9TicU6Ktwt1eiX+tf4fvMpre5Wt9S9iL+qL/8bJJhPDh4sQV/8JPMU579dK9 esZRzR8XWxHNsFrM6Ii9F9/7tGp4nLbPHUWwteS45lVJeycNv758E7qlXfUWmxWEL9sp 4dKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tziaOs8n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l25si983846otk.119.2020.03.19.01.43.21; Thu, 19 Mar 2020 01:43:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tziaOs8n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgCSIms (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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