Received: by 10.223.185.111 with SMTP id b44csp314680wrg; Fri, 9 Mar 2018 05:31:04 -0800 (PST) X-Google-Smtp-Source: AG47ELuWRidi6Ku2CJD5roqQi+HHXSJUk5v742elHDJwqAxqnmcf/fFKR36WsApSa0HwRa7GDh4/ X-Received: by 10.99.168.75 with SMTP id i11mr24043765pgp.420.1520602264667; Fri, 09 Mar 2018 05:31:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520602264; cv=none; d=google.com; s=arc-20160816; b=0Yt52XZZT60s76SDvhirEML3W8SG+Vsmc5EDBPwX4eAO/M56t1WmjIrONTnwTomNS1 d2rxM1Jz04l9tR469sKiawdCQcKI+QE6VWudhH469O6HyvnI05qF0iniC0raDOZQ/7tP mOR1txrucdWOOiF+V41NUsP91Folb02WCH5GPSWRspexbhh07spu1xcbKK4zYH7K7vxM 4bO4HeAQaZcuPwQZjkEuLwU0tM9ja0zWvoDUpp/MIsw/L/NQQl/129Osr1gbSzN5bSd9 q+uadBNBGjpBpCXL3NBh3wBkZshd56eo5KLVVQzcNK3s1TFH+li43feKs5Cpca5MQq0j sxrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=gK8C4u1vQ2KryBo4WtMkS9Pi5fj0Hh/xma+GK16i6Yk=; b=0OKA8mKZw0BKDax88FID5Ue2At8V9GAC96gL89oNTq+sCsIQXV9713uPQmDnzkCD6o kE4nX5QRj6xpcO1Kw/zaCKrnVweEq2AMrgRKNk1eAFmmFXi34W1BJpMV388C+tsqFFDM J9jEF8B4MkY5xmwYn+bRxeat2AjgRMy0S4jkChf/V7WwXqBdL3kVb1wa7nAjXdg0YVhh SpHSHBuXaZwiJFReGZcDXBn9iN8lVdcqBFIbhxCdXK1FGTVrKx6ZlMXCuXadGcDuicC7 g/LzQcjCo+S3dM7PIzZN720GaRocb8uyAQ4wNjUrDx/oPrTPuMHydG0YwJ8hBuv2qzRL StlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mvista-com.20150623.gappssmtp.com header.s=20150623 header.b=tluwklp8; 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 j62si732171pgd.404.2018.03.09.05.30.50; Fri, 09 Mar 2018 05:31:04 -0800 (PST) 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=@mvista-com.20150623.gappssmtp.com header.s=20150623 header.b=tluwklp8; 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 S932110AbeCIN3g (ORCPT + 99 others); Fri, 9 Mar 2018 08:29:36 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:32983 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbeCIN3d (ORCPT ); Fri, 9 Mar 2018 08:29:33 -0500 Received: by mail-ot0-f196.google.com with SMTP id y11so8670678otg.0 for ; Fri, 09 Mar 2018 05:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=gK8C4u1vQ2KryBo4WtMkS9Pi5fj0Hh/xma+GK16i6Yk=; b=tluwklp83QU0OnzsT0NUzKcMa8cH22GG0YdobpvSjKA6ykIJHEarm8iAtSveUWZYZq i41D2gauHojQ/N4Wvm6ZjMVuRlk/2EwEBDFLK328WXjWCMaiT+kACkQzFdlAX4c92i4r fQF5WFT4ZGmD8+mJ3MmLJb160A7zQe2nmll0WmRA6VSVMTEBr/cAfQVctAE+LHcqZuV0 1eUKRZaqAIRESIn0J4G3FlpMpmLQ+jNAEs21zxbvfSJ+ZQrlyvhpHs26BBVcCDpc7SuD /FTJuRmZFz8tKSO4HfcAwfAWyf1hdf7uGvdEl0BflLj1dtj44cMGJxSOr+V6gnrNa2KT Njhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=gK8C4u1vQ2KryBo4WtMkS9Pi5fj0Hh/xma+GK16i6Yk=; b=IdJ0ZTKsoNEOsyZ4waolzltCHFkwMR03X3XXBmMngUWp6B11CCGvMFnzBT4kDwhLo7 hljcX0bhmoxlq/sr2QaB7Fr/Hy1CqUzXozK98EkFuerxmQk4UsWq9+UmEvvdISENrnci ZsZw977zrV/AEtR6Uyo1TaGpYe5IRYwkvVadEYIzFPBqKtc628fixmjojmr6Cb67PNL7 CbtKB2i5w2oVPOvgQV7YZp3ztQCpsll+Z6fZbk6nVgoOc7Ox885M4JKiKxm6XshV4joB tgJE+U2CFEk2WWeEQ4LDBmZ+kIyzrn1IlivWxqgvJv6X9U5qDNOJWQBIMh/U3tTt6sre 8DnQ== X-Gm-Message-State: AElRT7HUYyQjgH5mlCGhwv8HrdRwBMwrKjIap4AV0YkQsU8UAzIWuZkY XJ014fwb9WluZssoZX4CeSGjxA== X-Received: by 10.157.28.158 with SMTP id l30mr2695528ota.18.1520602172888; Fri, 09 Mar 2018 05:29:32 -0800 (PST) Received: from [192.168.27.3] ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id r184sm394817oib.39.2018.03.09.05.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 05:29:32 -0800 (PST) Subject: Re: Warning from swake_up_all in 4.14.15-rt13 non-RT To: Sebastian Andrzej Siewior , Peter Zijlstra , Thomas Gleixner , Steven Rostedt Cc: linux-rt-users , linux-kernel , Tejun Heo References: <20180306174604.nta5rcvfvrfdfftz@linutronix.de> <1704d817-8fb9-ce8f-1aa1-fe6e8b0c3919@mvista.com> <20180308174103.mduy5qq2ttlcvig3@linutronix.de> <20180309110418.lwtennjqwqcxh422@linutronix.de> From: Corey Minyard Message-ID: <08aa9f8a-afe5-e1d3-5301-d196beb665b5@mvista.com> Date: Fri, 9 Mar 2018 07:29:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180309110418.lwtennjqwqcxh422@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/2018 05:04 AM, Sebastian Andrzej Siewior wrote: > On 2018-03-08 13:54:17 [-0600], Corey Minyard wrote: >>> It will work but I don't think pushing this into workqueue/tasklet is a >>> good idea. You want to wakeup all waiters on waitqueue X (probably one >>> waiter) and instead there is one one wakeup + ctx-switch which does the >>> final wakeup. >> True, but this is an uncommon and already fairly expensive operation being >> done.  Adding a context switch doesn't seem that bad. > still no need to make it more expensive if it can be avoided. > >>> But now I had an idea: swake_up_all() could iterate over list and >>> instead performing wakes it would just wake_q_add() the tasks. Drop the >>> lock and then wake_up_q(). So in case there is wakeup pending and the >>> task removed itself from the list then the task may observe a spurious >>> wakeup. >> That sounds promising, but where does wake_up_q() get called?  No matter >> what >> it's an expensive operation and I'm not sure where you would put it in this >> case. > Look at this: > ... > > void swake_up(struct swait_queue_head *q) > { > @@ -66,25 +62,14 @@ EXPORT_SYMBOL(swake_up); > */ > void swake_up_all(struct swait_queue_head *q) > { > - struct swait_queue *curr; > - LIST_HEAD(tmp); > + unsigned long flags; > + DEFINE_WAKE_Q(wq); > > - WARN_ON(irqs_disabled()); > - raw_spin_lock_irq(&q->lock); > - list_splice_init(&q->task_list, &tmp); > - while (!list_empty(&tmp)) { > - curr = list_first_entry(&tmp, typeof(*curr), task_list); > + raw_spin_lock_irqsave(&q->lock, flags); > + swake_add_all_wq(q, &wq); > + raw_spin_unlock_irqrestore(&q->lock, flags); > > - wake_up_state(curr->task, TASK_NORMAL); > - list_del_init(&curr->task_list); > - > - if (list_empty(&tmp)) > - break; > - > - raw_spin_unlock_irq(&q->lock); > - raw_spin_lock_irq(&q->lock); > - } > - raw_spin_unlock_irq(&q->lock); > + wake_up_q(&wq); From what I can tell, wake_up_q() is unbounded, and you have undone what the previous code had tried to accomplish.  In the scenario I'm talking about, interrupts are still disabled here.  That's why I was asking about where to put wake_up_q(), I knew you could put it here, but it didn't seem to me to help at all. > } > EXPORT_SYMBOL(swake_up_all); > > >> I had another idea.  This is only occurring if RT is not enabled, because >> with >> RT all the irq disable things go away and you are generally running in task >> context.  So why not have a different version of swake_up_all() for non-RT >> that does work from irqs-off context? > With the patch above I have puzzle part which would allow to use swait > based completions upstream. That ifdef would probably not help. I agree that having a bounded time way to wake up a bunch of threads while interrupts are disabled would solve a bunch of issues.  I just don't see how it can be done without pushing it off to a softirq or workqueue. -corey >> -corey > Sebastian