From patchwork Tue Feb 13 15:08:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 872919 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zgmkW3VHtz9t3F for ; Wed, 14 Feb 2018 02:32:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZfRbZCP1"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zgmkW1zSMzF0y7 for ; Wed, 14 Feb 2018 02:32:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZfRbZCP1"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::241; helo=mail-pl0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZfRbZCP1"; dkim-atps=neutral Received: from mail-pl0-x241.google.com (mail-pl0-x241.google.com [IPv6:2607:f8b0:400e:c01::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zgmCS5CfgzF1Q9 for ; Wed, 14 Feb 2018 02:09:08 +1100 (AEDT) Received: by mail-pl0-x241.google.com with SMTP id p5so6752253plo.12 for ; Tue, 13 Feb 2018 07:09:08 -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=pYeoQ9aRIV0kGdx/9vdqqCktsnsKId+gy03kj3MZG0E=; b=ZfRbZCP1p5u/KR10Vd5FHbT3SYQO6qrpby1uFGJa+4ejHBMi5HmCaZlDGehVGXfGvB 3pWNSBtrY5U/++FamjlP9j4mi9EDCalHTfEUDNr0fhBW7GZ8WEoWfw8mCuE2E6E9Ju0t nhYRPKfIDJif3oyjRPEsj5xI9XOMgj+7faPR+RxDcEoxMHSusXCtHH6h8RUD6mHOdl2l jvcKCU8AjUDlajqkd1mlyf1KGEdwFVLuA0azUgIiOv+SSzFyUyj43PZnmHyu3rdRxetD YIOnAJ5OsGnJgzjnuOBdbkHMdU3AmuJpIWlzikF8Jf+6NygSjqt2zrcd0WsZVrzUY7K8 2awA== 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=pYeoQ9aRIV0kGdx/9vdqqCktsnsKId+gy03kj3MZG0E=; b=IwYi3si/aG6kBJ7/zQ0zuBX/NqHows78K6FbyjTshERyTrvTCWY6bwLj38bvZEN0nh RuXB1JPrLPVn+65DdshcTQzUcKs4zTO0rJfVEEzY8Ed0vHgY1LvgHesRSM/t7cxdTJhg Ec58rFNNJp3snlY5R0FfT0nGskDffAsTwe9tLbwJOmdii+iml7O6WynWHQhvjG6oY9nG Xj5StdsF+0KDa9InHYvv8xEcLpIQoHsD1ldx8YK/1Uim02DyDNrVCkGBZUFwWoQixj4r ViETjUcgasK9hdLXZmry33uoKvsV4R+ydP/1zq+BZBByMG0lnPYtshMOXXJvhr9GgJ0w tQUA== X-Gm-Message-State: APf1xPA/PMpaKM98fNLDSWi4dc74NlWKbWw/OsQuwMV7GR4LtjWgIqnz L4KNoWWFHfsIOG05gaOepc++Qg== X-Google-Smtp-Source: AH8x225Y9q0jA9x+QR2iRjR/YT13wFMiAylqDhaN1cfDAg1M66spIBAe1CXl9CgYKy5pqChe2QK90g== X-Received: by 2002:a17:902:526d:: with SMTP id z100-v6mr1413857plh.396.1518534546712; Tue, 13 Feb 2018 07:09:06 -0800 (PST) Received: from roar.local0.net ([202.7.219.42]) by smtp.gmail.com with ESMTPSA id f123sm24720533pgc.55.2018.02.13.07.09.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 07:09:05 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 10/14] powerpc/64: allocate pacas per node Date: Wed, 14 Feb 2018 01:08:20 +1000 Message-Id: <20180213150824.27689-11-npiggin@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180213150824.27689-1-npiggin@gmail.com> References: <20180213150824.27689-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Per-node allocations are possible on 64s with radix that does not have the bolted SLB limitation. Hash would be able to do the same if all CPUs had the bottom of their node-local memory bolted as well. This is left as an exercise for the reader. --- arch/powerpc/kernel/paca.c | 41 +++++++++++++++++++++++++++++++++++------ arch/powerpc/kernel/setup_64.c | 4 ++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 12d329467631..470ce21af8b5 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -20,6 +20,37 @@ #include "setup.h" +static void *__init alloc_paca_data(unsigned long size, unsigned long align, + unsigned long limit, int cpu) +{ + unsigned long pa; + int nid; + + /* + * boot_cpuid paca is allocated very early before cpu_to_node is up. + * Set bottom-up mode, because the boot CPU should be on node-0, + * which will put its paca in the right place. + */ + if (cpu == boot_cpuid) { + nid = -1; + memblock_set_bottom_up(true); + } else { + nid = early_cpu_to_node(cpu); + } + + pa = memblock_alloc_base_nid(size, align, limit, nid, MEMBLOCK_NONE); + if (!pa) { + pa = memblock_alloc_base(size, align, limit); + if (!pa) + panic("cannot allocate paca data"); + } + + if (cpu == boot_cpuid) + memblock_set_bottom_up(false); + + return __va(pa); +} + #ifdef CONFIG_PPC_PSERIES /* @@ -52,7 +83,7 @@ static struct lppaca * __init new_lppaca(int cpu, unsigned long limit) if (early_cpu_has_feature(CPU_FTR_HVMODE)) return NULL; - lp = __va(memblock_alloc_base(size, 0x400, limit)); + lp = alloc_paca_data(size, 0x400, limit, cpu); init_lppaca(lp); return lp; @@ -82,7 +113,7 @@ static struct slb_shadow * __init new_slb_shadow(int cpu, unsigned long limit) return NULL; } - s = __va(memblock_alloc_base(sizeof(*s), L1_CACHE_BYTES, limit)); + s = alloc_paca_data(sizeof(*s), L1_CACHE_BYTES, limit, cpu); memset(s, 0, sizeof(*s)); s->persistent = cpu_to_be32(SLB_NUM_BOLTED); @@ -173,7 +204,6 @@ void __init allocate_paca_ptrs(void) void __init allocate_paca(int cpu) { u64 limit; - unsigned long pa; struct paca_struct *paca; BUG_ON(cpu >= paca_nr_cpu_ids); @@ -188,9 +218,8 @@ void __init allocate_paca(int cpu) limit = ppc64_rma_size; #endif - pa = memblock_alloc_base(sizeof(struct paca_struct), - L1_CACHE_BYTES, limit); - paca = __va(pa); + paca = alloc_paca_data(sizeof(struct paca_struct), L1_CACHE_BYTES, + limit, cpu); paca_ptrs[cpu] = paca; memset(paca, 0, sizeof(struct paca_struct)); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index dde34d35d1e7..02fa358982e6 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -312,6 +312,10 @@ void __init early_setup(unsigned long dt_ptr) early_init_devtree(__va(dt_ptr)); /* Now we know the logical id of our boot cpu, setup the paca. */ + if (boot_cpuid != 0) { + /* Poison paca_ptrs[0] again if it's not the boot cpu */ + memset(&paca_ptrs[0], 0x88, sizeof(paca_ptrs[0])); + } setup_paca(paca_ptrs[boot_cpuid]); fixup_boot_paca();