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: 10572565 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 683DF1579 for ; Wed, 22 Aug 2018 03:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 193FD2AF45 for ; Wed, 22 Aug 2018 03:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AE4B2AF41; Wed, 22 Aug 2018 03:08:02 +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,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7ADC2AF41 for ; Wed, 22 Aug 2018 03:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=IzX4bMz/1mE9xIO1IXV8Iy584TGri/roDSLaseZO1rw=; b=uGo dUUHVQ96wIpWzWIJajo+QLqgPJk9o+koZdSb548NtC7YlxY8j9ClGrh+LaNwnjEp3lGyrqPQiXNt+ th/+xMb+dHpfyBDN8enIVveaPvVDNgjxfbEunQLMYiyu9EKRga50Z+AIaeUrFBkL+q4ajRMib+wUp bZJWWkb2TaZJPOdu29xnqdq2eTIjWe6UIZ6i8D1LeM/VcL5iinjvj96n8P+Ti0EZCbR2U7FeGhCXW YFC1XWM+pducuSdUQPHlGy5wHzKFp00U1nIOdYEUtw9CnVGj75gh5xB+AFW8dZiRdsb7gFx5TPz9V KwT1FZx1MwVsd2njv+9QsJ3Mvzsr+Bw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsJUs-00046v-Rx; Wed, 22 Aug 2018 03:07:50 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsJUq-00044j-4U for linux-arm-kernel@lists.infradead.org; Wed, 22 Aug 2018 03:07:49 +0000 Received: by mail-pf1-x441.google.com with SMTP id p12-v6so288946pfh.2 for ; Tue, 21 Aug 2018 20:07:37 -0700 (PDT) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gKWS16jdzfXAD+G98kjPe+iqSsLmnu/5WshYoGJhp9Q=; b=QH2BHs7cVN9900dpAOVgHT4pWunQFi3yOwkPXSpevzXh85rbiumiHqyj3hAhXVU6g3 n8Dv9Pzg8hw8WCYqcgw6FvniDH65dX1kelG7BgTIXdA1y1b0JnMGwtFkdvCr2GI1IZx3 /68K4Lpql2XjarynK8oumq8g+d1P46xXp1dlfOmY7j0ef/9ribmZ/OWZRcGIvW+Hjnpv pvUsBzfNTfQnyLOA/sdzjNdGgYOrGvUDNbpkFLcMxJC5Gzh97M1BjFN1XFNsGy1iBkXY Zq7DA06CNsKgSE6KFl++sL2wrAKKb2ShJ5xFAkkHyax+MhEM3HQVl2bgi/n1C0kk3oJW 7oNg== X-Gm-Message-State: AOUpUlGg+ZfheMJ1NLgbdH4BLUd9jkGMxwkBj8JyCjonR3wC9YsNLd+Q 0EnoXucEkXIF5ksHC86WLIU= 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180821_200748_182279_FFDE29F1 X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gioh Kim , Wei Yang , linux-mm@kvack.org, Eugeniu Rosca , Petr Tesarik , Nikolay Borisov , Daniel Jordan , AKASHI Takahiro , Vlastimil Babka , Andrey Ryabinin , Laura Abbott , Daniel Vacek , Mel Gorman , Vladimir Murzin , Kees Cook , Philip Derrin , YASUAKI ISHIMATSU , Jia He , Kemi Wang , linux-arm-kernel@lists.infradead.org, Steve Capper , linux-kernel@vger.kernel.org, James Morse , Johannes Weiner MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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