Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp908809ybl; Thu, 23 Jan 2020 09:57:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxUzqgOqVllKXDl76mDThctb5P1CBjJoX5H+plJBZm64fXWDc9RMvgbFPrQC58rOJJtFZXp X-Received: by 2002:a9d:7315:: with SMTP id e21mr12835035otk.255.1579802271823; Thu, 23 Jan 2020 09:57:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579802271; cv=none; d=google.com; s=arc-20160816; b=yg0rnJoqhyp3sRnKLUA2yEEOUtZvUlNo8YaOh1FAcz1D57qBz3fi0QmUzoZDtvMsgY Fk6eUN0M+P78vBoGIYgqWhI/zrubXm9HQLP+yh66Zc0ZqHtwv3X0KUygqbyRoCazGySU WPrBnrD5UsoByqcTQ8vi63AEGD00mgrOmFnVDMJw06eUYzxyWN10pgX4sJ1Tjq+mkwX6 yFUTMV2dvmeEPG8fUKQ+isAjWDhtwN1ZfczebxbnMXoBlReYWiuWhXKNAnnA/g+6hbRL batq4i4sSdSAt6sDLU/YLFwKmvE67gl7zoZTtqZQTYuNajp6nI7YdLV654geNR5+V6p6 zLgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=tbUt6go+kLuXKXQ0VzJ6Mhyl0zSlPzgGsNDFNiXJt7g=; b=Ko1eXeO71+TZiUUrEO884k9Wg2DCTD9zsC9dCVAfF8udadv3BSDx4lkwVNnDlYXXRZ GbEskEfZLlVELYFZWEGMWYOwfzlF+3YOy3H+/q1RIdUg/soUN+Orxluwt8peQ0/ONJw4 3YHypstEkK93AnSHum6w//MdaKnuf/gh6GzS39JfVKsB+Dm4yBI7+WLoDs+cuzfazCRj 2C2hZkQ94ihhWgQ6YRi+UTeZvkBr+TDU9k0Vw5FLaUkKZ6tLCORCRJPO0cWM5KcZmlvj MHKVZ6Ub9OLC7RkALBjtel7cYl51BdAOCoKz0/YkCmYvBTaAkniO7oGQrAxHUirv3J+3 j8kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NK4+dXDp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14si1466616oto.46.2020.01.23.09.57.39; Thu, 23 Jan 2020 09:57:51 -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; dkim=pass header.i=@chromium.org header.s=google header.b=NK4+dXDp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbgAWR4V (ORCPT + 99 others); Thu, 23 Jan 2020 12:56:21 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36454 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgAWR4U (ORCPT ); Thu, 23 Jan 2020 12:56:20 -0500 Received: by mail-lf1-f66.google.com with SMTP id f24so3020159lfh.3 for ; Thu, 23 Jan 2020 09:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tbUt6go+kLuXKXQ0VzJ6Mhyl0zSlPzgGsNDFNiXJt7g=; b=NK4+dXDpNBbzPh3b80IEDt5inscQTCvjYG7+GPJ5WUbiU+W/8YhHNLVwGhxs57FIS4 fK7JN1NswFF2h0zIXnkR7Xk+qgzuLlEZVN6S32B+6w20Ygvnm09GYcbJgAJZKjeKpTGc 792wHEdxRwurEfdqWJVhjVFcefHoQJugA+IyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tbUt6go+kLuXKXQ0VzJ6Mhyl0zSlPzgGsNDFNiXJt7g=; b=HbBeZ38yXuWPElfNaRsPw/ss1YAxZ8OFrF/zRSB/lZ/nCFpRyWdRIRz49ngNZGPMlh /dUJgEBAaxot/fuvF0auK80+3KXQwQ/8z76ukW4QAMCfv6lFTbFPjcsSI/2pXD0LjnsK G1kmoCZnWm/+nMgYaOwqqdKpFXWFIkkDp9ZB3b3TD8E7PAikdWdFRKbHN3aZajEHgo90 vhPJlTcDOZnNGDIcRuavw67+FPCz5VByyxa/PttbEFQ+0S85YVFRyWEHLFBNaUgM4OI8 KXGrZnYAXrdt6s5rDWt9hvS9RT3+5axvPkRUqixuMKb5Z64VeVU3UQxLpiWzwVVRwNOk NeFA== X-Gm-Message-State: APjAAAUd+l0KZ+CdAFVY2K/F3hloV1zapUbWizEZc4qMxyKgbDR0vvvv Zj9/LQdHcjpA1FPeRAfHiiDrC0nlLlg= X-Received: by 2002:ac2:44bc:: with SMTP id c28mr4749572lfm.72.1579802177333; Thu, 23 Jan 2020 09:56:17 -0800 (PST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com. [209.85.208.174]) by smtp.gmail.com with ESMTPSA id x10sm79734ljd.68.2020.01.23.09.56.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jan 2020 09:56:16 -0800 (PST) Received: by mail-lj1-f174.google.com with SMTP id o13so4582551ljg.4 for ; Thu, 23 Jan 2020 09:56:16 -0800 (PST) X-Received: by 2002:a2e:b017:: with SMTP id y23mr24733117ljk.229.1579802175831; Thu, 23 Jan 2020 09:56:15 -0800 (PST) MIME-Version: 1.0 References: <20200116133102.1.I9c7e72144ef639cc135ea33ef332852a6b33730f@changeid> <20200122172816.GA139285@google.com> <875zh3ukoy.fsf@nanos.tec.linutronix.de> <871rrqva0t.fsf@nanos.tec.linutronix.de> In-Reply-To: <871rrqva0t.fsf@nanos.tec.linutronix.de> From: Evan Green Date: Thu, 23 Jan 2020 09:55:39 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] PCI/MSI: Avoid torn updates to MSI pairs To: Thomas Gleixner Cc: Bjorn Helgaas , linux-pci , LKML , Marc Zyngier , Christoph Hellwig , Rajat Jain Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 23, 2020 at 12:42 AM Thomas Gleixner wrote: > > Evan Green writes: > > On Wed, Jan 22, 2020 at 3:37 PM Thomas Gleixner wrote: > >> > 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. > > > > Right, that occurred to me as well. The actual requirement isn't quite > > as restrictive. What you really need is the old vector to be > > registered on both the old CPU and the new CPU. Then once the > > interrupt is confirmed to have moved we could release both the old > > vector both CPUs, leaving only the new vector on the new CPU. > > Sure, and how can you guarantee that without reserving the vector on all > CPUs in the first place? If you don't do that then if the vector is not > available affinity setting would fail every so often and it would pretty > much prevent hotplug if a to be migrated vector is not available on at > least one online CPU. > > > In that world some SMP affinity transitions might fail, which is a > > bummer. To avoid that, you could first migrate to a vector that's > > available on both the source and destination CPUs, keeping affinity > > the same. Then change affinity in a separate step. > > Good luck with doing that at the end of the hotplug routine where the > CPU is about to vanish. > > > Or alternatively, you could permanently designate a "transit" vector. > > If an interrupt fires on this vector, then we call all ISRs currently > > in transit between CPUs. You might end up calling ISRs that didn't > > actually need service, but at least that's better than missing edges. > > I don't think we need that. While walking the dogs I thought about > invoking a force migrated interrupt on the target CPU, but haven't > thought it through yet. Yeah, I think the Intel folks did that in some tree of theirs too. > > >> 'lscpci -vvv' and 'cat /proc/interrupts' > > > > Here it is: > > https://pastebin.com/YyxBUvQ2 > > Hrm: > > Capabilities: [80] MSI-X: Enable+ Count=16 Masked- > > So this is weird. We mask it before moving it, so the tear issue should > not happen on MSI-X. So the tearing might be just a red herring. Mmm... sorry what? This is the complete entry for xhci: 00:14.0 USB controller: Intel Corporation Device 02ed (prog-if 30 [XHCI]) Subsystem: Intel Corporation Device 7270 Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+ Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- SERR- Kernel driver in use: xhci_hcd > > Let me stare into the code a bit. Thanks, I appreciate the help. -Evan