From patchwork Tue Feb 13 15:08:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 872896 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 3zgmRB0Q84z9t3F for ; Wed, 14 Feb 2018 02:19:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MwhxYUkx"; 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 3zgmR96FQ3zF1RD for ; Wed, 14 Feb 2018 02:19:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MwhxYUkx"; 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:c05::242; helo=mail-pg0-x242.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="MwhxYUkx"; dkim-atps=neutral Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 3zgmC66y88zF1P2 for ; Wed, 14 Feb 2018 02:08:50 +1100 (AEDT) Received: by mail-pg0-x242.google.com with SMTP id t4so35570pgp.8 for ; Tue, 13 Feb 2018 07:08:50 -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=YMJhQMibocwB51ljHao0xzHOs0KCcweYGy7wJoUQpfw=; b=MwhxYUkxFjUCL47ekByf9txOYlfVsnbMvXiva3B7ZKTpBdEE+iquTVbEHmTVYgtzYj mV26f+exRMbSGE8sV79xW+h+3ArNfR35ACDlNpk+GTVO4yiumnbk/Dz21AAN2/Rt3bv5 Uu9y2ne0XxTaKja9rF53yv0drKTgu7GdnuuLgNmOJ5Dv+3KUj7E2es2OmNf7cFhkVtXz kf13xWZ/T0ou1qnN9ou6tvY7oazd7jS0Aaf7vXG/zNljFHVLeBV9BWW/HFKpnoAAfHc8 4lBvzJkUPQFozoxSQOwYyQ0jxiTamQAI7JpYxtcCTeO/EhOK7HBZT7vFBqrvhJhKbVCg +W5g== 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=YMJhQMibocwB51ljHao0xzHOs0KCcweYGy7wJoUQpfw=; b=NItBXeRJABUe7nCyGt50zL1ybhlUre6tcUh3+b2dEi6qZGT6MI0S6ca8lmENwJbjCJ 5upAU9srPHu2pTqkNPymD954Q+13LAQMBiZDE716+WLSYn2WfzRpVjAeqCiqhqzvYGo9 lCUNYVuh2cPfMERMWO5HRfHGkLs/l0G3rDPEGw9I/P9VMgUl9FfA5b/sA6LRAf0ZDaCB SfL2oRHqlsTBM/GapcD+LLilQhIrDQel8a8xf3HpAC//WIUgFEhUFcVxpjFPR0WLZlr4 I8bKNz9FWBqSPj6ui98WBgYVUEAQ5dcrQmLAxRuc1gloFeACG+nFiCR6bQuGoeJM8MMk XDrA== X-Gm-Message-State: APf1xPDUi48BdHkB8Cb+MW7ZmcXhwLGD1O3nz6nfsOQ4YnRYOFk9Inio uEs0qFgTpLb/RjIDQRj8h+311Q== X-Google-Smtp-Source: AH8x224ARqTo2+n9EpTxqjFmKB/+ilFdM0EM2SmiHKKWCR2g8OUvfvk3O90K1Krxl3Cuq4flPRrceg== X-Received: by 10.99.122.70 with SMTP id j6mr1226354pgn.17.1518534527968; Tue, 13 Feb 2018 07:08:47 -0800 (PST) Received: from roar.local0.net ([202.7.219.42]) by smtp.gmail.com with ESMTPSA id f123sm24720533pgc.55.2018.02.13.07.08.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 07:08:47 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 04/14] powerpc/64s: allocate slb_shadow structures individually Date: Wed, 14 Feb 2018 01:08:14 +1000 Message-Id: <20180213150824.27689-5-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" Allocate slb_shadow structures individually. slb_shadow structures are avoided for radix environment. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/paca.c | 65 +++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c index 6cddb9bdc151..2699f9009286 100644 --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -72,41 +72,28 @@ static void __init free_lppaca(struct lppaca *lp) #ifdef CONFIG_PPC_BOOK3S_64 /* - * 3 persistent SLBs are registered here. The buffer will be zero + * 3 persistent SLBs are allocated here. The buffer will be zero * initially, hence will all be invaild until we actually write them. * * If you make the number of persistent SLB entries dynamic, please also * update PR KVM to flush and restore them accordingly. */ -static struct slb_shadow * __initdata slb_shadow; - -static void __init allocate_slb_shadows(int nr_cpus, int limit) -{ - int size = PAGE_ALIGN(sizeof(struct slb_shadow) * nr_cpus); - - if (early_radix_enabled()) - return; - - slb_shadow = __va(memblock_alloc_base(size, PAGE_SIZE, limit)); - memset(slb_shadow, 0, size); -} - -static struct slb_shadow * __init init_slb_shadow(int cpu) +static struct slb_shadow * __init new_slb_shadow(int cpu, unsigned long limit) { struct slb_shadow *s; - if (early_radix_enabled()) - return NULL; + if (cpu != boot_cpuid) { + /* + * Boot CPU comes here before early_radix_enabled + * is parsed (e.g., for disable_radix). So allocate + * always and this will be fixed up in free_unused_pacas. + */ + if (early_radix_enabled()) + return NULL; + } - s = &slb_shadow[cpu]; - - /* - * When we come through here to initialise boot_paca, the slb_shadow - * buffers are not allocated yet. That's OK, we'll get one later in - * boot, but make sure we don't corrupt memory at 0. - */ - if (!slb_shadow) - return NULL; + s = __va(memblock_alloc_base(sizeof(*s), L1_CACHE_BYTES, limit)); + memset(s, 0, sizeof(*s)); s->persistent = cpu_to_be32(SLB_NUM_BOLTED); s->buffer_length = cpu_to_be32(sizeof(*s)); @@ -114,10 +101,6 @@ static struct slb_shadow * __init init_slb_shadow(int cpu) return s; } -#else /* !CONFIG_PPC_BOOK3S_64 */ - -static void __init allocate_slb_shadows(int nr_cpus, int limit) { } - #endif /* CONFIG_PPC_BOOK3S_64 */ /* The Paca is an array with one entry per processor. Each contains an @@ -151,7 +134,7 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu) new_paca->__current = &init_task; new_paca->data_offset = 0xfeeeeeeeeeeeeeeeULL; #ifdef CONFIG_PPC_BOOK3S_64 - new_paca->slb_shadow_ptr = init_slb_shadow(cpu); + new_paca->slb_shadow_ptr = NULL; #endif #ifdef CONFIG_PPC_BOOK3E @@ -222,13 +205,16 @@ void __init allocate_pacas(void) printk(KERN_DEBUG "Allocated %lu bytes for %u pacas\n", size, nr_cpu_ids); - allocate_slb_shadows(nr_cpu_ids, limit); - /* Can't use for_each_*_cpu, as they aren't functional yet */ for (cpu = 0; cpu < nr_cpu_ids; cpu++) { - initialise_paca(paca_ptrs[cpu], cpu); + struct paca_struct *paca = paca_ptrs[cpu]; + + initialise_paca(paca, cpu); #ifdef CONFIG_PPC_PSERIES - paca_ptrs[cpu]->lppaca_ptr = new_lppaca(cpu, limit); + paca->lppaca_ptr = new_lppaca(cpu, limit); +#endif +#ifdef CONFIG_PPC_BOOK3S_64 + paca->slb_shadow_ptr = new_slb_shadow(cpu, limit); #endif } } @@ -263,6 +249,15 @@ void __init free_unused_pacas(void) paca_nr_cpu_ids = nr_cpu_ids; paca_ptrs_size = new_ptrs_size; + +#ifdef CONFIG_PPC_BOOK3S_64 + if (early_radix_enabled()) { + /* Ugly fixup, see new_slb_shadow() */ + memblock_free(__pa(paca_ptrs[boot_cpuid]->slb_shadow_ptr), + sizeof(struct slb_shadow)); + paca_ptrs[boot_cpuid]->slb_shadow_ptr = NULL; + } +#endif } void copy_mm_to_paca(struct mm_struct *mm)