Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp39603ybl; Wed, 22 Jan 2020 15:39:35 -0800 (PST) X-Google-Smtp-Source: APXvYqySXRs812VNQKiRNOTdKZhk/VAsZt93xmAYQx0oy0K8Qny1W4fsIBov6quJ3BLelhLXXWss X-Received: by 2002:a05:6830:4a7:: with SMTP id l7mr8720887otd.372.1579736375767; Wed, 22 Jan 2020 15:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579736375; cv=none; d=google.com; s=arc-20160816; b=kTO9Y+BFzsk7Bhx10e2Lqi03uk/W7MMW6h4cpIQBk4aGChalIHdfmEQ0a5n6zhFaT9 /3x68npHJ/uogQpRR6kPbyilv/FYiWv1Aj6icu06VSiMYXmzH1tLcWZ3QhlaLwkqH8g/ wIEcg0/QZz0szOAeqRaGk0TS8SVbynrRK8oUaM247Cv03Ay4VS1U+em0oQXYfH8/idA7 On8viMAuKY6qqrG3QSOijRFr+tftrQjB94sIUXfILaPsJQ7Q90QEVmfEANT5WH9U4yts 6OZCi/rFX60Bj2qPa+NgYe5tzZT0bC5Z0jac7ncqty0EB7bJNOWf0GuID9Neu9QSoyh5 QIQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=zm9wDTJ1b31ssLU+dPbg1rdas3LQGWG0K1x6D8VCEyU=; b=DpDxLEFwfYxOVlcAuu1Fpj8ulnBEQMbSmRat5iDO5XQULNzlm2iFPc24l1q1p7zqNg L7OZ8JXUgFOm+gJc0OESR/SqlDB9aB/CldjrgSkhv3vhiusYpIi5lk98DPtCKGGFnZDi 41jH7FjEyv2w5w5NsEnlDLByymlk1nCivkofdmZdAXu13nrW9/cviOYa+7U/t6puRApu dMKRnGGzI4h31giKGiMTXCMR2j/BnnWoOFNA3hFBzsCBkkvXpQP2kwAXEwEI02ZXPhyP DYsUkAu0kB2g8ysFOlZZyehr3XKVY5m9+KG2CrcX2vg2hppdAqsDopZhSlN+sC0knBm1 EN7w== ARC-Authentication-Results: i=1; mx.google.com; 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 16si178306otu.77.2020.01.22.15.39.19; Wed, 22 Jan 2020 15:39:35 -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; 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 S1726605AbgAVXhl (ORCPT + 99 others); Wed, 22 Jan 2020 18:37:41 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:38871 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgAVXhl (ORCPT ); Wed, 22 Jan 2020 18:37:41 -0500 Received: from p5b06da22.dip0.t-ipconnect.de ([91.6.218.34] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iuPZ0-0007OT-0Q; Thu, 23 Jan 2020 00:37:34 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 3688610029B; Thu, 23 Jan 2020 00:37:33 +0100 (CET) From: Thomas Gleixner To: Evan Green , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, LKML , Marc Zyngier , Christoph Hellwig , Rajat Jain Subject: Re: [PATCH] PCI/MSI: Avoid torn updates to MSI pairs In-Reply-To: References: <20200116133102.1.I9c7e72144ef639cc135ea33ef332852a6b33730f@changeid> <20200122172816.GA139285@google.com> Date: Thu, 23 Jan 2020 00:37:33 +0100 Message-ID: <875zh3ukoy.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Evan Green writes: > On Wed, Jan 22, 2020 at 9:28 AM Bjorn Helgaas wrote: >> I suspect this *is* a problem because I think disabling MSI doesn't >> disable interrupts; it just means the device will interrupt using INTx >> instead of MSI. And the driver is probably not prepared to handle >> INTx. >> >> PCIe r5.0, sec 7.7.1.2, seems relevant: "If MSI and MSI-X are both >> disabled, the Function requests servicing using INTx interrupts (if >> supported)." Disabling MSI is not an option. Masking yes, but MSI does not have mandatory masking. We already attempt masking on migration, which covers only MSI-X reliably, but not all MSI incarnations. So I assume that problem happens on a MSI interrupt, right? >> Maybe the IRQ guys have ideas about how to solve this? Maybe :) > But don't we already do this in __pci_restore_msi_state(): > pci_intx_for_msi(dev, 0); > pci_msi_set_enable(dev, 0); > arch_restore_msi_irqs(dev); > > I'd think if there were a chance for a line-based interrupt to get in > and wedge itself, it would already be happening there. That's a completely different beast. It's used when resetting a device and for other stuff like virt state migration. That's not a model for affinity changes of a live device. > One other way you could avoid torn MSI writes would be to ensure that > if you migrate IRQs across cores, you keep the same x86 vector number. > That way the address portion would be updated, and data doesn't > change, so there's no window. But that may not actually be feasible. That's not possible simply because the x86 vector space is limited. If we would have to guarantee that then we'd end up with a max of ~220 interrupts per system. Sufficient for your notebook, but the big iron people would be not amused. The real critical path here is the CPU hotplug path. For regular migration between two online CPUs we use the 'migrate when the irq is actually serviced ' mechanism. That might have the same issue on misdesigned devices which are firing the next interrupt before the one on the flight is serviced, but I haven't seen any reports with that symptom yet. But before I dig deeper into this, please provide the output of 'lscpci -vvv' and 'cat /proc/interrupts' Thanks, tglx