From patchwork Wed Apr 4 02:56:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10322001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82D7360116 for ; Wed, 4 Apr 2018 03:00:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 718D628764 for ; Wed, 4 Apr 2018 03:00:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65BAD2876D; Wed, 4 Apr 2018 03:00:19 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham 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 E9E9628764 for ; Wed, 4 Apr 2018 03:00:18 +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:References: In-Reply-To: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:List-Owner; bh=UCRc8T9Ip05jC4a74HXZvX1aE52y3lkWNFzWf0nVMS0=; b=KDsp/zd3oRco6PoXno6zTJcpBB hcCGk6lSVoT7bV4VjuikNjLfahSZy3HUgRVqOnTsaSrPeO1biJ77bVXaRMDtc+GITdI1x0McLy/Xh ogtmNOakSZAM2CnP3jKv47nyXBf9QgIv+7yyrQ3ZVfuIfTaJBmJAh0z0VFGH06PKILxOub5ir+z1l vLAfabSIlu0vvPQO/g8ay2eqkD/J2+Mepeb49Q2wC7sZgEUUnJnOiqTTu2whPxOWawD/a0mwnEhuz FyJgT2O+68t7jRDtQRZ4FJAax0FEiISvM5g1ym2EsNfIxJlS5zyctmskqyO7ychxkgJqYZzMp1OnY 3r5Wah1g==; 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 1f3Yeb-0000Mt-3T; Wed, 04 Apr 2018 03:00:05 +0000 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3YcL-0007Rw-I3 for linux-arm-kernel@lists.infradead.org; Wed, 04 Apr 2018 02:57:52 +0000 Received: by mail-pl0-x241.google.com with SMTP id s10-v6so10032307plp.0 for ; Tue, 03 Apr 2018 19:57:35 -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:in-reply-to:references; bh=ieW6Yp/ttHGGz0nzBCjYHSwJcIZ2bSoQtdoURi3Cslk=; b=X8CtjIxp2D8HtC/9n0HyruQe9pjwR5enFq8cFXRmzUdb/Wiiqc8HKBAhPmqSeWEL3h gcZ0FrrlbOwqUqcrj8f0+F0I78xdiYenNQ5O/NVMkSnRjNvqUyO7o8FGA+wgZBtNHLoS ocGlWqqVZnWiET5FrkXEWSkaG2J+HcbJ8cJWuf16pOkME4ru2StmOylU/+P3Lg8I/8OT ISadhNQsfq3Jo4/UgyAnHESPaGh/4eH0U6fubswJ+dqbm7WvYONUdyKJlXX5dvW0AlD5 j3o32Uu0KcfIDWjKjxeJ3X5OcfUridL0HA5ZwtwKD8QgtRwes5mvrkAZHRPF3QaP0eG5 aVEg== 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:in-reply-to :references; bh=ieW6Yp/ttHGGz0nzBCjYHSwJcIZ2bSoQtdoURi3Cslk=; b=F7lOz0kYTixKQnivNHDaKQujGu8HDsvGI3CAECi6actzqii4n/jKTA22b+OYc98qAw pgdkBYOJO9wij7E5LA6pwXI+KM1D/Ym1lx2LV/35JvsaK4y8GN6CU/UDtPJXMZEVDksR aqHo9VwicjZCk91qQjpgsUzjBGKXB8tEgNSyTSU+xdmAxMUBAe8w8yM1JWpaj8tX/iYU IbyOrdNBK2r0DiaLa4D7K5aPzFfQiesVb1MFQoRaFTViya5dQX2YmTOf8gp9hwkyo3g8 VcO6F6WK95eZ+F4cI7N0ajz6P01sr8/MFWgo2UgpEmA1EVQ73STwq0wiWxy4cj0Xwe0W eiQg== X-Gm-Message-State: AElRT7FekxkGHxtgHBObFEUg/X/Hb51vJIKK+5+Lf4ffEnBd5TW9AyMc UXIeEYGLMlD8FrfPim7+2//Tryhx X-Google-Smtp-Source: AIpwx4+4hST2tc9NYxb6jeCAKK7Kjw7WzIg51jnyWcNIWdKfHmkpts7dO/hW3yY22KO56yw90jUqbQ== X-Received: by 10.101.99.149 with SMTP id h21mr10914642pgv.345.1522810654256; Tue, 03 Apr 2018 19:57:34 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id a4sm8020701pfj.107.2018.04.03.19.57.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Apr 2018 19:57:33 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v6 4/5] arm: arm64: introduce pfn_valid_region() Date: Tue, 3 Apr 2018 19:56:18 -0700 Message-Id: <1522810579-7466-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522810579-7466-1-git-send-email-hejianet@gmail.com> References: <1522810579-7466-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180403_195745_624918_1012E7F6 X-CRM114-Status: GOOD ( 16.10 ) 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 , Jia He , Pavel Tatashin , 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 there is still some room for improvement. E.g. in early_pfn_valid(), if pfn and pfn+1 are in the same memblock region, we can record the last returned memblock region index and check pfn++ is still in the same region. Thus we can avoid do the slow binary searches. Currently it only improve the performance on arm/arm64 and will have no impact on other arches. Signed-off-by: Jia He --- include/linux/arm96_common.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/arm96_common.h b/include/linux/arm96_common.h index 2f4dea4..bb86bd3 100644 --- a/include/linux/arm96_common.h +++ b/include/linux/arm96_common.h @@ -48,5 +48,29 @@ ulong __init_memblock memblock_next_valid_pfn(ulong pfn) return PHYS_PFN(regions[early_region_idx].base); } EXPORT_SYMBOL(memblock_next_valid_pfn); + +int pfn_valid_region(ulong pfn) +{ + ulong start_pfn, end_pfn; + struct memblock_type *type = &memblock.memory; + struct memblock_region *regions = type->regions; + + if (early_region_idx != -1) { + start_pfn = PFN_DOWN(regions[early_region_idx].base); + end_pfn = PFN_DOWN(regions[early_region_idx].base + + regions[early_region_idx].size); + + if (pfn >= start_pfn && pfn < end_pfn) + return !memblock_is_nomap( + ®ions[early_region_idx]); + } + + early_region_idx = memblock_search_pfn_regions(pfn); + if (early_region_idx == -1) + return false; + + return !memblock_is_nomap(®ions[early_region_idx]); +} +EXPORT_SYMBOL(pfn_valid_region); #endif /*CONFIG_HAVE_ARCH_PFN_VALID*/ #endif /*__ARM96_COMMON_H*/