From patchwork Tue Mar 28 15:53:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 9650053 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 9D62660349 for ; Tue, 28 Mar 2017 15:56:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E92E283C9 for ; Tue, 28 Mar 2017 15:56:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8329028403; Tue, 28 Mar 2017 15:56:27 +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 E2618283E8 for ; Tue, 28 Mar 2017 15:56:26 +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 1cstRv-0006uy-CN; Tue, 28 Mar 2017 15:54:23 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cstRu-0006u9-1l for xen-devel@lists.xen.org; Tue, 28 Mar 2017 15:54:22 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 03/F2-01912-D278AD85; Tue, 28 Mar 2017 15:54:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRWlGSWpSXmKPExsXiVRvsqKvZfiv CYPYmZYslHxezODB6HN39mymAMYo1My8pvyKBNePW88tsBV8sK3bsu8LUwPhWr4uRi0NIYAKj xMlVW1hAHBaBlywSn688ZgZxJAT6WSUO/bjF1sXICeTESOyccxXKrpZ4O2UVM4gtJKAq0fH/L TvEqG+MEisXNLOCJNgEZCSOPD/ABGKLCEhLXPt8mRGkiFmgmUmib/cSsEnCAmkSi08fAJvEAj RpxfdzQHEODl4BN4nbV61BTAkBBYk5k2xAKjgF3CU2PVkLtReo4sxFxgmMAgsYGVYxahSnFpW lFukaGuslFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQmFesl5+duYgSGFgMQ7GD8t83zEKMkB5OS KO+HoFsRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4v7cA5QSLUtNTK9Iyc4BBDpOW4OBREuF1a AVK8xYXJOYWZ6ZDpE4x6nJ86D/8hkmIJS8/L1VKnPclyAwBkKKM0jy4EbCIu8QoKyXMywh0lB BPQWpRbmYJqvwrRnEORiVh3jqQKTyZeSVwm14BHcEEdIS4DdgRJYkIKakGxsz1M+4cdphTHG+ +NnyKTu2lcsONzq/uHmG5oOTMGlUoPn9byiOb5ZlTWNd0/jOr61/muey8lsktHdFbl5cIlmQY Xph7uJ7/Ztq0CLM7uldn9abJ/ZL5/qO/lXm5z22liaKGEycrVBxTelWdEXzk4a/DmlzNQsJix UK9N5sPr1SuZNCaP3WakRJLcUaioRZzUXEiAGrSFCizAgAA X-Env-Sender: vijay.kilari@gmail.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1490716456!91672389!1 X-Originating-IP: [74.125.83.65] 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 52581 invoked from network); 28 Mar 2017 15:54:17 -0000 Received: from mail-pg0-f65.google.com (HELO mail-pg0-f65.google.com) (74.125.83.65) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Mar 2017 15:54:17 -0000 Received: by mail-pg0-f65.google.com with SMTP id 81so22305514pgh.3 for ; Tue, 28 Mar 2017 08:54:17 -0700 (PDT) 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=LNFgQIjzhBbFCSM2acOekY9vSBdQVxVxLqZz1ALmMJM=; b=PKXzQ5u3t4U2k8KQpyThC14porAW4Z/wdgJHJllNgFAIREs5xnJqX/2U7ELw7V3V4C LdZmtnSx7E4C2qlkfoVAflOOaRLeJbo4siwqYAPzLeQhvWA0fJWgaGic2pfIvH4G6cj0 U3kanvzYkUCBJDxaKB/lkKrcJpMmJUwWQO2DopmvgB4tGPVoxupZtH0KPOq8cw2DRgzJ 4r14SCBNb1nvVjTEOBKKPzBRnR5kI5w6i47APn835yQOOogp53NUgjkwtamM/JPeVReN wmAOzTn5viK07J0phTVNVxQb4zWCl/sjUJNllT3TtwtL8EAk/m+2+6avvKEDlOb4AV3k zKKw== 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=LNFgQIjzhBbFCSM2acOekY9vSBdQVxVxLqZz1ALmMJM=; b=W3sXYoy+vPqaX6BtShu0Egx7QN3BCZjZTzSKYjGC/agFW12mmij8RJ3UJnxbAgpvYl 2FYBNuUdqUWaK4DMnxIN4mTFjCfuSG14faxBwm4DseG9QWs/hrAW00laB8RORMpF5v4u nrbwE9PWuTKfZqAueLhxFzyAL81AAUdR095zPb7UC1ydTQjHTODBQSs8qJb+hPHZdqC/ fTb3CT6qYz2jjbyvalZm2lcySKY11qUnX8VJDqliQos4Nybu8zeKjrbskOgbl017uhHd n65pvD1MLIISw9gl+/l/9Iw8jvn0LkFJ2g8077IPQhy7HAgvm5T0JH/boegtryFh3RmA 68qQ== X-Gm-Message-State: AFeK/H2jCb5IhX1iqUrLIbdHoX+5V/Q/dblLuO7myAVHiMJrz1wCeR5oKdPxSvys2SvabQ== X-Received: by 10.98.44.142 with SMTP id s136mr11342737pfs.244.1490716455532; Tue, 28 Mar 2017 08:54:15 -0700 (PDT) Received: from localhost.localdomain ([14.140.2.178]) by smtp.gmail.com with ESMTPSA id y7sm8298867pfk.93.2017.03.28.08.54.11 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Mar 2017 08:54:15 -0700 (PDT) From: vijay.kilari@gmail.com To: xen-devel@lists.xen.org Date: Tue, 28 Mar 2017 21:23:12 +0530 Message-Id: <1490716413-19796-5-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1490716413-19796-1-git-send-email-vijay.kilari@gmail.com> References: <1490716413-19796-1-git-send-email-vijay.kilari@gmail.com> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com, jbeulich@suse.com, Vijaya Kumar K Subject: [Xen-devel] [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables 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 Add accessor functions for acpi_numa and numa_off static variables. Init value of acpi_numa is set 1 instead of 0. Also return value of srat_disabled is changed to bool. Signed-off-by: Vijaya Kumar K --- xen/arch/x86/numa.c | 43 +++++++++++++++++++++++++++++++------------ xen/arch/x86/setup.c | 2 +- xen/arch/x86/srat.c | 12 ++++++------ xen/include/asm-x86/acpi.h | 1 - xen/include/asm-x86/numa.h | 5 +---- xen/include/xen/numa.h | 3 +++ 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 964fc5a..6b794a7 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -42,12 +42,27 @@ cpumask_t __read_mostly node_to_cpumask[MAX_NUMNODES]; nodemask_t __read_mostly node_online_map = { { [0] = 1UL } }; -bool numa_off = 0; -s8 acpi_numa = 0; +static bool numa_off = 0; +static bool acpi_numa = 1; -int srat_disabled(void) +bool is_numa_off(void) { - return numa_off || acpi_numa < 0; + return numa_off; +} + +bool get_acpi_numa(void) +{ + return acpi_numa; +} + +void set_acpi_numa(bool_t val) +{ + acpi_numa = val; +} + +bool srat_disabled(void) +{ + return numa_off || acpi_numa == 0; } /* @@ -202,13 +217,17 @@ void __init numa_init_array(void) #ifdef CONFIG_NUMA_EMU static int __initdata numa_fake = 0; +static int get_numa_fake(void) +{ + return numa_fake; +} /* Numa emulation */ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) { int i; struct node nodes[MAX_NUMNODES]; - uint64_t sz = ((end_pfn - start_pfn) << PAGE_SHIFT) / numa_fake; + uint64_t sz = ((end_pfn - start_pfn) << PAGE_SHIFT) / get_numa_fake(); /* Kludge needed for the hash function */ if ( hweight64(sz) > 1 ) @@ -223,10 +242,10 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) } memset(&nodes,0,sizeof(nodes)); - for ( i = 0; i < numa_fake; i++ ) + for ( i = 0; i < get_numa_fake(); i++ ) { nodes[i].start = (start_pfn << PAGE_SHIFT) + i * sz; - if ( i == numa_fake - 1 ) + if ( i == get_numa_fake() - 1 ) sz = (end_pfn << PAGE_SHIFT) - nodes[i].start; nodes[i].end = nodes[i].start + sz; printk(KERN_INFO @@ -235,7 +254,7 @@ static int __init numa_emulation(uint64_t start_pfn, uint64_t end_pfn) (nodes[i].end - nodes[i].start) >> 20); node_set_online(i); } - if ( compute_memnode_shift(nodes, numa_fake, NULL, &memnode_shift) ) + if ( compute_memnode_shift(nodes, get_numa_fake(), NULL, &memnode_shift) ) { memnode_shift = 0; printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\n"); @@ -254,18 +273,18 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) int i; #ifdef CONFIG_NUMA_EMU - if ( numa_fake && !numa_emulation(start_pfn, end_pfn) ) + if ( get_numa_fake() && !numa_emulation(start_pfn, end_pfn) ) return; #endif #ifdef CONFIG_ACPI_NUMA - if ( !numa_off && !acpi_scan_nodes((uint64_t)start_pfn << PAGE_SHIFT, + if ( !is_numa_off() && !acpi_scan_nodes((uint64_t)start_pfn << PAGE_SHIFT, (uint64_t)end_pfn << PAGE_SHIFT) ) return; #endif printk(KERN_INFO "%s\n", - numa_off ? "NUMA turned off" : "No NUMA configuration found"); + is_numa_off() ? "NUMA turned off" : "No NUMA configuration found"); printk(KERN_INFO "Faking a node at %016"PRIx64"-%016"PRIx64"\n", (uint64_t)start_pfn << PAGE_SHIFT, @@ -312,7 +331,7 @@ static int __init numa_setup(char *opt) if ( !strncmp(opt,"noacpi",6) ) { numa_off = 0; - acpi_numa = -1; + acpi_numa = 0; } #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1cd290e..4410e53 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -241,7 +241,7 @@ void srat_detect_node(int cpu) node_set_online(node); numa_set_node(cpu, node); - if ( opt_cpu_info && acpi_numa > 0 ) + if ( opt_cpu_info && get_acpi_numa() ) printk("CPU %d APIC %d -> Node %d\n", cpu, apicid, node); } diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index 2d0c047..ccacbcd 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -153,7 +153,7 @@ static void __init bad_srat(void) { int i; printk(KERN_ERR "SRAT: SRAT not used.\n"); - acpi_numa = -1; + set_acpi_numa(0); for (i = 0; i < MAX_LOCAL_APIC; i++) apicid_to_node[i] = NUMA_NO_NODE; for (i = 0; i < ARRAY_SIZE(pxm2node); i++) @@ -232,7 +232,7 @@ acpi_numa_x2apic_affinity_init(const struct acpi_srat_x2apic_cpu_affinity *pa) apicid_to_node[pa->apic_id] = node; node_set(node, processor_nodes_parsed); - acpi_numa = 1; + set_acpi_numa(1); printk(KERN_INFO "SRAT: PXM %u -> APIC %08x -> Node %u\n", pxm, pa->apic_id, node); } @@ -265,7 +265,7 @@ acpi_numa_processor_affinity_init(const struct acpi_srat_cpu_affinity *pa) } apicid_to_node[pa->apic_id] = node; node_set(node, processor_nodes_parsed); - acpi_numa = 1; + set_acpi_numa(1); printk(KERN_INFO "SRAT: PXM %u -> APIC %02x -> Node %u\n", pxm, pa->apic_id, node); } @@ -418,7 +418,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE)) return 0; - if (numa_off) + if (is_numa_off()) printk(KERN_INFO "SRAT: %013"PRIx64"-%013"PRIx64"\n", ma->base_address, ma->base_address + ma->length - 1); @@ -433,7 +433,7 @@ void __init srat_parse_regions(uint64_t addr) uint64_t mask; unsigned int i; - if (acpi_disabled || acpi_numa < 0 || + if (acpi_disabled || (get_acpi_numa() == 0) || acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) return; @@ -462,7 +462,7 @@ int __init acpi_scan_nodes(uint64_t start, uint64_t end) for (i = 0; i < MAX_NUMNODES; i++) cutoff_node(i, start, end); - if (acpi_numa <= 0) + if (get_acpi_numa() == 0) return -1; if (!nodes_cover_memory()) { diff --git a/xen/include/asm-x86/acpi.h b/xen/include/asm-x86/acpi.h index a766688..9298d42 100644 --- a/xen/include/asm-x86/acpi.h +++ b/xen/include/asm-x86/acpi.h @@ -103,7 +103,6 @@ extern void acpi_reserve_bootmem(void); #define ARCH_HAS_POWER_INIT 1 -extern s8 acpi_numa; extern int acpi_scan_nodes(u64 start, u64 end); #define NR_NODE_MEMBLKS (MAX_NUMNODES*2) diff --git a/xen/include/asm-x86/numa.h b/xen/include/asm-x86/numa.h index bb22bff..ae5768b 100644 --- a/xen/include/asm-x86/numa.h +++ b/xen/include/asm-x86/numa.h @@ -30,10 +30,7 @@ extern nodeid_t pxm_to_node(unsigned int pxm); extern void numa_add_cpu(int cpu); extern void numa_init_array(void); -extern bool_t numa_off; - - -extern int srat_disabled(void); +extern bool srat_disabled(void); extern void numa_set_node(int cpu, nodeid_t node); extern nodeid_t setup_node(unsigned int pxm); extern void srat_detect_node(int cpu); diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h index 7aef1a8..7f6d090 100644 --- a/xen/include/xen/numa.h +++ b/xen/include/xen/numa.h @@ -18,4 +18,7 @@ (((d)->vcpu != NULL && (d)->vcpu[0] != NULL) \ ? vcpu_to_node((d)->vcpu[0]) : NUMA_NO_NODE) +bool is_numa_off(void); +bool get_acpi_numa(void); +void set_acpi_numa(bool val); #endif /* _XEN_NUMA_H */