Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp726357imm; Thu, 13 Sep 2018 06:54:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaZCmy/DpzG/Md8RyMM5fc+jXCC2934MWX5UIqLy1oSYd+mhWSzhZOm6UPsN5hjINiADAcH X-Received: by 2002:a63:1d22:: with SMTP id d34-v6mr7455659pgd.133.1536846848489; Thu, 13 Sep 2018 06:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846848; cv=none; d=google.com; s=arc-20160816; b=UfzRKtNyLJ2LKPDxBqb4T4mZMu1FETu35fmg/bmQ6/nEytaZiTpZzlHVnOAqcNM5P1 6BT8aqLiyZhJ9qhV/m+E959z1sZoXStHpWs4Xz74WOh4/6Qp8+48+JmH+tApMTkIUcbW 6hPtKdgRCYFrlFMUR/4DxxVtIvNyfTOBbHNEbd6APl7ovpVlsOgwc1n6popCW5GBvHl2 Zm9Elfx8/fs/mBty4xP5LCWKIjMi7iX+cs5JhFZni4k3JQHsIgNzgeMcAox+S/4Kcf+G U9dHMU/T+/xPYsuqOiZtUJ/vKUUHlIKewHzSAsMcgTRfd6ZakrcsauKdnLEFMqC3KOzf rUcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=az8Wd5G0/tcpbAWeocIvk2k7CO1/aBwI8VkPuEJtkhg=; b=oqpH1DvoqQvFn2egnbVwEYPlyHLLKDHYeKnPXjqttt9s2931nF49hrM9VsOJflfDw1 yQZgUJt1LIfS/1+PsmEUD2vF9dwBlxYVLsWbFkB9mTntZ+4zzv/fHZuPY9JOyCw/X8eg 2+8rKJz4QHgFXAcfhD9R7Qtc/8ijkEH2diAh96lx9xi4tRZ9te8Ligrs3xAoiSe3tPIo 6X2NgmHCYdGw5fVvk2uUfBynu8qDkVr6WeilchztKYaUo95iEO+ydWnATNitFWQ1KWlM CZBrcLtsgNmoivjJyQkTrDJf0BRlyBPQk3ymf5J4p6pIZMoetBJSDu7i1TV05bTRqN/+ CcNw== 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 d2-v6si3860065pgp.256.2018.09.13.06.53.53; Thu, 13 Sep 2018 06:54:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731152AbeIMTDY (ORCPT + 99 others); Thu, 13 Sep 2018 15:03:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33740 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbeIMTDY (ORCPT ); Thu, 13 Sep 2018 15:03:24 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EFE19D19; Thu, 13 Sep 2018 13:53:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gary Leshner , Mike Marciniszyn , "Michael J. Ruhl" , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.18 056/197] IB/hfi1: Invalid NUMA node information can cause a divide by zero Date: Thu, 13 Sep 2018 15:30:05 +0200 Message-Id: <20180913131843.770790558@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Michael J. Ruhl" [ Upstream commit c513de490f808d8480346f9a58e6a4a5f3de12e7 ] If the system BIOS does not supply NUMA node information to the PCI devices, the NUMA node is selected by choosing the current node. This can lead to the following crash: divide error: 0000 SMP CPU: 0 PID: 4 Comm: kworker/0:0 Tainted: G IOE ------------ 3.10.0-693.21.1.el7.x86_64 #1 Hardware name: Intel Corporation S2600KP/S2600KP, BIOS SE5C610.86B.01.01.0005.101720141054 10/17/2014 Workqueue: events work_for_cpu_fn task: ffff880174480fd0 ti: ffff880174488000 task.ti: ffff880174488000 RIP: 0010: [] hfi1_dev_affinity_init+0x129/0x6a0 [hfi1] RSP: 0018:ffff88017448bbf8 EFLAGS: 00010246 RAX: 0000000000000011 RBX: ffff88107ffba6c0 RCX: ffff88085c22e130 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff880824ad0000 RBP: ffff88017448bc48 R08: 0000000000000011 R09: 0000000000000002 R10: ffff8808582b6ca0 R11: 0000000000003151 R12: ffff8808582b6ca0 R13: ffff8808582b6518 R14: ffff8808582b6010 R15: 0000000000000012 FS: 0000000000000000(0000) GS:ffff88085ec00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007efc707404f0 CR3: 0000000001a02000 CR4: 00000000001607f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Call Trace: hfi1_init_dd+0x14b3/0x27a0 [hfi1] ? pcie_capability_write_word+0x46/0x70 ? hfi1_pcie_init+0xc0/0x200 [hfi1] do_init_one+0x153/0x4c0 [hfi1] ? sched_clock_cpu+0x85/0xc0 init_one+0x1b5/0x260 [hfi1] local_pci_probe+0x4a/0xb0 work_for_cpu_fn+0x1a/0x30 process_one_work+0x17f/0x440 worker_thread+0x278/0x3c0 ? manage_workers.isra.24+0x2a0/0x2a0 kthread+0xd1/0xe0 ? insert_kthread_work+0x40/0x40 ret_from_fork+0x77/0xb0 ? insert_kthread_work+0x40/0x40 If the BIOS is not supplying NUMA information: - set the default table count to 1 for all possible nodes - select node 0 (instead of current NUMA) node to get consistent performance - generate an error indicating that the BIOS should be upgraded Reviewed-by: Gary Leshner Reviewed-by: Mike Marciniszyn Signed-off-by: Michael J. Ruhl Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/affinity.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) --- a/drivers/infiniband/hw/hfi1/affinity.c +++ b/drivers/infiniband/hw/hfi1/affinity.c @@ -198,7 +198,7 @@ int node_affinity_init(void) while ((dev = pci_get_device(ids->vendor, ids->device, dev))) { node = pcibus_to_node(dev->bus); if (node < 0) - node = numa_node_id(); + goto out; hfi1_per_node_cntr[node]++; } @@ -206,6 +206,18 @@ int node_affinity_init(void) } return 0; + +out: + /* + * Invalid PCI NUMA node information found, note it, and populate + * our database 1:1. + */ + pr_err("HFI: Invalid PCI NUMA node. Performance may be affected\n"); + pr_err("HFI: System BIOS may need to be upgraded\n"); + for (node = 0; node < node_affinity.num_possible_nodes; node++) + hfi1_per_node_cntr[node] = 1; + + return 0; } static void node_affinity_destroy(struct hfi1_affinity_node *entry) @@ -622,8 +634,14 @@ int hfi1_dev_affinity_init(struct hfi1_d int curr_cpu, possible, i, ret; bool new_entry = false; - if (node < 0) - node = numa_node_id(); + /* + * If the BIOS does not have the NUMA node information set, select + * NUMA 0 so we get consistent performance. + */ + if (node < 0) { + dd_dev_err(dd, "Invalid PCI NUMA node. Performance may be affected\n"); + node = 0; + } dd->node = node; local_mask = cpumask_of_node(dd->node);