From patchwork Thu Feb 9 15:57:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 9565037 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 E4E706020C for ; Thu, 9 Feb 2017 16:02:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D46B827F81 for ; Thu, 9 Feb 2017 16:02:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8C2D281E1; Thu, 9 Feb 2017 16:02:14 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F95227F81 for ; Thu, 9 Feb 2017 16:02:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbr8A-00083c-7i; Thu, 09 Feb 2017 15:59:34 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbr88-00081e-QG for xen-devel@lists.xenproject.org; Thu, 09 Feb 2017 15:59:32 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id A3/BB-03454-4E19C985; Thu, 09 Feb 2017 15:59:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfTAQd3HE+d EGPQ2KVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlnJ31mLGiQrZg9u5upgXGiRBcjF4eQwDRG ifUfZjOBOCwCL1kkZu56yAbiSAj0s0r8/tcHlOEEcmIkJu4+xgJhl0tsX7iEHcQWElCV6Pj/F sr+wSix6mMmiM0mICNx5PkBsF4RgTSJY6vXsoHYzAK+Ei8XTWQGsYUFbCW+vHjM2MXIAbRZVe Lj5EqQMK+Am8SiZe+YQMISAgoScybZgIQ5gcLL91xigdjkKvGgu411AqPAAkaGVYwaxalFZal FuoameklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgWHFAAQ7GL8tCzjEKMnBpCTK K1swJ0KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK8JMEyFBItS01Mr0jJzgAEOk5bg4FES4f07A SjNW1yQmFucmQ6ROsVozNHTdfolE8eeXZdfMgmx5OXnpUqJ8waDlAqAlGaU5sENgkXeJUZZKW FeRqDThHgKUotyM0tQ5V8xinMwKgnz3gWZwpOZVwK37xXQKUxAp1w/PQvklJJEhJRUA6Ou7IJ rrjqTgktn1XSLqzAdud/p/CvoesXkVTevM7c82uW2jX2qqZqO6caLF06+uHit1CR66gV12YLo 5h/PbW6r6OsdO27l7e6dOdNmazzr2/iPNzLnRvyepLyov0C8plNU8sTvNV5WKWb77J7KHXmRf 9PWcMOzhO5Fafb3Nr2Zy8iQk1cVdFOJpTgj0VCLuag4EQAz9AxltwIAAA== X-Env-Sender: vijay.kilari@gmail.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1486655970!43046680!1 X-Originating-IP: [209.85.192.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3445 invoked from network); 9 Feb 2017 15:59:31 -0000 Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Feb 2017 15:59:31 -0000 Received: by mail-pf0-f193.google.com with SMTP id e4so481869pfg.0 for ; Thu, 09 Feb 2017 07:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8YMgDaXdAHDzziOTEr9dYP//qoXbCQEzuNCKl3eQ9Iw=; b=WQUHxR+gbGKdyr9WAdcsSOf9mcWkHFafosgsDuAmnDW82fKrJ5eyktWO1p7/Sh8od1 a2NdQ6R4EhMcCKmxn8XjxHtDtUTlIRcX9M/RDw0x4VCyXEzA6M0Q2r6UfC4uXLd69JGz aiINY/Ej8OWwrqC3rdqBLvicS6uOz//3XbQBg9u4sid/QZWPuZDINxR6wVt83pFWdkcg l1lFnkl7S5asXk9qzQg7dXnZcWAUoNejYbRJPRq+aKM7wuqe20dlgt+3NBMClLil7lfr RCRw/Y2JWo6IyzWpQWzCMsCn1Id6lDg7eaBxfvXXGkpLnSbydIsBtDCMn7RTzKg0wAds mA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8YMgDaXdAHDzziOTEr9dYP//qoXbCQEzuNCKl3eQ9Iw=; b=bBpgnKmDBTKDD0uL6I1TNjrRtfJ6AJwE3GDyOddVeoNNKg6vY2fuEjdc8HhGSiEkuC kjiF2hDTSbpMRF3MBPJOvVXGfZkSdEKRkrrOPTuVXS+2aRmcocIdUDdumCCGOrr7XpOb L9P2wfGy5f5XZao3LS/I5lm3R8gRJFvIC8ULGwRmNOAgduN122VNkQ1A+oSmMqeoIsSq u0WY84zfhFUSha7g+Lu8Vcy00SEZ11NK5z4KgyekmUBGU5kndbDw+VYGz+BfHzUoZMv0 Dtptj/7TZGOJiTRWce27auw6xuoFa8S6tQ9K7Umg8YwmJ8zHl16tCdb6xKUTDvxkCvoM kj+Q== X-Gm-Message-State: AMke39nsakAKD40JQ7z0x7RdjW6Zc98QT2fjICmlnTj+GOynSrkCUvlV/t5yXgNTwksLAQ== X-Received: by 10.84.193.36 with SMTP id e33mr5143251pld.4.1486655969939; Thu, 09 Feb 2017 07:59:29 -0800 (PST) Received: from localhost.localdomain ([14.140.2.178]) by smtp.gmail.com with ESMTPSA id m29sm30093842pfi.54.2017.02.09.07.59.27 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Feb 2017 07:59:29 -0800 (PST) From: vijay.kilari@gmail.com To: julien.grall@arm.com, sstabellini@kernel.org, andre.przywara@arm.com, dario.faggioli@citrix.com Date: Thu, 9 Feb 2017 21:27:01 +0530 Message-Id: <1486655834-9708-10-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1486655834-9708-1-git-send-email-vijay.kilari@gmail.com> References: <1486655834-9708-1-git-send-email-vijay.kilari@gmail.com> Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K Subject: [Xen-devel] [RFC PATCH v1 09/21] ARM: NUMA: Add CPU NUMA support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vijaya Kumar K For each cpu, update cpu_to_node[] with node id from the MPIDR registers. Also, initialize cpu_to_node[] with node 0. Add macros to access cpu_to_node[] information. Signed-off-by: Vijaya Kumar K --- xen/arch/arm/numa.c | 25 +++++++++++++++++++++++++ xen/arch/arm/setup.c | 2 ++ xen/arch/arm/smpboot.c | 3 +++ xen/include/asm-arm/numa.h | 15 +++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c index 11d100b..d4dbad4 100644 --- a/xen/arch/arm/numa.c +++ b/xen/arch/arm/numa.c @@ -23,9 +23,23 @@ #include #include #include +#include int _node_distance[MAX_NUMNODES * 2]; int *node_distance; +extern nodemask_t numa_nodes_parsed; + +void __init numa_set_cpu_node(int cpu, unsigned long hwid) +{ + unsigned node; + + node = hwid >> 16 & 0xf; + if ( !node_isset(node, numa_nodes_parsed) || node == MAX_NUMNODES ) + node = 0; + + numa_set_node(cpu, node); + numa_add_cpu(cpu); +} u8 __node_distance(nodeid_t a, nodeid_t b) { @@ -37,6 +51,17 @@ u8 __node_distance(nodeid_t a, nodeid_t b) EXPORT_SYMBOL(__node_distance); +/* + * Setup early cpu_to_node. + */ +void __init init_cpu_to_node(void) +{ + int i; + + for ( i = 0; i < nr_cpu_ids; i++ ) + numa_set_node(i, 0); +} + int __init numa_init(void) { int i, ret = 0; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index b6618ca..5612ba6 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -749,6 +749,8 @@ void __init start_xen(unsigned long boot_phys_offset, xen_paddr, xen_paddr + xen_bootmodule->size); xen_bootmodule->start = xen_paddr; + init_cpu_to_node(); + setup_mm(fdt_paddr, fdt_size); /* Parse the ACPI tables for possible boot-time configuration */ diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index 32e8722..3667d4b 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -313,6 +314,8 @@ void start_secondary(unsigned long boot_phys_offset, */ smp_wmb(); + numa_set_cpu_node(cpuid, hwid); + /* Now report this CPU is up */ cpumask_set_cpu(cpuid, &cpu_online_map); diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h index b8857e2..33a9e53 100644 --- a/xen/include/asm-arm/numa.h +++ b/xen/include/asm-arm/numa.h @@ -2,16 +2,26 @@ #define __ARCH_ARM_NUMA_H #include +#include typedef u8 nodeid_t; #define NODES_SHIFT 2 #ifdef CONFIG_NUMA + +extern cpumask_t node_to_cpumask[]; +extern nodeid_t cpu_to_node[NR_CPUS]; +#define cpu_to_node(cpu) (cpu_to_node[cpu]) +#define parent_node(node) (node) +#define node_to_first_cpu(node) (__ffs(node_to_cpumask[node])) +#define node_to_cpumask(node) (node_to_cpumask[node]) + int arch_numa_setup(char *opt); int __init numa_init(void); int __init dt_numa_init(void); u8 __node_distance(nodeid_t a, nodeid_t b); +void __init numa_set_cpu_node(int cpu, unsigned long hwid); #else static inline int arch_numa_setup(char *opt) { @@ -28,6 +38,11 @@ static inline int __init dt_numa_init(void) return -EINVAL; } +static inline void __init numa_set_cpu_node(int cpu, unsigned long hwid) +{ + return; +} + /* Fake one node for now. See also node_online_map. */ #define cpu_to_node(cpu) 0 #define node_to_cpumask(node) (cpu_online_map)