Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2237789pxu; Sun, 13 Dec 2020 18:52:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwq0EpFee8THBo4RYhH1ovjdG040qxW7GqLQU/7hmbiNGMrK7zbWQH2nO9cTNLK1V2YEPq9 X-Received: by 2002:a17:906:8693:: with SMTP id g19mr21645630ejx.111.1607914326479; Sun, 13 Dec 2020 18:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607914326; cv=none; d=google.com; s=arc-20160816; b=EZqZPSqMzbLnnlmNU5o6lt/hAEAbp80yFtDrBtWdKO/ZEF3PLcQLRRpGt1AWpIJk+D ZHOoEOvBdR+aY0u3vjJrwsKDYxqaZfhHN8+KjM3jC0rvM3zgG27U0ob6rrypY+Z3iOL+ 6nlRDOOq0NBKVLAVEUq6bbkm3njQG1vGOaRKiSHPizSOpu/Uncn3tDJqM5h1RIeDv1fv jE+D9gTKp33IkwcU7/f0vdOaET6b8ZyC9IyGDRkTBbY+uWLsL1UskcsGewKSep+5qzPQ Jqsqg7gXH8uoTTN86UiUBaUA/eRWWeuoKRcHOOfY5cuynrzgsMJwqy7RlQ9DFtaodUr9 kGTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=94qT6t4PVJZBCD9E9scwjeDACrnmOHeXXj0Va5eef6k=; b=QWVD0N/pwxirH9XQ9tC41e/k7cqS8p3LcHf1bR6HvB3IbXZavw/QKRHen48D7H6BYO UI0a9I6cuYLi1sPNWYZcW5TuYgVA+DPoci8ZlJZI5fQ8ZDyPEo8C/cRXL6XANSdXvjUz Vx7Wm2HNqphhslpd4YcCCLZtrP+AO0V5ZZznvSQc4eas8SsRTAX39NWRpnLnfX6m5JDn 8cGCqdjBm9AcIkHcAGHTX29X+k+EiUbST3BX9C57h2RxS7L4zyPxKQOuEo+IcVr3R/79 vBn41FSQBIyqI7pr8s4XVgA/aCwAIcA5mEXxQRbMF4ncqGV2GNH5XJRwcUaVV/JmEgw8 WNkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tTvobONu; dkim=neutral (no key) header.i=@linutronix.de header.b="hEP/3qw9"; 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 u13si9696192edv.186.2020.12.13.18.51.32; Sun, 13 Dec 2020 18:52:06 -0800 (PST) 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=tTvobONu; dkim=neutral (no key) header.i=@linutronix.de header.b="hEP/3qw9"; 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 S2438911AbgLLM7u (ORCPT + 99 others); Sat, 12 Dec 2020 07:59:50 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:41204 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438889AbgLLM71 (ORCPT ); Sat, 12 Dec 2020 07:59:27 -0500 Date: Sat, 12 Dec 2020 12:58:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607777915; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94qT6t4PVJZBCD9E9scwjeDACrnmOHeXXj0Va5eef6k=; b=tTvobONus1/7CRO0lQiE3j3nC9hreDj1wW82t3T8SfqWgsuKZn7ua69/c/2iKsTFlmtQxp PlhTwCZgwz1x7iyx8D4adLd/suSZ2BrAT73AmLfkph+T46mDSWbF1CE+23wREjDJyENBgy jQvB8V+T3k+pPPgYztZ6SBUH290evjLC0t4rAakNyWG57PLGiOdCPaF/RsU65ye3PmK4Kt YLfVSX6DFJpHu+bZT/9C8Hni2j3m6QSm7CtzQF6hRcXi0wSYxszLUlB7t5mwhEwrGVKu+4 R6x0a3g2XL9pfdwAgKOy93nUObvFFdjbiKFZI8bUf+UOTfndcsHYEQLkmDLICw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607777915; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94qT6t4PVJZBCD9E9scwjeDACrnmOHeXXj0Va5eef6k=; b=hEP/3qw9h3g+x1+ng/ONii6J2eZCmhodghphZUaEbU/IfBNmfjn1zxp/Dmd0OlclLpNCsn q8VwDdek5EWKzQBg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] xen/events: Only force affinity mask for percpu interrupts Cc: Thomas Gleixner , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20201210194045.250321315@linutronix.de> References: <20201210194045.250321315@linutronix.de> MIME-Version: 1.0 Message-ID: <160777791504.3364.5223639342920487711.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: f61b8351facda691f1564097074976b30e987a81 Gitweb: https://git.kernel.org/tip/f61b8351facda691f1564097074976b30e987a81 Author: Thomas Gleixner AuthorDate: Thu, 10 Dec 2020 20:26:03 +01:00 Committer: Thomas Gleixner CommitterDate: Sat, 12 Dec 2020 12:59:06 +01:00 xen/events: Only force affinity mask for percpu interrupts All event channel setups bind the interrupt on CPU0 or the target CPU for percpu interrupts and overwrite the affinity mask with the corresponding cpumask. That does not make sense. The XEN implementation of irqchip::irq_set_affinity() already picks a single target CPU out of the affinity mask and the actual target is stored in the effective CPU mask, so destroying the user chosen affinity mask which might contain more than one CPU is wrong. Change the implementation so that the channel is bound to CPU0 at the XEN level and leave the affinity mask alone. At startup of the interrupt affinity will be assigned out of the affinity mask and the XEN binding will be updated. Only keep the enforcement for real percpu interrupts. On resume the overwrite is not required either because info->cpu and the affinity mask are still the same as at the time of suspend. Same for rebind_evtchn_irq(). This also prepares for proper interrupt spreading. Signed-off-by: Thomas Gleixner Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Link: https://lore.kernel.org/r/20201210194045.250321315@linutronix.de --- drivers/xen/events/events_base.c | 48 +++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index eaba42a..679b2cb 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -433,15 +433,20 @@ static bool pirq_needs_eoi_flag(unsigned irq) return info->u.pirq.flags & PIRQ_NEEDS_EOI; } -static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu) +static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu, + bool force_affinity) { int irq = get_evtchn_to_irq(evtchn); struct irq_info *info = info_for_irq(irq); BUG_ON(irq == -1); -#ifdef CONFIG_SMP - cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu)); -#endif + + if (IS_ENABLED(CONFIG_SMP) && force_affinity) { + cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu)); + cpumask_copy(irq_get_effective_affinity_mask(irq), + cpumask_of(cpu)); + } + xen_evtchn_port_bind_to_cpu(evtchn, cpu, info->cpu); info->cpu = cpu; @@ -788,7 +793,7 @@ static unsigned int __startup_pirq(unsigned int irq) goto err; info->evtchn = evtchn; - bind_evtchn_to_cpu(evtchn, 0); + bind_evtchn_to_cpu(evtchn, 0, false); rc = xen_evtchn_port_setup(evtchn); if (rc) @@ -1107,8 +1112,14 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip) irq = ret; goto out; } - /* New interdomain events are bound to VCPU 0. */ - bind_evtchn_to_cpu(evtchn, 0); + /* + * New interdomain events are initially bound to vCPU0 This + * is required to setup the event channel in the first + * place and also important for UP guests because the + * affinity setting is not invoked on them so nothing would + * bind the channel. + */ + bind_evtchn_to_cpu(evtchn, 0, false); } else { struct irq_info *info = info_for_irq(irq); WARN_ON(info == NULL || info->type != IRQT_EVTCHN); @@ -1156,7 +1167,11 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) irq = ret; goto out; } - bind_evtchn_to_cpu(evtchn, cpu); + /* + * Force the affinity mask to the target CPU so proc shows + * the correct target. + */ + bind_evtchn_to_cpu(evtchn, cpu, true); } else { struct irq_info *info = info_for_irq(irq); WARN_ON(info == NULL || info->type != IRQT_IPI); @@ -1269,7 +1284,11 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) goto out; } - bind_evtchn_to_cpu(evtchn, cpu); + /* + * Force the affinity mask for percpu interrupts so proc + * shows the correct target. + */ + bind_evtchn_to_cpu(evtchn, cpu, percpu); } else { struct irq_info *info = info_for_irq(irq); WARN_ON(info == NULL || info->type != IRQT_VIRQ); @@ -1634,8 +1653,7 @@ void rebind_evtchn_irq(evtchn_port_t evtchn, int irq) mutex_unlock(&irq_mapping_update_lock); - bind_evtchn_to_cpu(evtchn, info->cpu); - irq_set_affinity(irq, cpumask_of(info->cpu)); + bind_evtchn_to_cpu(evtchn, info->cpu, false); /* Unmask the event channel. */ enable_irq(irq); @@ -1669,7 +1687,7 @@ static int xen_rebind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int tcpu) * it, but don't do the xenlinux-level rebind in that case. */ if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) - bind_evtchn_to_cpu(evtchn, tcpu); + bind_evtchn_to_cpu(evtchn, tcpu, false); if (!masked) unmask_evtchn(evtchn); @@ -1798,7 +1816,8 @@ static void restore_cpu_virqs(unsigned int cpu) /* Record the new mapping. */ (void)xen_irq_info_virq_setup(cpu, irq, evtchn, virq); - bind_evtchn_to_cpu(evtchn, cpu); + /* The affinity mask is still valid */ + bind_evtchn_to_cpu(evtchn, cpu, false); } } @@ -1823,7 +1842,8 @@ static void restore_cpu_ipis(unsigned int cpu) /* Record the new mapping. */ (void)xen_irq_info_ipi_setup(cpu, irq, evtchn, ipi); - bind_evtchn_to_cpu(evtchn, cpu); + /* The affinity mask is still valid */ + bind_evtchn_to_cpu(evtchn, cpu, false); } }