Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp408490imm; Thu, 6 Sep 2018 04:33:36 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY/nWGfLgUbanqfmA7BYjZLZzdZtj3Zwe9WZ/1C2xVqLHJSpiftEDu3dnlj9BVldQ2Pvc6J X-Received: by 2002:a63:560e:: with SMTP id k14-v6mr2290843pgb.189.1536233615965; Thu, 06 Sep 2018 04:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536233615; cv=none; d=google.com; s=arc-20160816; b=dhyncS+TZapis9iYal9zjtvgTU+A6kDnGIlYPCuBdtRFYRA5z+QClGiwEfm1Cp8O7T BxaKKUOYMHmmdqBPgqU9NqsR6CTs5GW4gTWFj89i4x244hzEyDlkTkt36sQA5XrpoKQD uxzbrJ7TtmL1/tlndYVDaXOKPa7IRFkF5hfaN7wdRo/mbvYQSNVzy0yB4BqbitreFkL5 zY+OK+DQRc7oPpdaWhTcYaV0xKF+7AOt4nkuWSnitPXosB+gu4mP58vgvOEI/eGHL8eJ EJb/PosMoqt2wuLFLRC6xYUke5g3JDdCZn/g/pZYX/+lhsDORdub7IRJFGan4QAYgRzj uB5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=mHc1cPtFL78lfojA9PJyr9HDLtVTRheeh6fv+zfPkIs=; b=i5Q5ivTcT/vWbDNYzSMUGGirV0V1Q3uihVr+5hemxoc7OOch/NqnWOmjPKxU69Cfpl QhnlaM6y792LCcMx3oGNsKphvNF9N57hRoqMRf8Iy03GunYOHd/vbSQNBhlY/l6gKIlb +/sVvvUlR9X1yVWboO/Vhk2yDmzoiXxFtYlsaiG8F6yw0u7MnnwcP7ZuVBNg42AsZgH4 DzdUIGXcDZVFQAiUmQpUXiVufS6xA/F1DRrM9OZNzNnZdN1/yal4DrAtz7oyGj/BfGjo qIQhFZzyUbKxq9LxkTqu10r0ZAe84DCD64evVkzY1kYqhfe23W4E11Pl2HempqiaCqxj F/ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NyXqh++T; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14-v6si4804921pgl.621.2018.09.06.04.33.20; Thu, 06 Sep 2018 04:33:35 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=NyXqh++T; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbeIFP7Y (ORCPT + 99 others); Thu, 6 Sep 2018 11:59:24 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:46875 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbeIFP7Y (ORCPT ); Thu, 6 Sep 2018 11:59:24 -0400 Received: by mail-io0-f195.google.com with SMTP id y12-v6so8478502ioj.13 for ; Thu, 06 Sep 2018 04:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=mHc1cPtFL78lfojA9PJyr9HDLtVTRheeh6fv+zfPkIs=; b=NyXqh++ThDSQBz/skcIrjIEq6Opeb3JAezgxgpZUwJQtYsm365OLJFcLVW7Hriuk5W ksOLxhG/HrQjPLClJ3iTeNKkv/jtmCZUABCtGe8i2UbMO1UYpH2v7kMXoQbJTWXCaJgR sD8NcqYZbOwwc+rAQTU60QXhjed182F/civb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=mHc1cPtFL78lfojA9PJyr9HDLtVTRheeh6fv+zfPkIs=; b=V9WHJ7Jh0VIohR6JvNPQ/+J2clGJEN9QFHrWdbWKkF4s5qFw0ON1FjETLbOnQByh8U 0s5/kTN1IfUMpMtM0wQS1PK1QjUBC4zafNlihI+9ND0/tJe7oEbavnzPb/qrPhECm+0U SVZ+3UfN0kkY1pF3+xslE8xEcp8hShH0OzY9c4lk7sIx/IbuchhZXxiPUnvvqjuB+ZcG CCEP+Q4T2VPZTDmVl9Wn+IUdFdbIBUiAEPobBkqViBfZPzI1Hj4ErmFv3KRXflceT4I+ BhkAmtuvrfZlv0beogF3Qa4HeEZVj9Fnqz6+iNdOA3laXYLV26oMd6GNNy6JGlF5dXAo 7rXA== X-Gm-Message-State: APzg51AmW8vIqi2/HVEECaZNm8wDe7bxZBDqLEsz4kww4/5hSNyOu4oQ 2+//tWTd6nUXxcLsGVyW+OUmpyhpZnDW4j7RpZNvsw== X-Received: by 2002:a6b:4516:: with SMTP id s22-v6mr1510407ioa.60.1536233063470; Thu, 06 Sep 2018 04:24:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:1c06:0:0:0:0:0 with HTTP; Thu, 6 Sep 2018 04:24:22 -0700 (PDT) In-Reply-To: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> References: <1534907237-2982-1-git-send-email-jia.he@hxt-semitech.com> From: Ard Biesheuvel Date: Thu, 6 Sep 2018 13:24:22 +0200 Message-ID: Subject: Re: [PATCH v11 0/3] remain and optimize memblock_next_valid_pfn on arm and arm64 To: Jia He Cc: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Michal Hocko , 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 , Linux Kernel Mailing List , Linux-MM , Jia He Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22 August 2018 at 05:07, Jia He wrote: > 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 > OK so we can summarize the benefits of this series as follows: - boot time on a virtual model of a Samurai CPU drops from 109 to 62 seconds - boot time on a QDF2400 arm64 server with 96 GB of RAM drops by ~15 *milliseconds* Google was not very helpful in figuring out what a Samurai CPU is and why we should care about the boot time of Linux running on a virtual model of it, and the 15 ms speedup is not that compelling either. Apologies to Jia that it took 11 revisions to reach this conclusion, but in /my/ opinion, tweaking the fragile memblock/pfn handling code for this reason is totally unjustified, and we're better off disregarding these patches. > 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(-) > > -- > 1.8.3.1 >