Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp448901ybb; Fri, 20 Mar 2020 02:03:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv++FBujAm3gjTzjsf4VjezwS8wd9lPPHG8GZr44K/wSULweHqf92TC1RpU/alBjyHgFmfS X-Received: by 2002:a05:6808:9bb:: with SMTP id e27mr5462159oig.36.1584694996638; Fri, 20 Mar 2020 02:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584694996; cv=none; d=google.com; s=arc-20160816; b=H7HtYa5gUjo4pWpn5ChR4nwU/38HdWo/hG15cIGKNENO2BgeLAA66a3/u3PAM/x1nP VTQUN5QiUORwHsXdvtLNyE1lBS3dDvzhXIgcXTD1VqV9aaSwH/U1cD6hVW3VyoKw9KyE zyQMtDffUJYzf1Vw4b+KfMcncSBjGsrhiIBClSv2+nbZJHk53i8zWewNEW8jhyH6mg2S Ly5MQZOKD8p2CfflNUarrhirtvSjknezMsa9Ik+EobM4V6NwrR87vAXavk597ZrJ+dBT aHbK2OKjvuCzAh8A/bY1IllSrfortYiVDZh6cu7oAfSoHdl+zObXeTmQnG/MHR4A2Chx FRSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=V3EQ3w6a14n82UUXcBAmfmJWLyS0ruJYM6V8G6Gx1Bc=; b=wu2Gf8o/bE8pEg5kd8Wc8r7QbG9lR/MVLlgfJJS2WXQTWyBJ68tmshXZICV03DGFUh X4iJ3low2IwCoWsfzyXHg0vyuBxmpR3wKGkq+dFc3H8eopSFIgr87OHrLN7NU/1v8Rpg 0YZWbjVf0JPiyLjtfQAapwy23JtKJwf0CaDpLVuTuyJFrCODKCEjfgVWB8c68pLkfTvo huOaxhywFZVIpOE47Vg4mfjx42VSrnMnANOZkL+pgn0IQagOhyjjTFVbGu9jyEKlQAd8 IeegB4qOm+ETwI4nVeXzAaF8VjAu+SIfnTqfZfJmN5lO14wCG1wdYev74axTQicfBtcF 5uIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 97si2476307oth.209.2020.03.20.02.03.05; Fri, 20 Mar 2020 02:03:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgCTJCO (ORCPT + 99 others); Fri, 20 Mar 2020 05:02:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:45570 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbgCTJCO (ORCPT ); Fri, 20 Mar 2020 05:02:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 60CA0AECE; Fri, 20 Mar 2020 09:02:12 +0000 (UTC) Date: Fri, 20 Mar 2020 02:01:06 -0700 From: Davidlohr Bueso 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 , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Kalle Valo , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Oleg Nesterov , Michael Ellerman , linuxppc-dev@lists.ozlabs.org Subject: Re: [patch V2 11/15] completion: Use simple wait queues Message-ID: <20200320090106.6p2lwqvs4jedhvds@linux-p48b> References: <20200318204302.693307984@linutronix.de> <20200318204408.521507446@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200318204408.521507446@linutronix.de> User-Agent: NeoMutt/20180716 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, 18 Mar 2020, 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 Reviewed-by: Davidlohr Bueso