From patchwork Wed Aug 22 03:07:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10572561 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 0A268921 for ; Wed, 22 Aug 2018 03:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 001AE2B393 for ; Wed, 22 Aug 2018 03:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E82B92B398; Wed, 22 Aug 2018 03:07:40 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 73B6D2B393 for ; Wed, 22 Aug 2018 03:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E7EE6B221E; Tue, 21 Aug 2018 23:07:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 570836B221F; Tue, 21 Aug 2018 23:07:39 -0400 (EDT) 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 4148E6B2220; Tue, 21 Aug 2018 23:07:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f72.google.com (mail-pl0-f72.google.com [209.85.160.72]) by kanga.kvack.org (Postfix) with ESMTP id ECEE66B221E for ; Tue, 21 Aug 2018 23:07:38 -0400 (EDT) Received: by mail-pl0-f72.google.com with SMTP id d10-v6so311681pll.22 for ; Tue, 21 Aug 2018 20:07:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=gKWS16jdzfXAD+G98kjPe+iqSsLmnu/5WshYoGJhp9Q=; b=MA77JucjMJgxvu8p0XeXf7mLfi/+X0piP4Oc7EY1zDEG5mLs5rVEqJynzcKXEtBFTM a6sK1Kn/WH2LousCeWARwwCIEgPWEemX384vB9VbFaAiQ0nYmOrGqiOHe5MVNLUwTg3i CkGqsnlZKQro13sVAgln/70Ro+Q5cD0zTxk5afHY9npRRnob8YqN+NE3TiyBChM1/u12 PIVfe9W+8GVX+d6EmV8r5Ds5vpSn1z+PVsnrgEIm2pFq4XF7NaPcPdRVuwH0VUY1HANz S0IhJhzOVzvNMIpm8OuYsVi2FIB8p/7geilF++BYf2jT3CTsLB921YP+adsnm4T+qG5/ wwAg== X-Gm-Message-State: AOUpUlFxVG/aSI219cQq/FCOkYQIBXAP1Lo7z4WRgR+nMya7DFz0i0eg w3JA4LdW/x9uWsBqbdQNJxE04zz9h0aAODzfLOtoDBpVtxi+zSAYHGPWKR4vgUvT62guuSz5CQ7 VUCDOBOMxRTI7Sb8FNtXjdt5UkrUqYfXh40PpXZ9ZZSzEt0d8KauBh8mYQr4KeqMooseo2W1dkU Or30jl7aqH+31ia9M4RMmqTry02QJ5dvwZeRAzgLVwuCrbsh3IWdnd4NVSZxQOUT9UZYrmJrRdq g+cbM7SAcrc7kePs+0B2ThFeHH+0bmnyHXPDaFWGMtSKdkiNDVcwCmFyzv2kUNDLCPfkB7dKX/Z O6aXW9g9xE2zL7g2jKhLAOMbnyKQ0j/HcTNEUs8/25VSrmNB6v763q6ukbVcGz1pzJHhNRGI0za m X-Received: by 2002:a17:902:be0a:: with SMTP id r10-v6mr15543070pls.275.1534907258619; Tue, 21 Aug 2018 20:07:38 -0700 (PDT) X-Received: by 2002:a17:902:be0a:: with SMTP id r10-v6mr15543035pls.275.1534907257689; Tue, 21 Aug 2018 20:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534907257; cv=none; d=google.com; s=arc-20160816; b=Omk1J6BmMIE0PG0mCahoUkEeGjgQX8w1R65uBNvq4jrE5AAb5X3rj+nZFE7mvX+HF5 as6vTqLCJXoJxOoRLwiEGDVM+1rKc73JXtxCJlFl3yn4mMHHyr33Tm9yLj+92GICeG+o CrPvjRlScfD9LGib8h8XcqlXXDEWJcBUPe0sD+Em+VOPTvLplhapJdjWQcofxoYLRjO7 YJ4UH1cBt4TTAqjnxoDKjKvbnCUyIxdZsNMQTEPREmLCqODJuRXE1aKBozkOWJY1enUy lahWeWxS6k1SFO05aALtE7NbxDeqGUymOFHwSuOwDeTFotBuEavzYLWyrHFlhuGRP+VR I4Jg== 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:dkim-signature :arc-authentication-results; bh=gKWS16jdzfXAD+G98kjPe+iqSsLmnu/5WshYoGJhp9Q=; b=uqP3cEJMcQpgeBqsBxBEMNtfvVRhqwEsMEETOZK840vvAjceM0JJc9JFmIwb5Ee9Cv rxrzmNx5EnNhPKgaiX+nVSGVENBOkvIkoPdoN/nuAJ6Q0lQ4la6edqatxGr/xcFp80PM TAQolYQoPN2BLmwJCl+GHMDrD91X1ZPwPYY/ohveu1rb+Ks85laIOLYiuSX74x+7kgiw Jszjf2TqWRYDTrc8QcSpf6ZcmKwS0Y6Z/H8sSvjEqRovdZBhkRYLGuhlFde9gy7mXUjG NbAme2CjqXQtjjG2gHhrLUFDLKcWZUmSKJ6sM55D4zMytGSFNOdON6kjLzAwfB2xBKaZ g8Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="j08/c2bX"; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r23-v6sor156947pfj.74.2018.08.21.20.07.37 for (Google Transport Security); Tue, 21 Aug 2018 20:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="j08/c2bX"; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=gKWS16jdzfXAD+G98kjPe+iqSsLmnu/5WshYoGJhp9Q=; b=j08/c2bXG/IDzydP+ckK37VLifklpleBpvCoU1sgxU0kxRe0/C0ZIGIiL96DsmdgEM crpEdfjxb9vUpP2BiW0ay7921Ryxn77/FsSS4WFPhrtRZlJ/04xFKSPXaYJfC8JwJPwk AbUaSj7aRZ5vIqgG3XEKJxHDfTDtPcjkVCC/JRdcmsQ4yKdk+gcFjVSYHDS6DAAlREx8 bnVg8UxhFK03KU/ZlLPMn5lj/Y5PT1oRbdyGAFl4GF9JagghLVrW7JjlOUv+r99cVqkD TFe4Orf3dKMeO07d0ijE3O1pOjBk7enzUUF7/wxIuPddrd8Fnr/F1iVTfOKswyf99f5Z F74Q== X-Google-Smtp-Source: AA+uWPzKNhtszuCWsOs3l4LCJ6kKE+mMa8LyV1g3KzqU1LhA7P2OiPUVeOQlYHLPHbZf3uxeSsuThA== X-Received: by 2002:a62:1157:: with SMTP id z84-v6mr55905319pfi.66.1534907257365; Tue, 21 Aug 2018 20:07:37 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id q7-v6sm440165pfq.43.2018.08.21.20.07.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 20:07:36 -0700 (PDT) From: Jia He X-Google-Original-From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He Subject: [PATCH v11 0/3] remain and optimize memblock_next_valid_pfn on arm and arm64 Date: Wed, 22 Aug 2018 11:07:14 +0800 Message-Id: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 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 Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") optimized the loop in memmap_init_zone(). But it causes possible panic bug. So Daniel Vacek reverted it later. But as suggested by Daniel Vacek, it is fine to using memblock to skip gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID. More from what Daniel said: "On arm and arm64, memblock is used by default. But generic version of pfn_valid() is based on mem sections and memblock_next_valid_pfn() does not always return the next valid one but skips more resulting in some valid frames to be skipped (as if they were invalid). And that's why kernel was eventually crashing on some !arm machines." About the performance consideration: As said by James in b92df1de5, "I have tested this patch on a virtual model of a Samurai CPU with a sparse memory map. The kernel boot time drops from 109 to 62 seconds." Thus it would be better if we remain memblock_next_valid_pfn on arm/arm64. Besides we can remain memblock_next_valid_pfn, there is still some room for improvement. After this set, I can see the time overhead of memmap_init is reduced from 27956us to 13537us in my armv8a server(QDF2400 with 96G memory, pagesize 64k). I believe arm server will benefit more if memory is larger than TBs Patch 1 introduces new config to make codes more generic Patch 2 remains the memblock_next_valid_pfn on arm and arm64,this patch is originated from b92df1de5 Patch 3 optimizes the memblock_next_valid_pfn() Changelog: V11:- drop patch#4-6, refine the codes V10:- move codes to memblock.c, refine the performance consideration V9: - rebase to mmotm master, refine the log description. No major changes V8: - introduce new config and move generic code to early_pfn.h - optimize memblock_next_valid_pfn as suggested by Matthew Wilcox V7: - fix i386 compilation error. refine the commit description V6: - simplify the codes, move arm/arm64 common codes to one file. - refine patches as suggested by Danial Vacek and Ard Biesheuvel V5: - further refining as suggested by Danial Vacek. Make codes arm/arm64 more arch specific V4: - refine patches as suggested by Danial Vacek and Wei Yang - optimized on arm besides arm64 V3: - fix 2 issues reported by kbuild test robot V2: - rebase to mmotm latest - remain memblock_next_valid_pfn on arm64 - refine memblock_search_pfn_regions and pfn_valid_region Jia He (3): arm: arm64: introduce CONFIG_HAVE_MEMBLOCK_PFN_VALID mm: page_alloc: remain memblock_next_valid_pfn() on arm/arm64 mm: page_alloc: reduce unnecessary binary search in memblock_next_valid_pfn arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + include/linux/mmzone.h | 9 +++++++++ mm/Kconfig | 3 +++ mm/memblock.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ mm/page_alloc.c | 5 ++++- 6 files changed, 69 insertions(+), 1 deletion(-) Tested-by: Eugeniu Rosca