From patchwork Wed Feb 1 04:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 9548891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D541960424 for ; Wed, 1 Feb 2017 04:25:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72A32838D for ; Wed, 1 Feb 2017 04:25:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99EEC283CA; Wed, 1 Feb 2017 04:25:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22E332838D for ; Wed, 1 Feb 2017 04:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751045AbdBAEZz (ORCPT ); Tue, 31 Jan 2017 23:25:55 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:32935 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750946AbdBAEZz (ORCPT ); Tue, 31 Jan 2017 23:25:55 -0500 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v114Mxxu020814 for ; Tue, 31 Jan 2017 20:25:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=ZvoUTiqW78wJX5waq4OCtyX0z24UNP6xQx7zF+liQT0=; b=Kl61090dIBzCCbpM2mefBz8dNaZA8+TOmsCtZteoswL1bEeaSuRPRJUBpzzFcgFH24M6 x1Rs/5ALP/pUA4dOjWfkzoBGRu2wroxyGTFHnXDxn0WdyLxsP7ywvxRF25WNp6itfwMl QWygy8kKANgkiWL/TDv0fxCaIkKKg9E6uqk= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 28b7p183jf-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 31 Jan 2017 20:25:54 -0800 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB10.TheFacebook.com (192.168.16.20) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 31 Jan 2017 20:25:53 -0800 Received: from facebook.com (2401:db00:21:603d:face:0:19:0) by mx-out.facebook.com (10.103.99.99) with ESMTP id 845a1618e83611e68b200002c9dfb610-751f7a50 for ; Tue, 31 Jan 2017 20:25:52 -0800 Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id AE19B42C0895; Tue, 31 Jan 2017 20:25:52 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Shaohua Li Smtp-Origin-Hostname: devbig638.prn2.facebook.com To: , CC: , Smtp-Origin-Cluster: prn2c22 Subject: [PATCH 2/2] nvme: allocate nvme_queue in correct node Date: Tue, 31 Jan 2017 20:25:52 -0800 Message-ID: <7119c172f8916bd21aeffc006b04cd73281afb25.1485922654.git.shli@fb.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <1c91ab2c0073598592f66f007ff72cfa58a17a54.1485922654.git.shli@fb.com> References: <1c91ab2c0073598592f66f007ff72cfa58a17a54.1485922654.git.shli@fb.com> X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-31_12:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nvme_queue is per-cpu queue (mostly). Allocating it in node where blk-mq will use it. Signed-off-by: Shaohua Li --- drivers/nvme/host/pci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 3faefab..f81c0ed 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1041,9 +1041,10 @@ static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq, } static struct nvme_queue *nvme_alloc_queue(struct nvme_dev *dev, int qid, - int depth) + int depth, int node) { - struct nvme_queue *nvmeq = kzalloc(sizeof(*nvmeq), GFP_KERNEL); + struct nvme_queue *nvmeq = kzalloc_node(sizeof(*nvmeq), GFP_KERNEL, + node); if (!nvmeq) return NULL; @@ -1219,7 +1220,8 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev) nvmeq = dev->queues[0]; if (!nvmeq) { - nvmeq = nvme_alloc_queue(dev, 0, NVME_AQ_DEPTH); + nvmeq = nvme_alloc_queue(dev, 0, NVME_AQ_DEPTH, + dev_to_node(dev->dev)); if (!nvmeq) return -ENOMEM; } @@ -1309,9 +1311,18 @@ static int nvme_create_io_queues(struct nvme_dev *dev) { unsigned i, max; int ret = 0; + const struct cpumask *mask; for (i = dev->queue_count; i <= dev->max_qid; i++) { - if (!nvme_alloc_queue(dev, i, dev->q_depth)) { + int node = dev_to_node(dev->dev); + + mask = pci_irq_get_affinity(to_pci_dev(dev->dev), i); + if (mask) { + node = cpu_to_node(cpumask_first(mask)); + node = local_memory_node(node); + } + + if (!nvme_alloc_queue(dev, i, dev->q_depth, node)) { ret = -ENOMEM; break; }