From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E972DC77B61 for ; Mon, 10 Apr 2023 10:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbjDJKFp (ORCPT ); Mon, 10 Apr 2023 06:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbjDJKFn (ORCPT ); Mon, 10 Apr 2023 06:05:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8976A2689 for ; Mon, 10 Apr 2023 03:05:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 27BAE6113B for ; Mon, 10 Apr 2023 10:05:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8920EC433D2; Mon, 10 Apr 2023 10:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681121141; bh=yg/6ohJ9ybqKo4SE90fS8mlHGZ56eLcDV/sK9yonlc4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AIKn0eOAnQSuQFZhM1472t/1QJ6yKWbmCNyIB6aaGdpw0lopq0QZPZivZWKoqFGit 2q44Ypypmj5wU9Ifg49UXV2/HtnimJHDe/hk2jMVjSDdCq5mCKwqEowCpHGecnbux3 N+uYegM2zpRwVbNMLbYxzE0VBxJeHiNwmoWjRyfiZr3iB+neXxi5un5LUeAO7pjvbr kY7I2ZOJUBHKDV1AhrpXC1FI8rm43Ho/CuR9yOERsY0NzCr8JwT2j8DvQrE61u9hUZ yPPE04VDfO5WfKH/O8VrsRAfY4bKx+0Jt+e8L2RWtfT5BslTiBWShW6UQeHt7j1USa eXXpcuHLYyrIQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ploP5-007GSt-AL; Mon, 10 Apr 2023 11:05:39 +0100 Date: Mon, 10 Apr 2023 11:05:36 +0100 Message-ID: <87fs9859xr.wl-maz@kernel.org> From: Marc Zyngier To: Shanker Donthineni Cc: Thomas Gleixner , Sebastian Andrzej Siewior , Michael Walle , linux-kernel@vger.kernel.org, Vikram Sethi , "Liam R . Howlett" Subject: Re: [PATCH v2 1/3] genirq: Use hlist for managing resend handlers In-Reply-To: <76bc7b50-d47f-e5a7-6aa6-54a7b1492ea3@nvidia.com> References: <20230408171526.3059039-1-sdonthineni@nvidia.com> <20230408171526.3059039-2-sdonthineni@nvidia.com> <863559mne0.wl-maz@kernel.org> <76bc7b50-d47f-e5a7-6aa6-54a7b1492ea3@nvidia.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: sdonthineni@nvidia.com, tglx@linutronix.de, bigeasy@linutronix.de, michael@walle.cc, linux-kernel@vger.kernel.org, vsethi@nvidia.com, Liam.Howlett@oracle.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 09 Apr 2023 13:00:27 +0100, Shanker Donthineni wrote: > > >> @@ -30,18 +31,17 @@ static DECLARE_BITMAP(irqs_resend, IRQ_BITMAP_BITS); > >> static void resend_irqs(struct tasklet_struct *unused) > >> { > >> struct irq_desc *desc; > >> - int irq; > >> - > >> - while (!bitmap_empty(irqs_resend, nr_irqs)) { > >> - irq = find_first_bit(irqs_resend, nr_irqs); > >> - clear_bit(irq, irqs_resend); > >> - desc = irq_to_desc(irq); > >> - if (!desc) > >> - continue; > >> - local_irq_disable(); > >> + > >> + raw_spin_lock_irq(&irq_resend_lock); > >> + while (!hlist_empty(&irq_resend_list)) { > >> + desc = hlist_entry(irq_resend_list.first, struct irq_desc, > >> + resend_node); > >> + hlist_del_init(&desc->resend_node); > >> + raw_spin_unlock(&irq_resend_lock); > >> desc->handle_irq(desc); > >> - local_irq_enable(); > >> + raw_spin_lock(&irq_resend_lock); > > > > What makes it safe to drop the local_irq_*able()? > > > > tasklet_action_common() explicitly enables interrupts when calling the > > callback, so unless there is some other interrupt disabling that I > > can't immediately spot, the handler may run in the wrong context. > > > > Unless I am overlooking something, interrupts are disabled within the while > loop unless desc->handle_irq() is enabling it. The existing code disables > and enables interrupts for each handler invocation, whereas the modified > code does it only once for all outstanding handlers. Ah, you use raw_spinlock_irq() outside of the loop. I somehow glanced over that, apologies for the noise. Unless we expect a really long list of interrupts to be resent, your current code should be OK. Thanks, M. -- Without deviation from the norm, progress is not possible.