Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5412782imu; Sun, 25 Nov 2018 23:27:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/VcKktaE8ZR55YOtXdJGh7AvHv11d8b3yBENw2XWesy8euaQ73uBz3UxMXK2zUFe/98Gqqq X-Received: by 2002:a17:902:14e:: with SMTP id 72mr13873636plb.287.1543217226832; Sun, 25 Nov 2018 23:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543217226; cv=none; d=google.com; s=arc-20160816; b=XTLKhdtk4R3agPup6hrMu9YhGxdl1okCunqPpH7Lp/q0eWbE8WEZg0hikA2oQh1jZY wzLk5dSxemxXM1Z8AX4fu8lC9bIlwVSiVeoSny18ZW5sJsh9FS04/bMMPgKBsRYDj2Aj qmfqFXAXa/IgzEl0DfKQOVUJH9JH3OcgXuIwapp2zw/hLNah9IPfUJ7e4KmU8Zwpx4o3 OyrGJ3Gy5IqKylCwMhSqAz93scNDA09Erm7fEzrNLupG7eIuoKe+Bcifcz7aK8M9F5EL bP80xNjf0r733/JUno2073QDLbf48peq1o46U9YfeL0x49FNJgqPoCwKgvvYCbGzKI8C G7IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:subject:cc:to:from:date; bh=mfkzCDnEakHSRnm2Z65lJsgswfQe1JFMsmpareF8TOQ=; b=fOKMuViyyMsqpixs3HrtROfqmX1JGRJVAnSRd0SG/A9gLhq5pmNrq1rbz60zZFMUE9 +DVDX+MtCSVbhq9CGnQfPYvsyn2h1xAG5JaGQHIO4M69oWPsEAtvmjKQsMzyMlRwkLV5 jGRiRCgkECQ+Ss/4TO3iQOsv7FOzDU/bovveV+0YzoDeEmT+4wq+QFo3szJhxAyvWZsa lNpx/XDFKvB0ZRzWkti5O8Z0GG4kNi5GpKWy3XUoYojdggYab9XYoqfGNaTrei9JipvD X4rHwKAJji3523AXXVVAKUuKEVfVL3QtUDoiP5HXIDcj/zAx4oqiDSKTju8ezENWd2af iGHA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si30731101plp.130.2018.11.25.23.26.52; Sun, 25 Nov 2018 23:27:06 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726399AbeKZSTM (ORCPT + 99 others); Mon, 26 Nov 2018 13:19:12 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44990 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726147AbeKZSTM (ORCPT ); Mon, 26 Nov 2018 13:19:12 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAQ7Pfvp085306 for ; Mon, 26 Nov 2018 02:25:59 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p0c2bguwx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 26 Nov 2018 02:25:58 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Nov 2018 07:25:57 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 26 Nov 2018 07:25:51 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAQ7Posj8716688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Nov 2018 07:25:50 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF6CC11C04C; Mon, 26 Nov 2018 07:25:49 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F12F11C04A; Mon, 26 Nov 2018 07:25:48 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.115]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 26 Nov 2018 07:25:48 +0000 (GMT) Date: Mon, 26 Nov 2018 09:25:46 +0200 From: Mike Rapoport To: Christophe LEROY Cc: linux-kernel@vger.kernel.org, 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" Subject: Re: [PATCH 5/5] arch: simplify several early memory allocations References: <1543182277-8819-1-git-send-email-rppt@linux.ibm.com> <1543182277-8819-6-git-send-email-rppt@linux.ibm.com> <7a92357c-6251-fe84-d724-16fdc49d03a3@c-s.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7a92357c-6251-fe84-d724-16fdc49d03a3@c-s.fr> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18112607-4275-0000-0000-000002E6AA64 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112607-4276-0000-0000-000037F3E223 Message-Id: <20181126072546.GB14863@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-26_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811260069 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 08:03:55AM +0100, Christophe LEROY wrote: > > > 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(). As far as I can tell, the majority of the page table pages will be anyway allocated with __get_free_page() so I think the performance loss here will negligible. > Christophe > > [...] > -- Sincerely yours, Mike.