From patchwork Mon Apr 2 02:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10319423 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 65C50603D7 for ; Mon, 2 Apr 2018 02:34:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5464528D42 for ; Mon, 2 Apr 2018 02:34:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 470C628D4B; Mon, 2 Apr 2018 02:34:33 +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 BC7B628D42 for ; Mon, 2 Apr 2018 02:34:32 +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=OxQSzg90XiNp8xgxVkgMMpOz9iXgiziv9DsAa4cITSA=; b=eN6Llxh92zCctz2TaIUt2l6Kys mdvmcW+dVBXAd/MA8Zvx8WzP8oFD7QUXtLYmzM6E4rtXoJrUNc1X8U30RRidK0DA2Nyy+1U11RpJq Pd6RhlkexN/wJJzqlyBsg8UfuO6gAasS7P4GD3iATv8ulL0mri/qrJH86YtOnVF3isy9bIyYlBo/D STKksB07qW+PraGd43PTL8I225Yai+v61WanACx/LlUPZMVeNq9T12RMUWsKzfkG3Xf9/wUF4PpbW h56Kgjsinl9JJUR2f7qiF6/sXlPdJ7r2B6XcxmfWCbTGprxE/s2TZlx3va+JZY8RuUseXK5VnoPLO jCWkTMcA==; 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 1f2pIf-0006pn-Fa; Mon, 02 Apr 2018 02:34:25 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2pHJ-00062C-9y for linux-arm-kernel@lists.infradead.org; Mon, 02 Apr 2018 02:33:13 +0000 Received: by mail-pf0-x243.google.com with SMTP id x16so3632208pfm.4 for ; Sun, 01 Apr 2018 19:32:50 -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=qp5NKpTdcRM6Rau/uqwRW72+6gftVpoNr2Kh3FeSdLk=; b=dDDbGEDLCy7gkR/kblFWe8VDkNyGj5uiDLQ6K0Q+Sb3owWc8wnQDu5qIK3FjLOX8s6 nrhXd8CDbutohKYkxL6GH1HWqzGyrMVY+zqbCij1jgvxujvNw4aahQinNkwmOhabGWXO WZgncQ1IhVP1k0pKyZ6b32v+egcP+xIzfMNAQ/ZI442F4cKaMPDPZdJ/jML0tz1+qpxC Of9YjnlgFt3BqE8hT6c16Eq9ZsH5AjJHVYh4j/z3QYokv+vugreVykgM4xkDXr37dlT8 lnyyxAzNr8MObhlCDFCGHCHfZNA0U1iB8V5+GqfKzbAj6dLJ/27KkZ+HVjE2UmMSVKFm tT7Q== 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=qp5NKpTdcRM6Rau/uqwRW72+6gftVpoNr2Kh3FeSdLk=; b=iQdAjFnkVebP8Q3cZ84R090nhhqDao7PJQQMunmGZeI4RSqSGGZe+PQdk4XwKfsRti IKWZwjD4sQ+QQqmsMJtHk54XPjw7oZkqRL5bEVpSoLnVK5KcT9k3UDZ4hG24K8P7pdnb fbuXxtD5BbAvzUiNa/w/EtrGljPxUuc/vfvmAKa7tHOPpUqJdQfmtrTlg0jww+9jnUCS 5XDqI4Lsq1wif/xmAKxtlJsrhmfT0Z2VfvW43SxrpFveoGgth1xezJdVLWkbdIrEzU3D +HFKRu282RyOqo4ZGLHECJTVyVYwBYzt+j1BOff/zmkZ3+FOipCuOKiPKRUJQrKzc/Fw MchA== X-Gm-Message-State: AElRT7E0/p7grTaOa2hAqQXZ9LpcNKL8uBPPeqLF8gjaWiaPDRtVf//g YhHMv19F9DkYpzPBgCRFPdI= X-Google-Smtp-Source: AIpwx4+zbFaTkKWbMau9UfOXPyoEtmpKoX7c0sYtyygxzunMlH1VjRGILpz3jK6PW7vJk7lSK5WQOQ== X-Received: by 10.99.95.84 with SMTP id t81mr4924886pgb.400.1522636369410; Sun, 01 Apr 2018 19:32:49 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id t20sm25934371pfh.182.2018.04.01.19.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 19:32:48 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [PATCH v5 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Sun, 1 Apr 2018 19:30:34 -0700 Message-Id: <1522636236-12625-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522636236-12625-1-git-send-email-hejianet@gmail.com> References: <1522636236-12625-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180401_193301_409482_98E28EA1 X-CRM114-Status: GOOD ( 14.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: Grygorii Strashko , Wei Yang , linux-mm@kvack.org, Eugeniu Rosca , Petr Tesarik , Nikolay Borisov , Jia He , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Andrey Ryabinin , Laura Abbott , Daniel Vacek , Mel Gorman , Vladimir Murzin , Kees Cook , Philip Derrin , YASUAKI ISHIMATSU , Jia He , Kemi Wang , Vlastimil Babka , 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 the preparation for further optimizing early_pfn_valid 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;