Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2117609ybl; Thu, 9 Jan 2020 07:11:50 -0800 (PST) X-Google-Smtp-Source: APXvYqz20rydllDchrPsTtWh1NrOIAjJH4utHM3WfpvQvMFiEGPNOmAlu+NYGm3muxTHl5e0HsX5 X-Received: by 2002:aca:d6d2:: with SMTP id n201mr3621626oig.112.1578582710757; Thu, 09 Jan 2020 07:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578582710; cv=none; d=google.com; s=arc-20160816; b=u+k2vlhRYN1qagRKMQs6FthiIzTfH07838c5dKQT5tuMzTqWfujC/Udhn30k0TKXoo EJhHfbNoMIZXXXK0cdcDWkMCYRnHinhwYNUdn9yVEONqhm5d+QE1Atc2sMfAUMmST3zg InjqHdnG4jBKHD/FSB+98cL9mbX37IQiuVUFK6mtny2ulqVIVxe3L/RTwUbLKrTfXoGV WDLGstpj0qjqdLhcgy8REqvn9+nvP7+Kl5WXXj/veE6/uU0yRfHJaJYU82wxIneEb7mR 6V1RYCaxIfjtlWmzgh32YEVHENAdq5Ew0eObG2fQtDuIwAF/B3Sb8Bj2YAjGX+PD8hrb 6w6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jbuVQ6K6dttdXv41t39pw8taO3WfFe0RTSvfm7JAe5g=; b=orFg9Oo2E2UEFjOtohudnT+qDZepxSf9Nfj7ldEJHnrmVYppZjvxVccvsoe8UBKXZL a3aDSsOanv5VANI9VgDWXUFsx0m9obV/h5lI7yk1PHVAk6dX7pMxNwvvjtBg+kio1Fr9 ZgUhyHc7HRD7vdRppOC4/SapNOxRH1md8iD3Se3e/DQCtIMezXcxyEBTBSYJg/pOnzJx jBKHzwjxpbos8kN978D5RIO1qyaBHH7CwAj71fnhw0lxhEMdCL8jPdej2bHsqOkvw/WH 9C7Nlrydphs/ZBHza0wqDX/tCxCetgP6sJvp0TL5ac4nEhRw14QXp1vbucmZvlqxspe3 IriQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si4024579otq.262.2020.01.09.07.11.37; Thu, 09 Jan 2020 07:11:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730899AbgAIMXu (ORCPT + 99 others); Thu, 9 Jan 2020 07:23:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:35270 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbgAIMXt (ORCPT ); Thu, 9 Jan 2020 07:23:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 12D44B2181; Thu, 9 Jan 2020 12:23:45 +0000 (UTC) From: Thomas Bogendoerfer To: Paul Burton Cc: Ralf Baechle , James Hogan , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] MIPS: mm: Place per_cpu on different nodes, if NUMA is enabled Date: Thu, 9 Jan 2020 13:23:31 +0100 Message-Id: <20200109122331.4109-3-tbogendoerfer@suse.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200109122331.4109-1-tbogendoerfer@suse.de> References: <20200109122331.4109-1-tbogendoerfer@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement placing of per_cpu into memory, which is local to the CPU. Signed-off-by: Thomas Bogendoerfer --- arch/mips/Kconfig | 8 ++++++++ arch/mips/mm/init.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ed8e28b0fb3e..cf56b3211a2b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2696,6 +2696,14 @@ config NUMA config SYS_SUPPORTS_NUMA bool +config HAVE_SETUP_PER_CPU_AREA + def_bool y + depends on NUMA + +config NEED_PER_CPU_EMBED_FIRST_CHUNK + def_bool y + depends on NUMA + config RELOCATABLE bool "Relocatable kernel" depends on SYS_SUPPORTS_RELOCATABLE && (CPU_MIPS32_R2 || CPU_MIPS64_R2 || CPU_MIPS32_R6 || CPU_MIPS64_R6 || CAVIUM_OCTEON_SOC) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 50f9ed8c6c1b..79684000de0e 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -508,6 +508,51 @@ void __ref free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } +#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA +unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; +EXPORT_SYMBOL(__per_cpu_offset); + +static int __init pcpu_cpu_distance(unsigned int from, unsigned int to) +{ + return node_distance(cpu_to_node(from), cpu_to_node(to)); +} + +static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, + size_t align) +{ + return memblock_alloc_try_nid(size, align, __pa(MAX_DMA_ADDRESS), + MEMBLOCK_ALLOC_ACCESSIBLE, + cpu_to_node(cpu)); +} + +static void __init pcpu_fc_free(void *ptr, size_t size) +{ + memblock_free_early(__pa(ptr), size); +} + +void __init setup_per_cpu_areas(void) +{ + unsigned long delta; + unsigned int cpu; + int rc; + + /* + * Always reserve area for module percpu variables. That's + * what the legacy allocator did. + */ + rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE, + PERCPU_DYNAMIC_RESERVE, PAGE_SIZE, + pcpu_cpu_distance, + pcpu_fc_alloc, pcpu_fc_free); + if (rc < 0) + panic("Failed to initialize percpu areas."); + + delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start; + for_each_possible_cpu(cpu) + __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu]; +} +#endif + #ifndef CONFIG_MIPS_PGD_C0_CONTEXT unsigned long pgd_current[NR_CPUS]; #endif -- 2.24.1