Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4030950pxv; Mon, 5 Jul 2021 11:47:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMHc0Osf9mBwCCULcOF8+MkQBtZSZYn5HuHujspqpwVZdCuGuMqaw4f3vn7Bu6nvbSa4ZV X-Received: by 2002:a50:d508:: with SMTP id u8mr18054328edi.223.1625510828405; Mon, 05 Jul 2021 11:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625510828; cv=none; d=google.com; s=arc-20160816; b=AhN8+lBozgGW9Tfa/E3ukTjZEbZoy/nV6FHcAyWMq15n3v0lYTVULNp5O6dipaPK2d 4G6YYHgxnZUA6kcF31H9BB0bJVNrMuGJc9uHJrcVgEZPAftsQOpeyIGUH6mSzVxSZUXt IchezRHXev5JrVFKPIcpBdC/a2M8WE9DVslckIAS019MCZiaWJJyhBzTTSAy0RPUgfi0 kXgNcHcJj/VloSbOjhaB3R8It48H2Cfj3blVQOiGDJn2U+le1EwZc1AIuQTK7D04xvGh AtcBNbBmz3JD3zpPs+VLzxJ/Vv62KjPdhj0sqPy6ofWvQk5hSX5qJEuab9h2aodYcCds UxWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=CnbwJSqqCowIbvwl1McilppruohNoJLmTXF6eD8wKdM=; b=NR6wLIqXEyMYZWVS5Q3LJ3V1KWJ6I9p9pcSD1VWXvr/5U098MYwBwVovAuSKOy00QW pBiTEx4DOy5zVzXXTNjNVAM/cv1mmjx2VqNwGU+iJJi1Z5fap0F8uOrLBsRYqx5EiVnG QKcKdtTvt2we8I7FdRZDGMcC0G5Q75EDwA9/d8DxHTLjfxcnB2ol6jnfe9Us8Y8RwMPd Pm0ceeo3T7XnDKyOvWv2VNYFZfzdcD67vGefwi26pyat3LiuwdSC8OBwTk/mzf7+OWHJ KyjgQeeqiCWjCF+1FwzqtgK4N0NhiUab+4rkw46Cst8FQKGwkKM6dOxqGEIuNmQgUXhR YnuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si11925633ede.189.2021.07.05.11.46.44; Mon, 05 Jul 2021 11:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbhGESqc (ORCPT + 99 others); Mon, 5 Jul 2021 14:46:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbhGESqc (ORCPT ); Mon, 5 Jul 2021 14:46:32 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A0E0613AE; Mon, 5 Jul 2021 18:43:55 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m0TZR-00BZOL-DY; Mon, 05 Jul 2021 19:43:53 +0100 Date: Mon, 05 Jul 2021 19:43:53 +0100 Message-ID: <87fsws8uty.wl-maz@kernel.org> From: Marc Zyngier To: Guenter Roeck Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: Re: [irqchip: irq/irqchip-next] irqdomain: Protect the linear revmap with RCU In-Reply-To: <79ec0069-553b-cac1-5ec7-d68c757619a5@roeck-us.net> References: <162341967699.19906.3242958007782554792.tip-bot2@tip-bot2> <20210705172352.GA56304@roeck-us.net> <87h7h88wsd.wl-maz@kernel.org> <79ec0069-553b-cac1-5ec7-d68c757619a5@roeck-us.net> 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: linux@roeck-us.net, linux-kernel@vger.kernel.org, tglx@linutronix.de 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 Mon, 05 Jul 2021 19:23:27 +0100, Guenter Roeck wrote: > > Hi Marc, > > On 7/5/21 11:01 AM, Marc Zyngier wrote: > > Hi Guenter, > > > > On Mon, 05 Jul 2021 18:23:52 +0100, > > Guenter Roeck wrote: > >> > >> Hi, > >> > >> On Fri, Jun 11, 2021 at 01:54:36PM -0000, irqchip-bot for Marc Zyngier wrote: > >>> The following commit has been merged into the irq/irqchip-next branch of irqchip: > >>> > >>> Commit-ID: d4a45c68dc81f9117ceaff9f058d5fae674181b9 > >>> Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/d4a45c68dc81f9117ceaff9f058d5fae674181b9 > >>> Author: Marc Zyngier > >>> AuthorDate: Mon, 05 Apr 2021 12:57:27 +01:00 > >>> Committer: Marc Zyngier > >>> CommitterDate: Thu, 10 Jun 2021 13:09:18 +01:00 > >>> > >>> irqdomain: Protect the linear revmap with RCU > >>> > >>> It is pretty odd that the radix tree uses RCU while the linear > >>> portion doesn't, leading to potential surprises for the users, > >>> depending on how the irqdomain has been created. > >>> > >>> Fix this by moving the update of the linear revmap under > >>> the mutex, and the lookup under the RCU read-side lock. > >>> > >>> The mutex name is updated to reflect that it doesn't only > >>> cover the radix-tree anymore. > >>> > >>> Signed-off-by: Marc Zyngier > >> > >> This patch results in various RCU warnings when booting mipsel images > >> in qemu. I can not revert the patch due to subsequent changes, so I > >> don't know if a simple revert fixes the problem. Log messages and > >> bisect log see below. > > > > Thanks for the heads up. Do you have a config file I can use to > > reproduce this? The QEMU invocation runes would certainly help too. > > > > It strikes me that in drivers/irqchip/irq-mips-cpu.c, > > plat_irq_dispatch() now uses the irqdomain resolution before > > irq_enter() took place. That's certainly a latent bug. I'll fix that > > regardless, but I'd like to make sure this is what you are seeing too. > > > > See http://server.roeck-us.net/qemu/mipsel/ > > config Complete configuration file > defconfig Shortened configuration file > rootfs.cpio root file system (initrd) > run.sh qemu run script (tested with qemu 4.2.1 and 6.0.0) > vmlinux Kernel image experiencing the problem (v5.13-9883-gaf9efb8b661) > > Hope this helps, It definitely helps, and confirms my hunch. With the patch below, I'm not getting the warnings anymore. I'm pretty sure a number of other MIPS systems suffer from similar issues, which I'll address similarly. Please let me know if that addresses the issue on your end. Thanks, M. diff --git a/arch/mips/include/asm/irq.h b/arch/mips/include/asm/irq.h index d1477ecb1af9..57561e0e6e8d 100644 --- a/arch/mips/include/asm/irq.h +++ b/arch/mips/include/asm/irq.h @@ -57,6 +57,9 @@ asmlinkage void plat_irq_dispatch(void); extern void do_IRQ(unsigned int irq); +struct irq_domain; +extern void do_domain_IRQ(struct irq_domain *domain, unsigned int irq); + extern void arch_init_irq(void); extern void spurious_interrupt(void); diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index 85b6c60f285d..c76005cd3b79 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -107,3 +108,16 @@ void __irq_entry do_IRQ(unsigned int irq) irq_exit(); } +void __irq_entry do_domain_IRQ(struct irq_domain *domain, unsigned int hwirq) +{ + struct irq_desc *desc; + + irq_enter(); + check_stack_overflow(); + + desc = irq_resolve_mapping(domain, hwirq); + if (likely(desc)) + handle_irq_desc(desc); + + irq_exit(); +} diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 0bbb0b2d0dd5..0c7ae71a0af0 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c @@ -127,7 +127,6 @@ static struct irq_chip mips_mt_cpu_irq_controller = { asmlinkage void __weak plat_irq_dispatch(void) { unsigned long pending = read_c0_cause() & read_c0_status() & ST0_IM; - unsigned int virq; int irq; if (!pending) { @@ -137,12 +136,15 @@ asmlinkage void __weak plat_irq_dispatch(void) pending >>= CAUSEB_IP; while (pending) { + struct irq_domain *d; + irq = fls(pending) - 1; if (IS_ENABLED(CONFIG_GENERIC_IRQ_IPI) && irq < 2) - virq = irq_linear_revmap(ipi_domain, irq); + d = ipi_domain; else - virq = irq_linear_revmap(irq_domain, irq); - do_IRQ(virq); + d = irq_domain; + + do_domain_IRQ(d, irq); pending &= ~BIT(irq); } } -- Without deviation from the norm, progress is not possible.