Received: by 10.223.148.5 with SMTP id 5csp7233097wrq; Thu, 18 Jan 2018 02:46:03 -0800 (PST) X-Google-Smtp-Source: ACJfBot+2XNUUG60XPbnlbl9IvF3FZsdb0VRZabud5ZpdVhAl4fXrDFI7lgoLwZp8MuVaFGU4rBX X-Received: by 10.84.160.227 with SMTP id v32mr7861666plg.405.1516272363021; Thu, 18 Jan 2018 02:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516272362; cv=none; d=google.com; s=arc-20160816; b=ZBzhljbLENExbZYQ4s8BKIdS4iV7hh0wRWc0kiH++oH/IPCzl82AgDMKBssoYqblCR U5ORIyhWhnP92AWq1os9ZXIjVL78DcSkcxxRRjUe8a4tBTMknkuW53Ukltu92hn8zBfl IgqwxXKCI91CM0e53QmjRR0ADgXBACN5ZfOsOezeZrEYlcVNOCxsz/bHhx7+ZHRfmzmH fxD5HMTsaiqjUaNZ6GAinxJT9lCQi/ZjfiSdEy75HMuA1o7jHEZt9/pl5dTz9EJYABc+ YA7xtf8JS320mugJevKRdWFAau8CcGUcusVAiCsREEs5jTI7gc5Ej0ZhDQEnEV/Dl0Hm EsrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=deqKC5dA1fyhaRWzXTU8hIGuP2ZN7FyQrWy31j0/yIM=; b=r+tJw1rjc2YKo3LvOBmYx7DznpYZR3lJNalxL6txqNeDFiDVuxHWqtKIXwSiPXPTPw ah3dD1uoDmh3z8oSSDYaPRQBeJYeC+0iSVxPc8LnlqMH2VxLb9nMghzEt6M83fCcX737 DkRQiKuXkw1SBnJAIARsjhMsX/RvR5ngH9bBCnu4k7OAgU4JZeSejJ0iltsll2rJrQqC klUByUaY2dGKteUyEbgS9SvFnM7mJbXm47lrYGcMmNIZ8+MKWlbJ5EBWS1oM63TwgdU9 E1EoLpiflXxTdJ/dJ+LJM3bNGxZkx9n7r9JpOAJMLDvH5gvEfwfTn5LWFsJzul13PmFO hx8g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si3973961plo.545.2018.01.18.02.45.48; Thu, 18 Jan 2018 02:46:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755822AbeARKoY (ORCPT + 99 others); Thu, 18 Jan 2018 05:44:24 -0500 Received: from terminus.zytor.com ([65.50.211.136]:42065 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754788AbeARKoV (ORCPT ); Thu, 18 Jan 2018 05:44:21 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0IAhCoI013285; Thu, 18 Jan 2018 02:43:12 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0IAhCCN013281; Thu, 18 Jan 2018 02:43:12 -0800 Date: Thu, 18 Jan 2018 02:43:12 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Gleixner Message-ID: Cc: hpa@zytor.com, keith.busch@intel.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, keith.busch@intel.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/urgent] irq/matrix: Spread interrupts on allocation Git-Commit-ID: a0c9259dc4e1923a98356967ce8b732da1979df8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a0c9259dc4e1923a98356967ce8b732da1979df8 Gitweb: https://git.kernel.org/tip/a0c9259dc4e1923a98356967ce8b732da1979df8 Author: Thomas Gleixner AuthorDate: Wed, 17 Jan 2018 16:01:47 +0100 Committer: Thomas Gleixner CommitDate: Thu, 18 Jan 2018 11:38:41 +0100 irq/matrix: Spread interrupts on allocation Keith reported an issue with vector space exhaustion on a server machine which is caused by the i40e driver allocating 168 MSI interrupts when the driver is initialized, even when most of these interrupts are not used at all. The x86 vector allocation code tries to avoid the immediate allocation with the reservation mode, but the card uses MSI and does not support MSI entry masking, which prevents reservation mode and requires immediate vector allocation. The matrix allocator is a bit naive and prefers the first CPU in the cpumask which describes the possible target CPUs for an allocation. That results in allocating all 168 vectors on CPU0 which later causes vector space exhaustion when the NVMe driver tries to allocate managed interrupts on each CPU for the per CPU queues. Avoid this by finding the CPU which has the lowest vector allocation count to spread out the non managed interrupt accross the possible target CPUs. Fixes: 2f75d9e1c905 ("genirq: Implement bitmap matrix allocator") Reported-by: Keith Busch Signed-off-by: Thomas Gleixner Tested-by: Keith Busch Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801171557330.1777@nanos --- kernel/irq/matrix.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c index 0ba0dd8..5187dfe 100644 --- a/kernel/irq/matrix.c +++ b/kernel/irq/matrix.c @@ -321,15 +321,23 @@ void irq_matrix_remove_reserved(struct irq_matrix *m) int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk, bool reserved, unsigned int *mapped_cpu) { - unsigned int cpu; + unsigned int cpu, best_cpu, maxavl = 0; + struct cpumap *cm; + unsigned int bit; + best_cpu = UINT_MAX; for_each_cpu(cpu, msk) { - struct cpumap *cm = per_cpu_ptr(m->maps, cpu); - unsigned int bit; + cm = per_cpu_ptr(m->maps, cpu); - if (!cm->online) + if (!cm->online || cm->available <= maxavl) continue; + best_cpu = cpu; + maxavl = cm->available; + } + + if (maxavl) { + cm = per_cpu_ptr(m->maps, best_cpu); bit = matrix_alloc_area(m, cm, 1, false); if (bit < m->alloc_end) { cm->allocated++; @@ -338,8 +346,8 @@ int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk, m->global_available--; if (reserved) m->global_reserved--; - *mapped_cpu = cpu; - trace_irq_matrix_alloc(bit, cpu, m, cm); + *mapped_cpu = best_cpu; + trace_irq_matrix_alloc(bit, best_cpu, m, cm); return bit; } }