Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4305360ybi; Tue, 18 Jun 2019 15:47:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTGT2Bf2rzGUNmoUJsiXaRVy8hSPGaeo4xpXSn0b6NQKKeTtN9/z9URaa4eeQZ3nx0PI+b X-Received: by 2002:a17:902:aa8a:: with SMTP id d10mr79396451plr.159.1560898040397; Tue, 18 Jun 2019 15:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560898040; cv=none; d=google.com; s=arc-20160816; b=s2LD8dbkh7CD5XwAyvVKiVLxCfjME8yw5WlM5PtHu8mTvXEwak+aP88BJA4AvIq1DP SA0A3l2DgK+FQVASjnvvQmkrcrRG4MNwKBj+q2XsNXCZTHrZXhBwt6sRB+J44KJbuXNt lOZ2zgffqamuqU/6rxHk2RNQaDdRoGF0GXbpZGJVbQ+xXNNYu6R2dMg2WQ1M8wCjP9sd WUjiLi4lYzIOQMlegrgHI7Q5hgcPSGgndlzcFsfAuGeK8WWSTNGZnjSUv0liu36iQSCc A/L6qFD2lvr+FeaM0CON17d48XfyCMb+BL/xrr5P20ZbSf2JidMZO7Cvdsg7pgiks2Pu yXVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8diAArJt01EXvGJzxLk3OytllZ6thd3sJow8nuPGeMY=; b=ZunInnAqI7NfenIF9JsmG2lzbZDV+Hc/JP3ctyccXF9U+Xf3ywc5sCICrpyNC2If9x PJKAepZx3o0ruE0NGDjnS4D3MvzWRtWZrPrgRNSoNefRW4BtcG8L1Cg6cxfdl6jKER68 BRcQOehGwKNWf4ngDWkg8ih6pFLxFt6aXG3BElTfN1ovwuUFBEY+N+ELLmb9PWxVuMKH +xyI9U0YVQ5nTfDee/g2yqj5qRFT07OlE9AeYVGeCifqGCV9tIRoM9eFSrikCaJNoai5 0lquHV6viwJFFajOcX1+68DuMaPmNvohgQrahjf9i0viZizo7vsK+4IEOm9+RoF4l3Vl jrMw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si14054999pfh.256.2019.06.18.15.47.03; Tue, 18 Jun 2019 15:47:20 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730782AbfFRWpl (ORCPT + 99 others); Tue, 18 Jun 2019 18:45:41 -0400 Received: from mga11.intel.com ([192.55.52.93]:12786 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730176AbfFRWpl (ORCPT ); Tue, 18 Jun 2019 18:45:41 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2019 15:45:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,390,1557212400"; d="scan'208";a="358421836" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga006.fm.intel.com with ESMTP; 18 Jun 2019 15:45:40 -0700 Date: Tue, 18 Jun 2019 15:45:19 -0700 From: Ricardo Neri To: Thomas Gleixner Cc: Ingo Molnar , Borislav Petkov , Ashok Raj , Joerg Roedel , Andi Kleen , Peter Zijlstra , Suravee Suthikulpanit , Stephane Eranian , "Ravi V. Shankar" , Randy Dunlap , x86@kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ricardo Neri , Tony Luck , Jacob Pan , Juergen Gross , Bjorn Helgaas , Wincy Van , Kate Stewart , Philippe Ombredanne , "Eric W. Biederman" , Baoquan He , Jan Kiszka , Lu Baolu Subject: Re: [RFC PATCH v4 20/21] iommu/vt-d: hpet: Reserve an interrupt remampping table entry for watchdog Message-ID: <20190618224519.GA30488@ranerica-svr.sc.intel.com> References: <1558660583-28561-1-git-send-email-ricardo.neri-calderon@linux.intel.com> <1558660583-28561-21-git-send-email-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 10:25:35AM +0200, Thomas Gleixner wrote: > On Sun, 16 Jun 2019, Thomas Gleixner wrote: > > On Thu, 23 May 2019, Ricardo Neri wrote: > > > When the hardlockup detector is enabled, the function > > > hld_hpet_intremapactivate_irq() activates the recently created entry > > > in the interrupt remapping table via the modify_irte() functions. While > > > doing this, it specifies which CPU the interrupt must target via its APIC > > > ID. This function can be called every time the destination iD of the > > > interrupt needs to be updated; there is no need to allocate or remove > > > entries in the interrupt remapping table. > > > > Brilliant. > > > > > +int hld_hpet_intremap_activate_irq(struct hpet_hld_data *hdata) > > > +{ > > > + u32 destid = apic->calc_dest_apicid(hdata->handling_cpu); > > > + struct intel_ir_data *data; > > > + > > > + data = (struct intel_ir_data *)hdata->intremap_data; > > > + data->irte_entry.dest_id = IRTE_DEST(destid); > > > + return modify_irte(&data->irq_2_iommu, &data->irte_entry); > > > > This calls modify_irte() which does at the very beginning: > > > > raw_spin_lock_irqsave(&irq_2_ir_lock, flags); > > > > How is that supposed to work from NMI context? Not to talk about the > > other spinlocks which are taken in the subsequent call chain. > > > > You cannot call in any of that code from NMI context. > > > > The only reason why this never deadlocked in your testing is that nothing > > else touched that particular iommu where the HPET hangs off concurrently. > > > > But that's just pure luck and not design. > > And just for the record. I warned you about that problem during the review > of an earlier version and told you to talk to IOMMU folks whether there is > a way to update the entry w/o running into that lock problem. I think I misunderstood your feedback. You did mention issues on locking between NMI and !NMI contexts. However, that was in the context of using the generic irq code to do things such as set the affinity of the interrupt and requesting an irq. I understood that I should instead program things directly. I extrapolated this to the IOMMU driver in which I also added code directly instead of using the existing layering. Also, at the time, the question regarding the IOMMU, as I understood, was whether it was posible to reserve a IOMMU remapping entry upfront. I believe my patches achieve that, even if they are hacky and ugly, and have locking issues. I see now that the locking issues are also part of the IOMMU discussion. Perhaps that was also implicit. > > Can you tell my why am I actually reviewing patches and spending time on > this when the result is ignored anyway? Yes, Thomas, I should have checked first with the IOMMU maintainers first on the issues in the paragraph above. It is not my intention to waste your time; your feedback has been valuable and has contributed to improve the code. > > I also tried to figure out why you went away from the IPI broadcast > design. The only information I found is: > > Changes vs. v1: > > * Brought back the round-robin mechanism proposed in v1 (this time not > using the interrupt subsystem). This also requires to compute > expiration times as in v1 (Andi Kleen, Stephane Eranian). > > Great that there is no trace of any mail from Andi or Stephane about this > on LKML. There is no problem with talking offlist about this stuff, but > then you should at least provide a rationale for those who were not part of > the private conversation. Stephane has already commented the rationale. Thanks and BR, Ricardo