Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5393942imu; Sun, 25 Nov 2018 23:04:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/XFDN0SDfZFhmCT3KD0aXkJAwkWw/S7wxkUW2XHtZ0HEWS56ISqF0wwGT0GU4IHOb9ssXLl X-Received: by 2002:a17:902:66e5:: with SMTP id e92-v6mr25905731plk.92.1543215899634; Sun, 25 Nov 2018 23:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543215899; cv=none; d=google.com; s=arc-20160816; b=H5Q540Z6xsdNg7TLsB+1YaVc9yl5xnQwmoLim25ZRmqplfxCK3or5sd6UUAk8zvBj1 PZ71jgroh7PHySP5TYUJfUQq4PmkyjvMzsojKZjilu+1F5VicDLPDUeIE4pb+Cw7H8U4 EictxqL/e7ttDh6OV9exYr66qhhXdEkrd6CYMSf8yExy0LU7u1wVQYIBntNf2jpEURhX LnuJWJPZZcrd57cYO7nFxqVKExEUhkA77LMfP/ZQM3yOgAmrRTNQV+x3qaA9skeE5FbX 44hKZpdoJors8OdweX0NEPdnu6Lgbg86sVIzkH4k3LVDh239zz3VXA17fswbXcIKJBCj ZuWQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5mKetchbbxmktaKDqO7FxoLDP7UxIVGXamnDC6zQ/hs=; b=zhJ0nr6kn/fFVLjVPsIQMfShJsTBAbP+6HetxRuIhPYBNwXJOdEbT+z/+FU5F+up0I Es3aF642FjqIpV4miFiT+Hp/oUkBUzpiQ9kKF4nZms6iWiJoEehQ4pfV8ZLhp32Yw6B/ sNktunXILzwxPEgKCa6udkL2VdCVNC7kg609jOp8cAlUhrOxh/mpkRaxp2I/eg/kL6pJ URMQGw/ZC5rkVlRtX5Sm7/x+6knW9zM+8t5CbRkldqCFbeo91ZvZKaEmUvVg+ECgeuUM vE1mdLhosc8ZbCunL2ps6TAKrI6CfCEx1TbNZG/AWiHDRifiA905iIWvXMIperioA7WS WnxQ== 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 o3-v6si65527141pld.329.2018.11.25.23.04.44; Sun, 25 Nov 2018 23:04:59 -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 S1726253AbeKZR5P (ORCPT + 99 others); Mon, 26 Nov 2018 12:57:15 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:39542 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726153AbeKZR5P (ORCPT ); Mon, 26 Nov 2018 12:57:15 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 433Hvl3vJ8z9vF7M; Mon, 26 Nov 2018 08:04:03 +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 pZ8NDTZPOyfG; Mon, 26 Nov 2018 08:04:03 +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 433Hvl36lqz9vF7K; Mon, 26 Nov 2018 08:04:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 03DA48B77B; Mon, 26 Nov 2018 08:04:04 +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 gcSdqzHHraiK; Mon, 26 Nov 2018 08:04:03 +0100 (CET) Received: from PO15451 (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 863318B74B; Mon, 26 Nov 2018 08:04:03 +0100 (CET) Subject: Re: [PATCH 5/5] arch: simplify several early memory allocations To: Mike Rapoport , linux-kernel@vger.kernel.org Cc: Michal Hocko , linux-sh@vger.kernel.org, linux-mm@kvack.org, Rich Felker , Paul Mackerras , sparclinux@vger.kernel.org, Vincent Chen , Jonas Bonn , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Russell King , Mark Salter , Arnd Bergmann , Stefan Kristiansson , openrisc@lists.librecores.org, Greentime Hu , Stafford Horne , Guan Xuetao , linux-arm-kernel@lists.infradead.org, Michal Simek , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" References: <1543182277-8819-1-git-send-email-rppt@linux.ibm.com> <1543182277-8819-6-git-send-email-rppt@linux.ibm.com> From: Christophe LEROY Message-ID: <7a92357c-6251-fe84-d724-16fdc49d03a3@c-s.fr> Date: Mon, 26 Nov 2018 08:03:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <1543182277-8819-6-git-send-email-rppt@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/11/2018 à 22:44, Mike Rapoport a écrit : > There are several early memory allocations in arch/ code that use > memblock_phys_alloc() to allocate memory, convert the returned physical > address to the virtual address and then set the allocated memory to zero. > > Exactly the same behaviour can be achieved simply by calling > memblock_alloc(): it allocates the memory in the same way as > memblock_phys_alloc(), then it performs the phys_to_virt() conversion and > clears the allocated memory. > > Replace the longer sequence with a simpler call to memblock_alloc(). > > Signed-off-by: Mike Rapoport > --- > arch/arm/mm/mmu.c | 4 +--- > arch/c6x/mm/dma-coherent.c | 9 ++------- > arch/nds32/mm/init.c | 12 ++++-------- > arch/powerpc/kernel/setup-common.c | 4 ++-- > arch/powerpc/mm/pgtable_32.c | 4 +--- > arch/powerpc/mm/ppc_mmu_32.c | 3 +-- > arch/powerpc/platforms/powernv/opal.c | 3 +-- > arch/sparc/kernel/prom_64.c | 7 ++----- > arch/sparc/mm/init_64.c | 9 +++------ > arch/unicore32/mm/mmu.c | 4 +--- > 10 files changed, 18 insertions(+), 41 deletions(-) > [...] > diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c > index bda3c6f..9931e68 100644 > --- a/arch/powerpc/mm/pgtable_32.c > +++ b/arch/powerpc/mm/pgtable_32.c > @@ -50,9 +50,7 @@ __ref pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) > if (slab_is_available()) { > pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO); > } else { > - pte = __va(memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE)); > - if (pte) > - clear_page(pte); > + pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE); memblock_alloc() uses memset to zeroize the block. clear_page() is more performant than memset(). Christophe [...]