Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2140984rwb; Thu, 19 Jan 2023 21:53:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsyTpZ2N53r8Ibd7n2smFP77lQq2riveCkhHCnubpY51+sO97W6jCrS8xEY6sXvfTKXNBs/ X-Received: by 2002:a17:90b:1a88:b0:22a:be:a92f with SMTP id ng8-20020a17090b1a8800b0022a00bea92fmr2202544pjb.14.1674193984855; Thu, 19 Jan 2023 21:53:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674193984; cv=none; d=google.com; s=arc-20160816; b=Vf0M1A/wbMMw6ZXcW7EWWxs3fv25hohFG7Myj+JjbSTiJJVVaniO/j3GEk+qInNT/S AlNAn/laVZ9cz7tYymR98tZ+FIARpBCF6zZPa75F5Yyb9/19h7GnerazAWXYvdU1eNXS DeDGh9GHejCUwkzqAs6LwCDfiZIaNc9GfXqAcoKylnO4hFc1mcQZNySR+UFGRU5niJQH jYJNAoc6aJ99vtbykmnbuZp74uzSgawppmc7ouIQ5nt2M5okYuDIKnYYtkZkdIBKAJkh oukt2B4hiKrvS7VEUEpRvaqUlG1p9ARXfd974LooEyhuL0z+0lm/ReLFD47e2sAp/xlD bjhw== 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:dkim-signature; bh=weCR9klppeXbY3Y1wQl3O4JqK6TIEQ5FIQfa5ZrLUdk=; b=BnRKulHPggPIb6qeRyEQzEojkRcYDj2gwoU8ygwoR9tq10IcnRieyEBF8fqz7VJJL9 HT0qRSEzwDk9EiAnCxZs0JTFrWOdCONLffXvzy3InQBV7A0urbetisdUZTWmU2g4Hug8 cZtvLF/WD4Nj+jkFmLMJ7EqEYyh0kAvOQI5NgQPH2erVt9p3U6j6sOk7nXhFkmI8dp8K NJBsFjyGV2kbWOao9U2yGQx2C/dGK+P+M4ddllZEsqxrC76ljcdelY4kDAOX/SVO2wx8 //DGnPfO1/NmTHqFOZOJ6YzPtBYvE3ZugpmfuoChDju6UpDcW36G0AA1OvR3dnlnTVfW c7IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L1Frc4CL; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a17090a530600b0022b78817fecsi1446519pjh.79.2023.01.19.21.52.59; Thu, 19 Jan 2023 21:53:04 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=L1Frc4CL; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230454AbjATFLT (ORCPT + 47 others); Fri, 20 Jan 2023 00:11:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjATFK4 (ORCPT ); Fri, 20 Jan 2023 00:10:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02E8AC380F for ; Thu, 19 Jan 2023 20:59:05 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 58EE8B82105 for ; Thu, 19 Jan 2023 07:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2A8FC433EF; Thu, 19 Jan 2023 07:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674112342; bh=ppCaKUMocfObxQmoemgltocCkqn+mmzyJALotudKBys=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=L1Frc4CLCNnwEaRoKRcsZSHweWOGCOh8V2cEPqf5hfWfY2bA/5RRZTobxNeRPVVLE 20vWPnnb/olFBOaBKpP6eF2DbJtE3zdBUY/jvOjsWluM9x4pM8S/RfvpMVU+QyUJP+ S8ruxNw8ythX6P1zyg+2MM+StI8NqXJcXL55IVYD8XvW/8CStNH6RzIpkhBsrz0yNa IcRRyhbV12LkGFHova9iXVR0r6ZBMX68f1hlMSCHDjbs7iKweA6KGhcyeV+sV+GIis nCXo1iT6DTWdpbB6eTDHdT5nj8bc7XlNilmXxxsAqiP6kbjJIGzL4hotchmbkQ23Nt A6I9c7agvx5VA== 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 1pIP5w-0030D7-GT; Thu, 19 Jan 2023 07:12:20 +0000 Date: Thu, 19 Jan 2023 07:11:21 +0000 Message-ID: <87bkmvdmna.wl-maz@kernel.org> From: Marc Zyngier To: Shanker Donthineni Cc: James Morse , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Vikram Sethi , Zenghui Yu , Oliver Upton , Suzuki K Poulose , Ard Biesheuvel Subject: Re: [PATCH] KVM: arm64: vgic: Fix soft lockup during VM teardown In-Reply-To: <28061ceb-a7ce-0aca-a97d-8227dcfe6800@nvidia.com> References: <20230118022348.4137094-1-sdonthineni@nvidia.com> <863588njmt.wl-maz@kernel.org> <28061ceb-a7ce-0aca-a97d-8227dcfe6800@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, james.morse@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, vsethi@nvidia.com, yuzenghui@huawei.com, oliver.upton@linux.dev, suzuki.poulose@arm.com, ardb@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 [dropping the now dead old kvmarm list] On Wed, 18 Jan 2023 19:24:01 +0000, Shanker Donthineni wrote: > > > > On 1/18/23 05:54, Marc Zyngier wrote: > > External email: Use caution opening links or attachments > > > > > > Shanker, > > > > Please Cc all the KVM/arm64 reviewers when sending KVM/arm64 patches. > > > > On Wed, 18 Jan 2023 02:23:48 +0000, > > Shanker Donthineni wrote: > >> > >> Getting intermittent CPU soft lockups during the virtual machines > >> teardown on a system with GICv4 features enabled. The function > >> __synchronize_hardirq() has been waiting for IRQD_IRQ_INPROGRESS > >> to be cleared forever as per the current implementation. > >> > >> CPU stuck here for a long time leads to soft lockup: > >> while (irqd_irq_inprogress(&desc->irq_data)) > >> cpu_relax(); > > > > Is it a soft-lockup from which the system recovers? or a livelock > > which leaves the system dead? > > > The system is not recovering, did a power cycle to recover. This isn't a soft-lockup then. This is at best a livelock. > > Are these two traces an indication of concurrent events? Or are they > > far apart? > > > Concurrent. So you can see the VM being torn down while the vgic save sequence is still in progress? If you can actually see that, then this is a much bigger bug than the simple race you are describing, and we're missing a reference on the kvm structure. This would be a *MAJOR* bug. Please post the full traces, not snippets. The absolutely full kernel log, the configuration, what you run, how you run it, *EVERYTHING*. I need to be able to reproduce this. > > >> > >> irqreturn_t handle_irq_event(struct irq_desc *desc) > >> { > >> irqd_set(&desc->irq_data, IRQD_IRQ_INPROGRESS); > >> raw_spin_unlock(&desc->lock); > >> > >> ret = handle_irq_event_percpu(desc); > >> > >> raw_spin_lock(&desc->lock); > >> irqd_clear(&desc->irq_data, IRQD_IRQ_INPROGRESS); > >> } > > > > How is that relevant to this trace? Do you see this function running > > concurrently with the teardown? If it matters here, it must be a VPE > > doorbell, right? But you claim that this is on a GICv4 platform, while > > this would only affect GICv4.1... Or are you using GICv4.1? > > > handle_irq_event() is running concurrently with irq_domain_activate_irq() > which happens before free_irq() called. Corruption at [78.983544] and > teardown started at [87.360891]. But that doesn't match the description you made of concurrent events. Does it take more than 9 seconds for the vgic state to be saved to memory? > > [ 78.983544] irqd_set_activated: lost IRQD_IRQ_INPROGRESS old=0x10401400, new=0x10441600 > > [ 87.360891] __synchronize_hardirq+0x48/0x140 > > Yes, I'm using GICv4.1, used these 2 functions to trace the issue. Then *please* be precise in your descriptions. You send people in the wrong direction. [...] > I ran stress test launch/teardown multiple VMs for 3hrs. The issue > is not reproducible. The same test fails in 10-30min without code > changes. That doesn't add up with the earlier description of concurrent events, with the VM teardown and the vgic saving running in parallel. My patch doesn't prevent this. So either your testing is insufficient, or your description of concurrent events is inaccurate. M. -- Without deviation from the norm, progress is not possible.