Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp782576pxu; Fri, 11 Dec 2020 14:20:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+i1yhK4dYOYjKBPZUOqs6XhZF/VJMGAFP099xNRaihOquTSsZ9nuw51yDYmX+IpThTF3X X-Received: by 2002:a50:d6d3:: with SMTP id l19mr14523514edj.376.1607725244804; Fri, 11 Dec 2020 14:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607725244; cv=none; d=google.com; s=arc-20160816; b=Zs1FAdxoJlQDiH17ZvOBi4MJq2iOiTSv7vgixkm3wSXRilqdHllsP1hphzs1WCsCrj yvQABeRooSlgbT0E0coukZ+iyeL7jGMjMEOv//WwHA2/WjqJA8iamiaCAoS1cgg6c7Jb WeuQKr6XK7/06pGBtxIxFjY8pn5j7HM2dPa/JMaYI+rxcggrnH/ESVRztjXgmL4Dxx7Y Lkm/uLGJbxT8/CeEbAGkfASDKvquu7Zun4lSLvn6pO6IHVUmxMFrjjLXA7PhAEDZ8Bgw FZw5EoODJ4HmHRaqvq3VSoxa9xH+Ab+lWTbwI+fXmxQM3vSi6nQVvKf/Gg2BNuTPUFyY T8GA== 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=VGmPq1i3ayrpyyrVWVoevEjU3QrxYsIort8NEoox4yg=; b=eTincLkSE8NK9lvBskUWN1Rqiiu97xdFN2SH5EwLazMZKXPpNTU7EO4V784SDCL/5X ZpJy1DeA3AoFjI4uuP0YR3aELOWQX0UfbbCKod6wxXZf1ZOIdXS2sFmojO096+RvlFfe 8wjSU47SUJWUsHVb1eW/J+DcZ7c0xbl/CyXFktciWPTP1bHlWZgo6Ulg0GeR8I1q6k6f 4DBzyajwJViB6frMhmZHdrC7pVLZe8UE79cc5FrKf/t2CMHgYgjri5V9JHh2lNvecJbW BBvqKAqHxP3M17KJP8zbLdBicF/LvDeHkxdbwdHcN01/mcqKwp7ZJ5v6es62vat8bzQj X0Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hqCVMUfm; 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 c35si5562269edf.522.2020.12.11.14.20.22; Fri, 11 Dec 2020 14:20:44 -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=hqCVMUfm; 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 S1732904AbgLJXKA (ORCPT + 99 others); Thu, 10 Dec 2020 18:10:00 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:58836 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388045AbgLJWbR (ORCPT ); Thu, 10 Dec 2020 17:31:17 -0500 Date: Thu, 10 Dec 2020 22:04:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607637874; 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=VGmPq1i3ayrpyyrVWVoevEjU3QrxYsIort8NEoox4yg=; b=hqCVMUfmuuticgtDymRG8jxVgKfcFBzIB8pH+l/OI50m/5MRXQLvICVL5XRnShD1fdU7zS uJ2GN/5zKHWIkchNoD1WGnOItSOiUg5KRJkU/eKqkA7yPkxvjEdqmw2mUb8klHvfwutPgX PxuxC+UDyZTvbi8Lvmg8wx3Za1npgvVOUw2FbsBKWQXcA3IAtTxnf3xUPNzuQlxz7Em99G pCsZ+/QdH1xpbvWOIL0OhbaOeo/eE6OMdHBxPK+a9MOLpXyFe6EYV8M8BD9WRLEgRy8AEG IxTXXg6uMXttBc0ctbRWxHTdWpdDUd329F2cgyOpHEm2eQtL7IKG2NjhvZrEaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607637874; 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=VGmPq1i3ayrpyyrVWVoevEjU3QrxYsIort8NEoox4yg=; b=Prvbtp9FjBqAtnFs1a+QKMk96kMxUa+7ebchJTMKBOD4BZ2ODJR7oe5dOa363J9JgvnJbH 4SvbeE4WVTaLGSCA== 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: x86/urgent] x86/apic/vector: Fix ordering in vector assignment Cc: Prarit Bhargava , "Shung-Hsi Yu" , Thomas Gleixner , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <87ft4djtyp.fsf@nanos.tec.linutronix.de> References: <87ft4djtyp.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Message-ID: <160763787305.3364.11404170583920698033.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 x86/urgent branch of tip: Commit-ID: 190113b4c6531c8e09b31d5235f9b5175cbb0f72 Gitweb: https://git.kernel.org/tip/190113b4c6531c8e09b31d5235f9b5175cbb0f72 Author: Thomas Gleixner AuthorDate: Thu, 10 Dec 2020 21:18:22 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 10 Dec 2020 23:00:54 +01:00 x86/apic/vector: Fix ordering in vector assignment Prarit reported that depending on the affinity setting the ' irq $N: Affinity broken due to vector space exhaustion.' message is showing up in dmesg, but the vector space on the CPUs in the affinity mask is definitely not exhausted. Shung-Hsi provided traces and analysis which pinpoints the problem: The ordering of trying to assign an interrupt vector in assign_irq_vector_any_locked() is simply wrong if the interrupt data has a valid node assigned. It does: 1) Try the intersection of affinity mask and node mask 2) Try the node mask 3) Try the full affinity mask 4) Try the full online mask Obviously #2 and #3 are in the wrong order as the requested affinity mask has to take precedence. In the observed cases #1 failed because the affinity mask did not contain CPUs from node 0. That made it allocate a vector from node 0, thereby breaking affinity and emitting the misleading message. Revert the order of #2 and #3 so the full affinity mask without the node intersection is tried before actually affinity is broken. If no node is assigned then only the full affinity mask and if that fails the full online mask is tried. Fixes: d6ffc6ac83b1 ("x86/vector: Respect affinity mask in irq descriptor") Reported-by: Prarit Bhargava Reported-by: Shung-Hsi Yu Signed-off-by: Thomas Gleixner Tested-by: Shung-Hsi Yu Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/87ft4djtyp.fsf@nanos.tec.linutronix.de --- arch/x86/kernel/apic/vector.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 1eac536..758bbf2 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -273,20 +273,24 @@ static int assign_irq_vector_any_locked(struct irq_data *irqd) const struct cpumask *affmsk = irq_data_get_affinity_mask(irqd); int node = irq_data_get_node(irqd); - if (node == NUMA_NO_NODE) - goto all; - /* Try the intersection of @affmsk and node mask */ - cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk); - if (!assign_vector_locked(irqd, vector_searchmask)) - return 0; - /* Try the node mask */ - if (!assign_vector_locked(irqd, cpumask_of_node(node))) - return 0; -all: + if (node != NUMA_NO_NODE) { + /* Try the intersection of @affmsk and node mask */ + cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk); + if (!assign_vector_locked(irqd, vector_searchmask)) + return 0; + } + /* Try the full affinity mask */ cpumask_and(vector_searchmask, affmsk, cpu_online_mask); if (!assign_vector_locked(irqd, vector_searchmask)) return 0; + + if (node != NUMA_NO_NODE) { + /* Try the node mask */ + if (!assign_vector_locked(irqd, cpumask_of_node(node))) + return 0; + } + /* Try the full online mask */ return assign_vector_locked(irqd, cpu_online_mask); }