From patchwork Wed Apr 4 02:56:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10321999 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 DCB3160467 for ; Wed, 4 Apr 2018 02:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C947428741 for ; Wed, 4 Apr 2018 02:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB3EE2874E; Wed, 4 Apr 2018 02:59:20 +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 27E4128741 for ; Wed, 4 Apr 2018 02:59:20 +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=47jYXPXGKhE2CaG6AreJnayRtmr3h9MAIdeu/WGLa0k=; b=SP0YuWLRgc/OD0D1s62kJ4fwiC vmVTv7+M+s4zyxPccssJKXWkQbWjBX0+QOIS1J3I15Aia07RKkzIVqhf9kbUCVm1+vPzFD37bLCfc TLfD4tylQbbULgE3Xrqn/ccUKVbJKmWr6fwUNbWsGQDOXDCK45wbiKc8Ahaj4qCKMSda6mUEg+p2I /KMT36ibOMR1BbcqAS1lBC1xrY3fRABua5+K5dWAe63gLCabvYu9unTyemY6VgmT8dQlRs1geBcy1 uhCSPEsYyYis0AoLlyhJddCJl2ZBxpEK9TIOYdzuhKLkz3Wa5VFgtwwUeOY/+4H6a9aEesM81xiFj K510Yh2w==; 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 1f3Ydi-0008Ke-Qa; Wed, 04 Apr 2018 02:59:10 +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 1f3Yc8-0007IA-5D for linux-arm-kernel@lists.infradead.org; Wed, 04 Apr 2018 02:57:33 +0000 Received: by mail-pl0-x241.google.com with SMTP id k6-v6so6899035pls.5 for ; Tue, 03 Apr 2018 19:57:21 -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=iBZHCBW4BvlpP/WE8DGI28xrDO81bOUvUzXIvggb3+Y=; b=dKhs8r/bVKZx4YMIyoXusi5DJyha5GJzRIjwt7zOgn+pnY7Mx379oYIywmq+2PW2wx tEGuQvW1w4FWB2AdDawRw9repXAducHBRYQ+BjnNjGZdSsQJOfulqx/0ehlDIMaLUFgH 2QXNA54nNfoo9yP8DaNOmnXdCAO0NanxYo66m/U7J2zwTBuu5xDDDtFoGDBauzmt/9UR HjZbQ7DFxSf9nmICUh0NEBZQnIcgaHukyxHiVAjqz+Q236CuRJhxSkXtqvw9m6iGeHKl xlMiPAaq4xpA6p2tNXIWBqFT/QIOKl1xNmKqSpf/JBvRKNmBYDa/OxAG/7XxEE/7SU0H 3yEg== 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=iBZHCBW4BvlpP/WE8DGI28xrDO81bOUvUzXIvggb3+Y=; b=qMtmGBWklpFEjpljwEyq9Y72IvET2xF4SyP/moF2GPTo0YjlFn8Vx3uTFc5cWBP5Ss 9ZWOkWz+OXqIj53O3iOgt6JPSA/Zl93VJ8tuFqjG8kFV7/8+XkUQ8lJ019HVOAJqjOtz S6tvPcq2+imSJOoGHTflNvyi/jnAdxdlhdBCqsEWJCi1wZoYuG8c/LMShciIQ++Ds40Z Gra3hDKxuQZ2xUoaAKX0Pv7shnEo0Wu0zUAmVOSez76Y2XgBGek0hqTLtq4AuHVY/3HQ GwaPDjF0P7mGIzLfh3toseWt7EClwITKtEeMSn6kwPnjjCSlow8ngQ594Hgn9crxv2RO LGug== X-Gm-Message-State: AElRT7FELqDp4H8UU68dO3ixrdJjtwlgvijlFg5WCKUhJgRbpeQE22wM f49/TODx7NQcngIy2M0h1jM= X-Google-Smtp-Source: AIpwx480Oz38VZt2RlMFpU7xTJ8HRrDvqliZMSnTnqVRsNdt2l2hu845DJmwdZzgGir/Wy9oTDZUgg== X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr15281001pll.116.1522810641431; Tue, 03 Apr 2018 19:57:21 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id a4sm8020701pfj.107.2018.04.03.19.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Apr 2018 19:57:20 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v6 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Tue, 3 Apr 2018 19:56:17 -0700 Message-Id: <1522810579-7466-4-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_195732_224378_7D7E283D X-CRM114-Status: GOOD ( 15.29 ) 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 This api is to find the region start_pfn and end_pfn of the input pfn. With this helper, we can improve the loop in early_pfn_valid by reducing the unnecessary binary searches. Signed-off-by: Jia He --- include/linux/memblock.h | 2 ++ mm/memblock.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 0257aee..a0127b3 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -203,6 +203,8 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid)) #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ +int memblock_search_pfn_regions(unsigned long pfn); + /** * for_each_free_mem_range - iterate through free memblock areas * @i: u64 used as loop variable diff --git a/mm/memblock.c b/mm/memblock.c index ba7c878..0f4004c 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1617,6 +1617,15 @@ static int __init_memblock memblock_search(struct memblock_type *type, phys_addr return -1; } +/* search memblock with the input pfn, return the region idx */ +int __init_memblock memblock_search_pfn_regions(unsigned long pfn) +{ + struct memblock_type *type = &memblock.memory; + int mid = memblock_search(type, PFN_PHYS(pfn)); + + return mid; +} + bool __init memblock_is_reserved(phys_addr_t addr) { return memblock_search(&memblock.reserved, addr) != -1;