From patchwork Mon Dec 31 09:29:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10745345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 690BB6C5 for ; Mon, 31 Dec 2018 09:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47132289FC for ; Mon, 31 Dec 2018 09:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3339E28A05; Mon, 31 Dec 2018 09:29:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9877E289FC for ; Mon, 31 Dec 2018 09:29:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 481058E008A; Mon, 31 Dec 2018 04:29:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 458B08E005B; Mon, 31 Dec 2018 04:29:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 321C78E008A; Mon, 31 Dec 2018 04:29:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id E2A6A8E005B for ; Mon, 31 Dec 2018 04:29:45 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id x67so2363629pfk.16 for ; Mon, 31 Dec 2018 01:29:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=iJLdI21pzC7kEG6oBhFSNEzBowjY070wKcfx2rOhR0Q=; b=S8BLoIcdcKGrzJiElyktBBh8SuCavFZ1bRxjrhcvmHKkbA4ddiL5V40eolQS7SjQuW TMvStk9KO9padPW3f4a/4z27w9eZnh7MVgkW+chTvM9i+e12ZW68Y1AwrbQvXR22nvj1 3yWYx2cHpskzqTBxqV6aLBGq/cPu2a5+fuMosNY2PHbmVkRfKwMeRAdh7mgfmWZmRgFB gQzE12Pj8HRrPAUmdcvwaWCvTa+JOYu+xNMVol4DuYEcn3Xm1FX5BtOM9gxPIl3bzz4o hH3kPROhjKLAEZ8xcECZ7pBYmMeIqhsf01IZQuMHKiuckk8+VBbnMhzO+7qS4eJLjDMv 3HQA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AJcUukfUppsPnqRsS0XD45dZJvfQku+2mVm+1ON1jjL2JAiuLkKck6AQ Sn64kqL9lsx2zbnyMR2OXNSGEQBZl/5V1uUkfVsA9i1h2w7OwvbLzUJ+8iCaSj6HN9xyuDVUeQe T92IHpJl1IYp/4nhwSsBcbcPZkTVQnNwLYWgbgzCZM0JVrBYbms7yQ9oUlVvi6lR+4Q== X-Received: by 2002:a17:902:161:: with SMTP id 88mr37490159plb.306.1546248585561; Mon, 31 Dec 2018 01:29:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN4AZz2qg6PPFrMMw+4VGbcqR75ClDOTbb7ilCd+i24rUHSMAOtahz+7sTYagCBmtBfHLisX X-Received: by 2002:a17:902:161:: with SMTP id 88mr37490124plb.306.1546248584292; Mon, 31 Dec 2018 01:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546248584; cv=none; d=google.com; s=arc-20160816; b=avUEt0BuvpWR8ngWtBK6id3O5Zeppn5rA0CIqsF957lgJrdklSviXQiLReNJqkqK99 XHjg6GQNy6enF4e2Um+SVZ8iP9GKz2Pvcymq7QsGZ0JTLf7UyUX+h2jL6mltECxwkLKB vjm2G3bt1qXUgAwZQb+RtzapTwpJPf3nKYeE+4r9K+ccVom3oVvyGjIjX25D2gOwgWcv I1lb/XvOBEFi97xorEqnjcyhIKtTWRkRqTSIKlVFPxqsi5Im4snFzvxC44fve07+2R2D jru61tlfI2ACXB+kvKO0j++1mCo4RAn5wuZWhOPU+eVrUi2xuJLVtFlUN3LKK40Ajfon kqVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=iJLdI21pzC7kEG6oBhFSNEzBowjY070wKcfx2rOhR0Q=; b=GvAyFvASRoEtHa7mudLFc5ltALKcW0ABsCYZdWv+H3NLjpsD54G+ZJKPsWy45mfXkR igRocWX3L3pc8tBya3leoJvq9eRGUkZSJ3z8DZixpXbj0phBdrLVrCx27CGI4QtQfLRj dMjGuAMlsFH8gqKVGvSWDXYQvMKCi69H/bVznUvVrkpFItFK57YzAogQnOsNXMfgIt1R YX2ruN+Nr+eySQwCgXfeBCAgVfIIrBDxRvhMh75tjJIPBu+Mic+aznpwAxH3G0bSaRCd SkxI9mCBW+SsSe5XhXC5nY4LsHZFotIFSrEnsh34+/pIIauocCfHaveViyYJVjwp/tHu uUig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id y22si31947085pfa.6.2018.12.31.01.29.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 01:29:44 -0800 (PST) Received-SPF: pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rppt@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=rppt@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBV9SkFA020900 for ; Mon, 31 Dec 2018 04:29:43 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pqdjxnsxf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 31 Dec 2018 04:29:43 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Dec 2018 09:29:40 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 31 Dec 2018 09:29:33 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBV9TWYT26017906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Dec 2018 09:29:32 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 154B84C040; Mon, 31 Dec 2018 09:29:32 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83CC14C04A; Mon, 31 Dec 2018 09:29:28 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.207.181]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 31 Dec 2018 09:29:28 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 31 Dec 2018 11:29:27 +0200 From: Mike Rapoport To: Andrew Morton Cc: Arnd Bergmann , Benjamin Herrenschmidt , "David S. Miller" , Guan Xuetao , Greentime Hu , Heiko Carstens , Jonas Bonn , Martin Schwidefsky , Michael Ellerman , Michal Hocko , Michal Simek , Mark Salter , Paul Mackerras , Rich Felker , Russell King , Stefan Kristiansson , Stafford Horne , Vincent Chen , Yoshinori Sato , linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, Mike Rapoport Subject: [PATCH v4 0/6] memblock: simplify several early memory allocation Date: Mon, 31 Dec 2018 11:29:20 +0200 X-Mailer: git-send-email 2.7.4 X-TM-AS-GCONF: 00 x-cbid: 18123109-0028-0000-0000-00000331258E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18123109-0029-0000-0000-000023EE69C7 Message-Id: <1546248566-14910-1-git-send-email-rppt@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-31_06:,, 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-1812310088 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Hi, These patches simplify some of the early memory allocations by replacing usage of older memblock APIs with newer and shinier ones. Quite a few places in the arch/ code allocated memory using a memblock API that returns a physical address of the allocated area, then converted this physical address to a virtual one and then used memset(0) to clear the allocated range. More recent memblock APIs do all the three steps in one call and their usage simplifies the code. It's important to note that regardless of API used, the core allocation is nearly identical for any set of memblock allocators: first it tries to find a free memory with all the constraints specified by the caller and then falls back to the allocation with some or all constraints disabled. The first three patches perform the conversion of call sites that have exact requirements for the node and the possible memory range. The fourth patch is a bit one-off as it simplifies openrisc's implementation of pte_alloc_one_kernel(), and not only the memblock usage. The fifth patch takes care of simpler cases when the allocation can be satisfied with a simple call to memblock_alloc(). The sixth patch removes one-liner wrappers for memblock_alloc on arm and unicore32, as suggested by Christoph. v4: * rebased on the current upstream * added conversion of s390 node data allocation v3: * added Tested-by from Michal Simek for microblaze changes * updated powerpc changes as per Michael Ellerman comments: - use allocations that clear memory in alloc_paca_data() and alloc_stack() - ensure the replacement is equivalent to old API v2: * added Ack from Stafford Horne for openrisc changes * entirely drop early_alloc wrappers on arm and unicore32, as per Christoph Hellwig Mike Rapoport (6): powerpc: prefer memblock APIs returning virtual address microblaze: prefer memblock API returning virtual address sh: prefer memblock APIs returning virtual address openrisc: simplify pte_alloc_one_kernel() arch: simplify several early memory allocations arm, s390, unicore32: remove oneliner wrappers for memblock_alloc() arch/arm/mm/mmu.c | 13 +++---------- arch/c6x/mm/dma-coherent.c | 9 ++------- arch/microblaze/mm/init.c | 5 +++-- arch/nds32/mm/init.c | 12 ++++-------- arch/openrisc/mm/ioremap.c | 11 ++++------- arch/powerpc/kernel/paca.c | 16 ++++++---------- arch/powerpc/kernel/setup-common.c | 4 ++-- arch/powerpc/kernel/setup_64.c | 24 ++++++++++-------------- arch/powerpc/mm/hash_utils_64.c | 6 +++--- arch/powerpc/mm/pgtable-book3e.c | 8 ++------ arch/powerpc/mm/pgtable-book3s64.c | 5 +---- arch/powerpc/mm/pgtable-radix.c | 25 +++++++------------------ arch/powerpc/mm/ppc_mmu_32.c | 3 +-- arch/powerpc/platforms/pasemi/iommu.c | 5 +++-- arch/powerpc/platforms/powernv/opal.c | 3 +-- arch/powerpc/platforms/pseries/setup.c | 18 ++++++++++++++---- arch/powerpc/sysdev/dart_iommu.c | 7 +++++-- arch/s390/numa/numa.c | 14 +------------- arch/sh/mm/init.c | 18 +++++------------- arch/sh/mm/numa.c | 5 ++--- arch/sparc/kernel/prom_64.c | 7 ++----- arch/sparc/mm/init_64.c | 9 +++------ arch/unicore32/mm/mmu.c | 14 ++++---------- 23 files changed, 88 insertions(+), 153 deletions(-)