Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp4054602pxy; Tue, 4 May 2021 16:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/TDlSBky2HePC1e1pNuIpkBkHLsJCxkZNFvZ3dx3jK0QKka+slnFu4JDqKlHaorGEdnR7 X-Received: by 2002:a17:903:31c3:b029:ed:6f74:49c7 with SMTP id v3-20020a17090331c3b02900ed6f7449c7mr27643449ple.12.1620172704765; Tue, 04 May 2021 16:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620172704; cv=none; d=google.com; s=arc-20160816; b=dwQ+20WJw8a8h8w3kgWasW8j+tKP2IQBhQiSaeeDIOVc/ndNRu9c0xsZueuVd6QMbV EEkGhRJMPV62ruIaAX/H+JCwmP6CGtZZPl2kf9qMwokuijBtGPQcL5FZryhlaVk7mZaq XXpsOFxBC1zB6U6fkBR9mTKhcIrsS2UvGq+jxMTVDeJHp3mC7hqSiJ74bDJwch1GraOa 9QuN0XZbYCEzgdSNFkZRE+FJ+c/U0/QBVFh3lDLhqGJOoLNCttthw41OIhpHy9NTqy6A FJBvOcBB6L7gAGjvJliCf0ZZ4eQKF16orwtAFSYlnhCQAJ7TYieZNLmxxL/x0bZ20XGX NNKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=Ll/PI4F/FVWkSEpqvRhq/+/IfArUdPCmgxQCahW3Q3M=; b=q1zA3o2Vy/hc3PUn6PrJ1w1HetKwUTwmbNtLhBqYfZwjjzn40EcWlMkKZudpQlGGtU oSr8WesmPqpreCM77MjUdAWwU7OQfO87aazMmAyqSvKHoSuf1YTE5VvOlMntCHIJysmi iE9GDA1h3+wRqu3HSS2DFMAANy9JazySJNh9FPWKg79Gg2kV+FcBYCjQ5UH9g/22/mgP yV9aK3cm6yY7WmoZ1/hroDLodorG/zW/bnseF4TG1lAtghRtrsJLlULXI4682lfiiSdY 9IX03FV5MefJY/8wGnbvjxyeVeJrwjyqDV3EAojNZs55yqzXTfcBdLe19g5KznBk+8XA keDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bA7TtUpy; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 130si4910982pga.231.2021.05.04.16.58.08; Tue, 04 May 2021 16:58:24 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bA7TtUpy; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhEDXEP (ORCPT + 99 others); Tue, 4 May 2021 19:04:15 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56644 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbhEDXEP (ORCPT ); Tue, 4 May 2021 19:04:15 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1620169399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ll/PI4F/FVWkSEpqvRhq/+/IfArUdPCmgxQCahW3Q3M=; b=bA7TtUpy/VkWS1LYnlQ8VPaObfNtx7ewqZbJgB5Tg6hFjPki3RG1ZAEV24kBg5QP5vTFR6 qbabswYvNGCQlIas1dckpYV9HQ+awsOR5m+D4b7wL+CxS4F4pEoBTkjd66/JXo9iswdkVi uaMq9PckdldwUYtmKnN+eqslJALyoM77mFCq3+sN0f96cFl+Lsh6ZgOrgXH4JPRwLX/fw+ N/upsUArXqTsu669S4r+mfxIhBez18YqekBzal9/gLz5Gjsy7AOmyPOGEQf6mogqetKdmq ISKjbIsBXOZ/8/6cXGcnw0JVnDm6n15FWi11mo30tb4mP/i/NNvzbLJgvuIa+w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1620169399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ll/PI4F/FVWkSEpqvRhq/+/IfArUdPCmgxQCahW3Q3M=; b=ZOtoHv13IU/mSywRedzAxnTRdphnFF8B7Do7UiUO4rjVFd53PtqHXsYUbJzGN3lnENbXiG zj5CY/++GeQ1rzAg== To: Ricardo Neri , Joerg Roedel , Will Deacon Cc: "woodhouse\, Jacob Pan" , Lu Baolu , Stephane Eranian , Ingo Molnar , Borislav Petkov , iommu@lists.linux-foundation.org, x86@kernel.org, linux-kernel@vger.kernel.org, "Ravi V. Shankar" , Ricardo Neri , Ricardo Neri , Andi Kleen , David Woodhouse Subject: Re: [RFC PATCH v5 5/7] iommu/vt-d: Fixup delivery mode of the HPET hardlockup interrupt In-Reply-To: <20210504191049.22661-6-ricardo.neri-calderon@linux.intel.com> References: <20210504191049.22661-1-ricardo.neri-calderon@linux.intel.com> <20210504191049.22661-6-ricardo.neri-calderon@linux.intel.com> Date: Wed, 05 May 2021 01:03:18 +0200 Message-ID: <87lf8uhzk9.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 04 2021 at 12:10, Ricardo Neri wrote: > In x86 there is not an IRQF_NMI flag that can be used to indicate the There exists no IRQF_NMI flag at all. No architecture provides that. > delivery mode when requesting an interrupt (via request_irq()). Thus, > there is no way for the interrupt remapping driver to know and set > the delivery mode. There is no support for this today. So what? > Hence, when allocating an interrupt, check if such interrupt belongs to > the HPET hardlockup detector and fixup the delivery mode accordingly. What? > + /* > + * If we find the HPET hardlockup detector irq, fixup the > + * delivery mode. > + */ > + if (is_hpet_irq_hardlockup_detector(info)) > + irq_cfg->delivery_mode = APIC_DELIVERY_MODE_NMI; Again. We are not sticking some random device checks into that code. It's wrong and I explained it to you before. https://lore.kernel.org/lkml/alpine.DEB.2.21.1906161042080.1760@nanos.tec.linutronix.de/ But I'm happy to repeat it again: "No. This is horrible hackery violating all the layering which we carefully put into place to avoid exactly this kind of sprinkling conditionals into all code pathes. With some thought the existing irqdomain hierarchy can be used to achieve the same thing without tons of extra functions and conditionals." So the outcome of thought and using the irqdomain hierarchy is: Replacing an hpet specific conditional in one place with an hpet specific conditional in a different place. Impressive. hpet_assign_irq(...., bool nmi) init_info(info) ... if (nmi) info.flags |= X86_IRQ_ALLOC_AS_NMI; irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, &info) intel_irq_remapping_alloc(..., info) irq_domain_alloc_irq_parents(..., info) x86_vector_alloc_irqs(..., info) { if (info->flags & X86_IRQ_ALLOC_AS_NMI && nr_irqs != 1) return -EINVAL; for (i = 0; i < nr_irqs; i++) { .... if (info->flags & X86_IRQ_ALLOC_AS_NMI) { irq_cfg_setup_nmi(apicd); continue; } ... } irq_cfg_setup_nmi() sets irq_cfg->delivery_mode and whatever is required and everything else just works. Of course this needs a few other minor tweaks but none of those introduces random hpet quirks all over the place. Not convoluted enough, right? But that solves none of other problems. Let me summarize again which options or non-options we have: 1) Selective IPIs from NMI context cannot work As explained in the other thread. 2) Shorthand IPI allbutself from NMI This should work, but that obviously does not take the watchdog cpumask into account. Also this only works when IPI shorthand mode is enabled. See apic_smt_update() for details. 3) Sending the IPIs from irq_work This would solve the problem, but if the CPU which is the NMI target is really stuck in an interrupt disabled region then the IPIs won't be sent. OTOH, if that's the case then the CPU which was processing the NMI will continue to be stuck until the next NMI hits which will detect that the CPU is stuck which is a good enough reason to send a shorthand IPI to all CPUs ignoring the watchdog cpumask. Same limitation vs. shorthand mode as #2 4) Changing affinity of the HPET NMI from NMI As we established two years ago that cannot work with interrupt remapping 5) Changing affinity of the HPET NMI from irq_work Same issues as #3 Anything else than #2 is just causing more problems than it solves, but surely the NOHZ_FULL/isolation people might have opinions on this. OTOH, as this is opt-in, anything which wants a watchdog mask which is not the full online set, has to accept that HPET has these restrictions. And that's exactly what I suggested two years ago: https://lore.kernel.org/lkml/alpine.DEB.2.21.1906172343120.1963@nanos.tec.linutronix.de/ "It definitely would be worthwhile to experiment with that. if we could use shorthands (also for regular IPIs) that would be a great improvement in general and would nicely solve that NMI issue. Beware of the dragons though." As a consequence of this conversation I implemented shorthand IPIs... But I haven't seen any mentioning that this has been tried, why the approach was not chosen or any discussion about that matter. Not that I'm surprised. Thanks, tglx