Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4812760imu; Tue, 8 Jan 2019 06:47:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ye4fD+vgpokAH5+9PipNl3ZTPo308dHXXqengvWC1bMqxxIRly7Nr1i50o2Jn8ID0K0Za X-Received: by 2002:a62:870e:: with SMTP id i14mr2061762pfe.41.1546958827187; Tue, 08 Jan 2019 06:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546958827; cv=none; d=google.com; s=arc-20160816; b=0/h6bF2NJlETkY17SCCL6hxu41Afw1xXkvlr5RA+RfAyE7DNVoXBoGwDStr3hoEcYQ YFJypMeeWSy8/Mo08sIJKe5I1UGMxTcDZC2PTnF6A7GetHCXhgynsWSiTXEWt85ZFUbS 0vTS6JbZvaNX254tSFI7FBhX7p6RGUm3iMlyyy+a8J/1gCnLaoZOncQVdRrg50Zair12 +Nl5RjY77xvGEfClnA1x6DDAYRv9xRZdITfpoPA/LcVzZHcMFaZSurgwPBmaS6K5sFDN l7bi0/trmPANXFC9vuzhvezL1ex4gM3rZ+hzgeL7b2jpHbgFe1kRfbMFIbSCHBtBMd7y 31rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=voknFrLyZRoKkRnj+tQyrJLWwX5lnxXAY0PzClDUfPQ=; b=Z+wEYMrhCZdeWm/mnIsUxNHFFn6Ts5UcoyFXhtQ86n67YQS18R0NST3GCQfdcWWkXj ukgQLqQbf/a+hS+H8M3RqEVe2LE2W28KIBSnVc87CvFyAjXQq6Ml3/Ge/d2+Gk8LOCMu UX1U78Mu0Qs7O88eS751WUKSZ4dGWD5vhK9cezjNjYQByJtcSIiy+hHCmEXYGwCwKMUh y0en2aqBNux74Bmv1vHm6I2/XC/+qeCaOXbWPNKgRo9+cli9ner3u9h1RWms9lqlhVSE NfxBBL0yBWHCSquiEwxnJRFKdxkmugCCLmXZJiMu7MLMzGoHHo7H1fdv+7UN/1TpBo4S eYpw== 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 r14si9253298pgh.39.2019.01.08.06.46.50; Tue, 08 Jan 2019 06:47:07 -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 S1728253AbfAHNnN (ORCPT + 99 others); Tue, 8 Jan 2019 08:43:13 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:15075 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbfAHNnL (ORCPT ); Tue, 8 Jan 2019 08:43:11 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43YtkN6KwZz9tyMy; Tue, 8 Jan 2019 14:43:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id pYx6BQ4vhwHl; Tue, 8 Jan 2019 14:43:08 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43YtkN5mpSz9tyMv; Tue, 8 Jan 2019 14:43:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F22608B83C; Tue, 8 Jan 2019 14:43:09 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id f8F9imAQGsDl; Tue, 8 Jan 2019 14:43:09 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A0F838B7DF; Tue, 8 Jan 2019 14:43:09 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 7E2FA717F2; Tue, 8 Jan 2019 13:43:09 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v12 01/10] powerpc/irq: use memblock functions returning virtual address To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Mike Rapoport Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 8 Jan 2019 13:43:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since only the virtual address of allocated blocks is used, lets use functions returning directly virtual address. Those functions have the advantage of also zeroing the block. Suggested-by: Mike Rapoport Signed-off-by: Christophe Leroy --- @Mike: Part of this is taken from your serie. I was not sure how to include you in the commit log, I used Suggested-by: but could use any other property, so if you prefer something different just tell me. Also, if you could review this patch, it would be nice. arch/powerpc/kernel/irq.c | 5 ----- arch/powerpc/kernel/setup_32.c | 15 +++++---------- arch/powerpc/kernel/setup_64.c | 16 ++-------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 916ddc4aac44..4a44bc395fbc 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -725,18 +725,15 @@ void exc_lvl_ctx_init(void) #endif #endif - memset((void *)critirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = critirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = 0; #ifdef CONFIG_BOOKE - memset((void *)dbgirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = dbgirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = 0; - memset((void *)mcheckirq_ctx[cpu_nr], 0, THREAD_SIZE); tp = mcheckirq_ctx[cpu_nr]; tp->cpu = cpu_nr; tp->preempt_count = HARDIRQ_OFFSET; @@ -754,12 +751,10 @@ void irq_ctx_init(void) int i; for_each_possible_cpu(i) { - memset((void *)softirq_ctx[i], 0, THREAD_SIZE); tp = softirq_ctx[i]; tp->cpu = i; klp_init_thread_info(tp); - memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); tp = hardirq_ctx[i]; tp->cpu = i; klp_init_thread_info(tp); diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 947f904688b0..bfe1b46a26dc 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -203,10 +203,8 @@ void __init irqstack_early_init(void) /* interrupt stacks must be in lowmem, we get that for free on ppc32 * as the memblock is limited to lowmem by default */ for_each_possible_cpu(i) { - softirq_ctx[i] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); - hardirq_ctx[i] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + softirq_ctx[i] = memblock_alloc(THREAD_SIZE, THREAD_SIZE); + hardirq_ctx[i] = memblock_alloc(THREAD_SIZE, THREAD_SIZE); } } @@ -224,13 +222,10 @@ void __init exc_lvl_early_init(void) hw_cpu = 0; #endif - critirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + critirq_ctx[hw_cpu] = memblock_alloc(THREAD_SIZE, THREAD_SIZE); #ifdef CONFIG_BOOKE - dbgirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); - mcheckirq_ctx[hw_cpu] = (struct thread_info *) - __va(memblock_phys_alloc(THREAD_SIZE, THREAD_SIZE)); + dbgirq_ctx[hw_cpu] = memblock_alloc(THREAD_SIZE, THREAD_SIZE); + mcheckirq_ctx[hw_cpu] = memblock_alloc(THREAD_SIZE, THREAD_SIZE); #endif } } diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 236c1151a3a7..943503f1e2c0 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -634,19 +634,10 @@ __init u64 ppc64_bolted_size(void) static void *__init alloc_stack(unsigned long limit, int cpu) { - unsigned long pa; - BUILD_BUG_ON(STACK_INT_FRAME_SIZE % 16); - pa = memblock_alloc_base_nid(THREAD_SIZE, THREAD_SIZE, limit, - early_cpu_to_node(cpu), MEMBLOCK_NONE); - if (!pa) { - pa = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); - if (!pa) - panic("cannot allocate stacks"); - } - - return __va(pa); + return memblock_alloc_try_nid(THREAD_SIZE, THREAD_SIZE, MEMBLOCK_LOW_LIMIT, + limit, early_cpu_to_node(cpu)); } void __init irqstack_early_init(void) @@ -739,20 +730,17 @@ void __init emergency_stack_init(void) struct thread_info *ti; ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->emergency_sp = (void *)ti + THREAD_SIZE; #ifdef CONFIG_PPC_BOOK3S_64 /* emergency stack for NMI exception handling. */ ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->nmi_emergency_sp = (void *)ti + THREAD_SIZE; /* emergency stack for machine check exception handling. */ ti = alloc_stack(limit, i); - memset(ti, 0, THREAD_SIZE); emerg_stack_init_thread_info(ti, i); paca_ptrs[i]->mc_emergency_sp = (void *)ti + THREAD_SIZE; #endif -- 2.13.3