Received: by 10.213.65.16 with SMTP id m16csp285082imf; Mon, 12 Mar 2018 03:52:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELtAysV0WkOstgW7RSvsBb99DCGBtRS6OHHJ8Nx+TlrjrXEBGqrdxmtI7QnLFCalhTTabzq8 X-Received: by 2002:a17:902:5609:: with SMTP id h9-v6mr7709068pli.302.1520851948010; Mon, 12 Mar 2018 03:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520851947; cv=none; d=google.com; s=arc-20160816; b=U0utRXXUb8TAx+yy6Rg+yDvOyShENXM7an6YHgo3uwkAYZegrnYk5G3y/mCptNSStb hSsAJdGi+NtNNVYWOgC78ghUbEgY/de6Wg8JO/wtnWFvpG1i+oPB5DQBrgatqAzTTIH5 cOPMxrXRKeu+IvIcD/F0gnrTN+IXeQ9O97qRf5ZPcGXiG4OpKsn/e5v+kJR8D7w8Z/mM M2LZ+SXCqam3VrUi8E4MSXm+cc1r0SLsKL30v5HYI/rREcTbr3BjcARPDwn8Ql0eG339 Ox9iUC9crSsIlBDYa3Nt9cfmerOarTaEycgCbCGbedrMpZ/3J0HjKL3qSPwAPwMr1wxA KbrA== 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:arc-authentication-results; bh=oXWnj/q2nqMy1aGtcmQ+mgoSJ7zphz8NX778zQWH8UY=; b=NBOOsnuQ8rTWl51C096kTFfvBxHuGxBty0C2t7TSJ4dSZDL4jTZr5B68IG6sUfsQK3 BWfygK/L7WHS5uJJUutioNMtSnC58BR0tk+uA6bs3bLzeiWRPC83sY1Zrs6d7jxD9+dK Gs9JK4uggw5fqq3FeRTPKm1Dp4K4ACVh0zSwJJqBa2SOMN0CZiykLciMtnBH5r6P6qs8 H1Z5axrecC4BPbiXDT/xJDnXfgoKD7xIIMCJi3Wgqc87+Vi942AD18bmnlgKcP5hIbuP jHogAPlACNqaPrqWOTWi6BRPAQjiV+QDM0PtVhd3aaWlKYM98GKHAx/AJa8PD678DP/q FZrg== ARC-Authentication-Results: i=1; mx.google.com; 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 n25si2939854pgc.87.2018.03.12.03.52.12; Mon, 12 Mar 2018 03:52:27 -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; 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 S1751255AbeCLKvU (ORCPT + 99 others); Mon, 12 Mar 2018 06:51:20 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45824 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbeCLKvT (ORCPT ); Mon, 12 Mar 2018 06:51:19 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1evL2v-00046C-PJ; Mon, 12 Mar 2018 11:51:13 +0100 Date: Mon, 12 Mar 2018 11:51:13 +0100 From: Sebastian Andrzej Siewior To: Peter Zijlstra Cc: Corey Minyard , Thomas Gleixner , Steven Rostedt , linux-rt-users , linux-kernel , Tejun Heo Subject: Re: Warning from swake_up_all in 4.14.15-rt13 non-RT Message-ID: <20180312105113.p7jifhwdwbhpvxds@linutronix.de> References: <20180306174604.nta5rcvfvrfdfftz@linutronix.de> <1704d817-8fb9-ce8f-1aa1-fe6e8b0c3919@mvista.com> <20180308174103.mduy5qq2ttlcvig3@linutronix.de> <20180309110418.lwtennjqwqcxh422@linutronix.de> <20180309174605.GC4064@hirez.programming.kicks-ass.net> <20180309202550.j66qphz3txupt55u@linutronix.de> <20180309222643.GC5926@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180309222643.GC5926@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-03-09 23:26:43 [+0100], Peter Zijlstra wrote: > On Fri, Mar 09, 2018 at 09:25:50PM +0100, Sebastian Andrzej Siewior wrote: > > Is it just about the irqsave() usage or something else? I doubt it is > > the list walk. It is still unbound if not called from irq-off region. > > The current list walk is preemptible. You put the entire iteration (of > unbound length) inside a single critical section which destroy RT. I considered that list walk as cheap. We don't do any wake ups with the list walk - just mark the task for a later wake up. But if it is not I could add an upper limit of 20 iterations or so. > > But it is now possible, I agree. The wake_q usage should be cheaper > > compared to IRQ off+on in each loop. And we wanted to do the wake ups > > with enabled interrupts - there is still the list_splice() from that > > attempt. Now it can be. > > Unbound is still unbound, inf/n := inf. A 'cheaper' unbound doesn't RT > make. What I meant is that wake_q() is invoked with interrupts enabled and we don't need the IRQ on/off on each iteration. But as I said in the upper paragraph, I can add an upper limit for the list walk. And wake up itself is with enabled interrupts. > > > Yes, wake_up_all() is crap, it is also fundamentally incompatible with > > > in-*irq usage. Nothing to be done about that. > > I still have (or need) completions which are swait based and do > > complete_all(). > > That's fine, as long as they're done from preemptible context. Back when > we introduced swait this was an explicit design goal/limitation. And > there were no in-irq users of this. Yes at that time in !RT. wake_up() is using sleeping locks on RT and swait is the only thing that can be used there. So if I don't get rid if that !preemptible part I try to switch to swait. > > There are complete_all() caller which wake more than one > > waiter (that is PM and crypto from the reports I got once I added the > > WARN_ON())). > > The in-IRQ usage is !RT only and was there before. > > Then that's broken and needs to be undone. Also, why did you need the > WARN, lockdep should've equally triggered on this, no? I added WARN_ON() and I didn't even think about lockdep. I wanted to see a warning even with lockdep off. After adding this for testing: { raw_spin_lock_irq(&lock1); raw_spin_unlock_irq(&lock1); raw_spin_lock_irq(&lock2); raw_spin_unlock_irq(&lock2); raw_spin_lock_irq(&lock1); raw_spin_lock_irq(&lock2); raw_spin_unlock_irq(&lock2); raw_spin_unlock_irq(&lock1); raw_spin_lock_irq(&lock2); raw_spin_lock_irq(&lock1); raw_spin_unlock_irq(&lock1); raw_spin_unlock_irq(&lock2); } I see only one complaint about the lock order in the last block. With that one gone there is no complain about the second block. So no, lockdep does not report such things (this was just tested on RT and TIP). > > > So NAK on this. > > So I need completions to be swait based and do complete_all() from IRQ > > (on !RT, not RT). I have this one call which breaks the usage on !RT and > > has wake_up_all() in it in vanilla which needs an swait equivalent since > > it calls its callback from an rcu-sched section. > > Why isn't this a problem on RT? So we remain in the preempt_disable() section due to RCU-sched so we have this, yes. But the "disabled interrupts" part is due to spin_lock_irqsave() which is a non-issue on RT. So if we managed to get rid of the rcu-sched then the swait can go and we can stick with the wake_up_all() on RT, too. Sebastian