From patchwork Mon Aug 31 20:48:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 7101511 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D9599BEEC1 for ; Mon, 31 Aug 2015 20:48:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C14BA206A3 for ; Mon, 31 Aug 2015 20:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8066B206A4 for ; Mon, 31 Aug 2015 20:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753218AbbHaUsb (ORCPT ); Mon, 31 Aug 2015 16:48:31 -0400 Received: from mail-qk0-f177.google.com ([209.85.220.177]:32935 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753019AbbHaUs2 (ORCPT ); Mon, 31 Aug 2015 16:48:28 -0400 Received: by qkdv1 with SMTP id v1so16757023qkd.0 for ; Mon, 31 Aug 2015 13:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=avagotech.com; s=google; h=date:from:to:subject:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=sGG2HkuKRgTLW9/jPlzymannR1i5EHxuPWqIOPzVt+g=; b=SKm1Et7HvArZsZ+GKz4UYQ4LAqAiAgS197s1WjRMF1+vfp1J4KJ7F0tZ4f0FJUcctg 5ILmM5WPN/RM3xE/YvBIFjlvFL0vu2FX+D9THNOV8eONZyY5rNMQSz1ew/4jhCz6OaLO 0unGPKthaVyocGezM65UX3Dyqq8YdVXkb4IRQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:user-agent :mime-version:content-type:content-transfer-encoding; bh=sGG2HkuKRgTLW9/jPlzymannR1i5EHxuPWqIOPzVt+g=; b=TLbRw8ibvsGHZeSmNAO0hn++p6rUQ+dbrFNKIk9IUXDyvexNhEHMz2hqON5xEg35+E INbYKElB87W1xmqn4pWR2HRLKgvEoeZLZM9K6ZriBUyalGtWzPcBHQUq2Kai7zm+pjM7 taJAc4iRU5fiFLBcZmVwdM6jTzE+9RAwn4WQVcbKypJH0OHrvN+cHXYCZUm0sk43F+Zv qZNjusw6Iaah8gII1gXnTOJ57vbAw1ofbnKJ6bYweAS+9HWSRh2O/PM39osA9okAcUCf Gk2w9yvsVzuNSlmD1FnTZeO7uCWgYIOhwwNFhKmTprMPEZ6vtDWRL7nvSpMbBmTn749K 1RwA== X-Gm-Message-State: ALoCoQlZH0mQWptguZHp2W82mOzQGEaNeASfTFyqsK5gtIdcjiWR8DFaqpaqdWwpqQVF4H9NdCHz X-Received: by 10.55.22.143 with SMTP id 15mr13197165qkw.38.1441054107658; Mon, 31 Aug 2015 13:48:27 -0700 (PDT) Received: from myfc17 (c-75-67-235-135.hsd1.nh.comcast.net. [75.67.235.135]) by smtp.gmail.com with ESMTPSA id c95sm364979qgd.7.2015.08.31.13.48.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 31 Aug 2015 13:48:27 -0700 (PDT) Date: Mon, 31 Aug 2015 16:48:12 -0400 From: james.smart@avagotech.com (James Smart) To: linux-scsi@vger.kernel.org Subject: [PATCH 05/14] Fix kmalloc overflow in LPFC driver at large core count Message-ID: <55e4bd8c.8SprKlWFHxhnk4Ef%james.smart@avagotech.com> User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Note: original patch modified by me to resolve unused variable warning From: ian mitchell This patch allows the LPFC to start up without a fatal kernel bug based on an exceeded KMALLOC_MAX_SIZE and a too large NR_CPU-based maskbits field. The bug was based on the number of CPU cores in a system. Using the get_cpu_mask() function declared in kernel/cpu.c allows the driver to load on the community kernel 4.2 RC1. Below is the kernel bug reproduced: 8<-------------------------------------------------------------------- 2199382.828437 ( 0.005216)| lpfc 0003:02:00.0: enabling device (0140 -> 0142) 2199382.999272 ( 0.170835)| ------------[ cut here ]------------ 2199382.999337 ( 0.000065)| WARNING: CPU: 84 PID: 404 at mm/slab_common.c:653 kmalloc_slab+0x2f/0x89() 2199383.004534 ( 0.005197)| Modules linked in: lpfc(+) usbcore(+) mptctl scsi_transport_fc sg lpc_ich i2c_i801 usb_common tpm_tis mfd_core tpm acpi_cpufreq button scsi_dh_alua scsi_dh_rdacusbcore: registered new device driver usb 2199383.020568 ( 0.016034)| 2199383.020581 ( 0.000013)| scsi_dh_hp_sw scsi_dh_emc scsi_dh gru thermal sata_nv processor piix fan thermal_sysehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver 2199383.035288 ( 0.014707)| 2199383.035306 ( 0.000018)| hwmon ata_piix 2199383.035336 ( 0.000030)| CPU: 84 PID: 404 Comm: kworker/84:0 Not tainted 3.18.0-rc2-gat-00106-ga7ca10f-dirty #178 2199383.047077 ( 0.011741)| ehci-pci: EHCI PCI platform driver 2199383.047134 ( 0.000057)| Hardware name: SGI UV2000/ROMLEY, BIOS SGI UV 2000/3000 series BIOS 01/15/2013 2199383.056245 ( 0.009111)| Workqueue: events work_for_cpu_fn 2199383.066174 ( 0.009929)| 000000000000028d ffff88eef827bbe8 ffffffff815a542f 000000000000028d 2199383.069545 ( 0.003371)| ffffffff810ea142 ffff88eef827bc28 ffffffff8104365c ffff88eefe4006c8 2199383.076214 ( 0.006669)| 0000000000000000 00000000000080d0 0000000000000000 0000000000000004 2199383.079213 ( 0.002999)| Call Trace: 2199383.084084 ( 0.004871)| [] dump_stack+0x49/0x62 2199383.087283 ( 0.003199)| [] ? kmalloc_slab+0x2f/0x89 2199383.091415 ( 0.004132)| [] warn_slowpath_common+0x77/0x92 2199383.095197 ( 0.003782)| [] warn_slowpath_null+0x15/0x17 2199383.103336 ( 0.008139)| [] kmalloc_slab+0x2f/0x89 2199383.107082 ( 0.003746)| [] __kmalloc+0x13/0x16a 2199383.112531 ( 0.005449)| [] lpfc_pci_probe_one_s4+0x105b/0x1644 [lpfc] 2199383.115316 ( 0.002785)| [] ? pci_bus_read_config_dword+0x75/0x87 2199383.123431 ( 0.008115)| [] lpfc_pci_probe_one+0x5d/0xcb5 [lpfc] 2199383.127364 ( 0.003933)| [] ? dbs_check_cpu+0x168/0x177 2199383.136438 ( 0.009074)| [] ? gov_queue_work+0xb4/0xc0 2199383.140407 ( 0.003969)| [] local_pci_probe+0x1e/0x52 2199383.143105 ( 0.002698)| [] work_for_cpu_fn+0x13/0x1b 2199383.147315 ( 0.004210)| [] process_one_work+0x222/0x35e 2199383.151379 ( 0.004064)| [] worker_thread+0x3d5/0x46e 2199383.159402 ( 0.008023)| [] ? process_one_work+0x35e/0x35e 2199383.163097 ( 0.003695)| [] kthread+0xc8/0xd2 2199383.167476 ( 0.004379)| [] ? kthread_freezable_should_stop+0x5b/0x5b 2199383.176434 ( 0.008958)| [] ret_from_fork+0x7c/0xb0 2199383.180086 ( 0.003652)| [] ? kthread_freezable_should_stop+0x5b/0x5b 2199383.192333 ( 0.012247)| ehci-pci 0000:00:1a.0: EHCI Host Controller -------------------------------------------------------------------->8 The proposed solution was approved by James Smart at Emulex and tested on a UV2 machine with 6144 cores. With the fix, the LPFC module loads with no unwanted effects on the system. Signed-off-by: Ian Mitchell Signed-off-by: Alex Thorlton Suggested-by: Robert Elliot Cc: James Smart Cc: Dick Kennedy Cc: James E.J. Bottomley Cc: linux-scsi@vger.kernel.org Signed-off-by: James Smart Reviewed-by: Hannes Reinecke --- drivers/scsi/lpfc/lpfc_init.c | 6 +----- drivers/scsi/lpfc/lpfc_sli4.h | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index eaf121a..bedbfe6 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -8678,7 +8678,6 @@ lpfc_sli4_set_affinity(struct lpfc_hba *phba, int vectors) #ifdef CONFIG_X86 struct cpuinfo_x86 *cpuinfo; #endif - struct cpumask *mask; uint8_t chann[LPFC_FCP_IO_CHAN_MAX+1]; /* If there is no mapping, just return */ @@ -8772,11 +8771,8 @@ found: first_cpu = cpu; /* Now affinitize to the selected CPU */ - mask = &cpup->maskbits; - cpumask_clear(mask); - cpumask_set_cpu(cpu, mask); i = irq_set_affinity_hint(phba->sli4_hba.msix_entries[idx]. - vector, mask); + vector, get_cpu_mask(cpu)); lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "3330 Set Affinity: CPU %d channel %d " diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h index d1a5b05..1e916e1 100644 --- a/drivers/scsi/lpfc/lpfc_sli4.h +++ b/drivers/scsi/lpfc/lpfc_sli4.h @@ -454,7 +454,6 @@ struct lpfc_vector_map_info { uint16_t core_id; uint16_t irq; uint16_t channel_id; - struct cpumask maskbits; }; #define LPFC_VECTOR_MAP_EMPTY 0xffff