From patchwork Mon Jul 10 15:53:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 9833339 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 02CCE60318 for ; Mon, 10 Jul 2017 15:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6B6B22B26 for ; Mon, 10 Jul 2017 15:54:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D98BF285DA; Mon, 10 Jul 2017 15:54:26 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 46CA422B26 for ; Mon, 10 Jul 2017 15:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=c70jqQMsiUpwH/07smejIYbKi2CUZSY0MMAq6AYr6Nc=; b=DeY d6HHTfRSZnIN+4vqJneWBIR3uKIyHX3t1gR8JiHn41+RA0dSNmn8p3TPn46VgX+0ko4YIRtL9eEhb YMESrGFw2nPvjO8rGJg+ow7nYa7uwl1Pt7qpFprV4sZFiikpPOMludMNPDqPj8KukMhWOU/GqC5Jx Wv2x81XtMowZi1xQS2wL5Q9lccp6jCGzfMBtoKv6VQRaSfOPsYo6V3LjrqLWTD0ZiuqueejXlrBDj J3k2HCZ6r+vFgCZ61zYYu12IWZ/ztbdVbRXkS9KEVRm47qfjRHjSXXcAhpujEUhep+quD0c9HbgFQ EqJE6e6czVHR4fjrYNqzgieNgH7+qdg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dUb0y-00008G-Tg; Mon, 10 Jul 2017 15:54:24 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUb0v-000063-BD for linux-arm-kernel@lists.infradead.org; Mon, 10 Jul 2017 15:54:23 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7AD5060870; Mon, 10 Jul 2017 15:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499702040; bh=vBcHUGNb0bgC1CmyQIwvk4PjVG688jFcaAtQr5YoZb4=; h=From:To:Cc:Subject:Date:From; b=cgxtJqPODqvu1fhvWYSGIgZj9QPrJX8RTwZmj5WHt0AYHa5+iITL9RFGcXVVQLrBw NlWt/Hy+Rmwcv1NRZ8YxUM2qj67Drj+01GAOa2t+SzMrJc7mBFGRAEbdhhTWhhUyNb Ix7RP6EbvJAnUUA8gDwOwIDSrAFTO3uS4SqD2lRQ= Received: from shankerd-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shankerd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B95EE60115; Mon, 10 Jul 2017 15:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1499702039; bh=vBcHUGNb0bgC1CmyQIwvk4PjVG688jFcaAtQr5YoZb4=; h=From:To:Cc:Subject:Date:From; b=Y9tBcP84sLnAiVBmgMIaVbbgDDhjnkZDPDbcxNl0qj7LvdjLs1bLdc2qaZiPp670V Szo1tA92uvl1xFb49qxTsYaeSu7aQU1ldrXYDfWSf+Vq5fxIfMiLjWszTISEdV9vr+ tGrqNdu61EhwwZt9Wu9bJri1z8QvejtAE/gxj3Mc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B95EE60115 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=shankerd@codeaurora.org From: Shanker Donthineni To: Marc Zyngier , linux-kernel , linux-arm-kernel Subject: [PATCH v2] irqchip: gicv3-its: Use NUMA aware memory allocation for ITS tables Date: Mon, 10 Jul 2017 10:53:45 -0500 Message-Id: <1499702025-21383-1-git-send-email-shankerd@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170710_085421_480349_4A09C1DB X-CRM114-Status: GOOD ( 15.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Cooper , Vikram Sethi , Eric Auger , Ganapatrao Kulkarni , Thomas Gleixner , Shanker Donthineni MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The NUMA node information is visible to ITS driver but not being used other than handling hardware errata. ITS/GICR hardware accesses to the local NUMA node is usually quicker than the remote NUMA node. How slow the remote NUMA accesses are depends on the implementation details. This patch allocates memory for ITS management tables and command queue from the corresponding NUMA node using the appropriate NUMA aware functions. This change improves the performance of the ITS tables read latency on systems where it has more than one ITS block, and with the slower inter node accesses. Signed-off-by: Shanker Donthineni Tested-by: Ganapatrao Kulkarni --- drivers/irqchip/irq-gic-v3-its.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 45ea1933..40442fb 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -858,8 +858,8 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, u64 val = its_read_baser(its, baser); u64 esz = GITS_BASER_ENTRY_SIZE(val); u64 type = GITS_BASER_TYPE(val); + struct page *page; u32 alloc_pages; - void *base; u64 tmp; retry_alloc_baser: @@ -872,12 +872,12 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, order = get_order(GITS_BASER_PAGES_MAX * psz); } - base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order); - if (!base) + page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, order); + if (!page) return -ENOMEM; retry_baser: - val = (virt_to_phys(base) | + val = (page_to_phys(page) | (type << GITS_BASER_TYPE_SHIFT) | ((esz - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) | ((alloc_pages - 1) << GITS_BASER_PAGES_SHIFT) | @@ -913,7 +913,8 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, shr = tmp & GITS_BASER_SHAREABILITY_MASK; if (!shr) { cache = GITS_BASER_nC; - gic_flush_dcache_to_poc(base, PAGE_ORDER_TO_SIZE(order)); + gic_flush_dcache_to_poc(page_to_virt(page), + PAGE_ORDER_TO_SIZE(order)); } goto retry_baser; } @@ -924,7 +925,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, * size and retry. If we reach 4K, then * something is horribly wrong... */ - free_pages((unsigned long)base, order); + __free_pages(page, order); baser->base = NULL; switch (psz) { @@ -941,19 +942,19 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, pr_err("ITS@%pa: %s doesn't stick: %llx %llx\n", &its->phys_base, its_base_type_string[type], val, tmp); - free_pages((unsigned long)base, order); + __free_pages(page, order); return -ENXIO; } baser->order = order; - baser->base = base; + baser->base = page_to_virt(page); baser->psz = psz; tmp = indirect ? GITS_LVL1_ENTRY_SIZE : esz; pr_info("ITS@%pa: allocated %d %s @%lx (%s, esz %d, psz %dK, shr %d)\n", &its->phys_base, (int)(PAGE_ORDER_TO_SIZE(order) / (int)tmp), its_base_type_string[type], - (unsigned long)virt_to_phys(base), + (unsigned long)page_to_phys(page), indirect ? "indirect" : "flat", (int)esz, psz / SZ_1K, (int)shr >> GITS_BASER_SHAREABILITY_SHIFT); @@ -1017,7 +1018,7 @@ static void its_free_tables(struct its_node *its) for (i = 0; i < GITS_BASER_NR_REGS; i++) { if (its->tables[i].base) { - free_pages((unsigned long)its->tables[i].base, + __free_pages(virt_to_page(its->tables[i].base), its->tables[i].order); its->tables[i].base = NULL; } @@ -1284,7 +1285,8 @@ static bool its_alloc_device_table(struct its_node *its, u32 dev_id) /* Allocate memory for 2nd level table */ if (!table[idx]) { - page = alloc_pages(GFP_KERNEL | __GFP_ZERO, get_order(baser->psz)); + page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, + get_order(baser->psz)); if (!page) return false; @@ -1330,7 +1332,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, nr_ites = max(2UL, roundup_pow_of_two(nvecs)); sz = nr_ites * its->ite_size; sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; - itt = kzalloc(sz, GFP_KERNEL); + itt = kzalloc_node(sz, GFP_KERNEL, its->numa_node); lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); if (lpi_map) col_map = kzalloc(sizeof(*col_map) * nr_lpis, GFP_KERNEL); @@ -1675,6 +1677,7 @@ static int __init its_probe_one(struct resource *res, { struct its_node *its; void __iomem *its_base; + struct page *page; u32 val; u64 baser, tmp; int err; @@ -1714,12 +1717,13 @@ static int __init its_probe_one(struct resource *res, its->ite_size = ((gic_read_typer(its_base + GITS_TYPER) >> 4) & 0xf) + 1; its->numa_node = numa_node; - its->cmd_base = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, - get_order(ITS_CMD_QUEUE_SZ)); - if (!its->cmd_base) { + page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, + get_order(ITS_CMD_QUEUE_SZ)); + if (!page) { err = -ENOMEM; goto out_free_its; } + its->cmd_base = page_to_virt(page); its->cmd_write = its->cmd_base; its_enable_quirks(its); @@ -1773,7 +1777,7 @@ static int __init its_probe_one(struct resource *res, out_free_tables: its_free_tables(its); out_free_cmd: - free_pages((unsigned long)its->cmd_base, get_order(ITS_CMD_QUEUE_SZ)); + __free_pages(virt_to_page(its->cmd_base), get_order(ITS_CMD_QUEUE_SZ)); out_free_its: kfree(its); out_unmap: