Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp427207iob; Tue, 3 May 2022 01:09:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMWTFeTIxy3/7k5lnnFnVl/u/B7auVmcnEqPNNF0fzJLKptqVqWtTJxW8qYvaeB9P5vEM2 X-Received: by 2002:a17:90b:4a90:b0:1dc:4122:6a70 with SMTP id lp16-20020a17090b4a9000b001dc41226a70mr3407058pjb.216.1651565345427; Tue, 03 May 2022 01:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651565345; cv=none; d=google.com; s=arc-20160816; b=GN0+CBAeS3QFX+aLqBMsmmTF5oZnkPoKR6aIo/4On0DNW0V1qQGXwqtbcJazU7XY39 9hcGXroZZ8Fi5n4pj6BT+onk9BJP1aYJD3xqJCR4kaLndfNjJ4W2mYXRayx/YG6dhlIl ed+mIjm1KeZ5ylzAfyqAHpPML9bdjiScqXHbr6mW3zyiBW+RHH2TuIrn7TKhDP72EEmA 2juhBg42yTZQRXPCbGc6huZ6QgiwbfTvWZzCSbY7mNioyD6vT/A+yYfAHsf3SrlgP2OA 8uEBxn4gl7tyTe3OPWLV3FZHejjgBPcdxjnQC01qh2nWkAYJ2V4sKE57JZd4qyibE3ot NkJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=sM1sh48qqqqNeZqSw1JKDfgm3vgNzqP52k4toCR21aY=; b=pwtNloSnCVMwNYOyqKVbgq2k0ki/SrU5/+RXCA92Hh1Gu2ImX+d5MgiFfSouASAPCu Hjl7LS9qGUtrJDiOtWwr2Zvn6NhoAvPZ1uHOwoApEp2u6yLywR8tpZW/RYLTNY8y3nHh atWpSF2VgSZ5cf96Sng7RIQZCf3nIBhdcDhFjV6GPlLfDDDwat6vP+jDNed+x0xK0uHB Tq/WpNlY8FvMasMC5ptY0dyQ6GXx1oBC0SYO2DEeuVF5tl73+ZyXHv3CE4vNPj2YCEEq sFMpUSgjCw0AkG3pYkve6yiAGgu43hZKOdZgFlhk+l6v4aFJmV1bevHZX23AfB0jUZkT E2tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kWu1KPiy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="VXGZ/V1x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056a00230d00b0050608866df1si17188411pfh.109.2022.05.03.01.08.50; Tue, 03 May 2022 01:09:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kWu1KPiy; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="VXGZ/V1x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231993AbiECHlk (ORCPT + 99 others); Tue, 3 May 2022 03:41:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbiECHlj (ORCPT ); Tue, 3 May 2022 03:41:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E9302CCA4 for ; Tue, 3 May 2022 00:38:04 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651563482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sM1sh48qqqqNeZqSw1JKDfgm3vgNzqP52k4toCR21aY=; b=kWu1KPiybkLj18Tfkypw8dueA/yObmYYIiP6sePLG/ZnCSqDfSriCHGK0CqDCSeFuBjgwd HHIPB/w0qH6mk7SLHQMK9AWev7vCyTQvJp5Zwdor0CRpbXbEH9xcyPiwFNjtyFrgYIzdrU CpGVAaGgCUHGkzKqC+0XKRW2snZQA2aEcQediFaUsD19AjhsaBr4PK0ahUdRy+am1XoSGD LRXNAx1t9NQbBLGfsY7dyxAn2qMRjO+Vkbf/fML7toCERZ/m6TUrqjQGEA0P2epyMm/63i DNByPw2KAnFHVe06j5Zqy6BvGhJCZ0MzC02GrD98vc7KY1MIGt/sXIgiic83og== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651563482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sM1sh48qqqqNeZqSw1JKDfgm3vgNzqP52k4toCR21aY=; b=VXGZ/V1xK1lI8LFeOqZFwMi+o4aQXfs5FbMnA3mDv34LarcY7zOKtr5GDSBSdGEie7fCp/ qNhNcA5X6yhv0tCg== To: Hillf Danton Cc: Thomas Pfaff , linux-kernel@vger.kernel.org, Marc Zyngier Subject: Re: [PATCH v3] irq/core: synchronize irq_thread startup In-Reply-To: <20220503004209.4670-1-hdanton@sina.com> References: <552fe7b4-9224-b183-bb87-a8f36d335690@pcs.com> <20220502160106.4587-1-hdanton@sina.com> <20220503004209.4670-1-hdanton@sina.com> Date: Tue, 03 May 2022 09:38:01 +0200 Message-ID: <87pmkvkqw6.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hillf, On Tue, May 03 2022 at 08:42, Hillf Danton wrote: > On Mon, 02 May 2022 21:24:45 +0200 Thomas Gleixner wrote: >> On Tue, May 03 2022 at 00:01, Hillf Danton wrote: >> > + if (!waked) >> > + wake_threads_waitq(desc); >> >> That's a guarantee to make desc->threads_active go negative in the case >> that the thread was never woken by a hard interrupt handler. IOW, you >> created a new problem which did not exist before. > > The count of active threads would not drop below zero with the change, > given the comment in __irq_wake_thread(). It is incremented before > wakeup. There is no guarantee that the wake-up happens via __irq_wake_thread(). kthread_stop() does a wake-up too, but that obviously _cannot_ increment the active counter because it does not know about it at all. create_thread() thread_fn() woken = false; wait_for_wakeup_or_stop() <- Stop is set, no interrupt happened <- ergo woken == false if (!woken) wake_threads_waitq(desc) atomic_dec_and_test(..) <- underflow >> The problem discussed here is not a problem in irq_thread(), it's a >> problem of not reaching this function in the first place. See the on >> point analysis in Thomas Pfaffs patch. > > Well why is the count above zero without wakeup? IOW why is there imbalance > in count if the irq thread never gets a CPU to run? Look at kthread() and the condition under which threadfn() is invoked. Thanks, tglx