From patchwork Fri Jul 6 09:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10511147 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 755D3600CA for ; Fri, 6 Jul 2018 09:02:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66BE02855E for ; Fri, 6 Jul 2018 09:02:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD4B28571; Fri, 6 Jul 2018 09:02:59 +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 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 EADC52855E for ; Fri, 6 Jul 2018 09:02:58 +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=iiAyYwfH0XkBgXEnTSMw6n8mcKYztZOye7chqumENRc=; b=CX5MiIdxs9LaMID6S8TTUBsb5I LJnrbqpILXl8Bd1Uvf9o/zR71KdUu6tzKkDe/Wni8XuCA5hQRmYtn4w5kqe6EUrokhbGMV9gKc+Ml 5J/kSbmaSDS9II1hY24TCK2c6A6++MllV7vueek0MhQBgZZ5k1cWpQfdTvXZ7IePyoKX9Euh7hk/2 0eLvrQKcVMZ2DAVt2Ik03Ncp/Ib08ebwftwc4Fwt4MWLjRDheL2gGRJFInXt76hCEDLpJgQB+4ksE zKcYZ3ylS7Dl8ocQuNwz7jkgCI5GKraPKZ8h8kjumnHTUFjdTeBf2lWnxqVL0GjtRblMAmRAoT6I0 Ey0LN9rg==; 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 1fbMdi-0002Na-58; Fri, 06 Jul 2018 09:02:54 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbMdS-0001zY-33 for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 09:02:51 +0000 Received: by mail-pf0-x244.google.com with SMTP id l123-v6so7887906pfl.13 for ; Fri, 06 Jul 2018 02:02:28 -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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=Lm5pdDs9QXa+vQlbDY8tzb6VmT11HogGxmVTLSZVWXKjoApQH2S/8K6ey0OQti287R 8Dj/ayQDJFJx0/3ChVNfMU6g1ro3FqNZsjmA5l1I/Js5Q7GFWwGDKJQPCNuYyd3idtv8 sg1LFvAJI/t0LVmZm9rWTaELjUNpjntJ86f6GuNzveIFLq42qPu1DGcjkQGuPShAp3+4 vN5qH1G0+utDojn+ROf51Tf64OY8Ymqqi7tOtEMfD0O8mc11+MYXM9gZBUGgHvM0cwl6 AER7Jo6eIlTxCBFKkT+YaPjrgWc7BIvsQNUNu0eVD6JIfNUZYuzyzzcrocj+K5X7Br8J TztQ== 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=J1/qrDFRRPtvPy6pcBvx2A2jDL6dORtIwMaYcYmol4minBmQ8ZSwztJ1Fo86Dd2dMF r281uirIVt0TIfIod/+7It3xGR6ey7/7hWRGROoLfaSmdUH2MgNoQ3htET5CNxpv+4io hMeRBpMJDZWU0lCq0Vzd7ywOQ2VgRtE89bjArQ/u20/EZm4Ua30cIeCORMpguYQcSpIW JGszSjAF92TgNxLUvs2uC6T1xcJ4pWotktlN/hnkYkx/OyjmzyQvkYPhHAeET77W0X1r OAV1jThzYk4qvco42uSEkcSavh8gg2Zg89iXbxEhkGXAJqr0CXNwgGkLR5yCqsg6EMrx 9etA== X-Gm-Message-State: APt69E0ewXeRVXQPJdQwgEsgxAdkRkLONXsM3erTtqADMCFF1EwFzL+l CDDeK1qlR75T0bf0tWGQQy8= X-Google-Smtp-Source: AAOMgpdrQogf7Agsnn4Fhl1vyVKv8GHnUUkHWQWKrCYczG4NV7lTbP+FGOMEo+WNQawOegDtDjCUhg== X-Received: by 2002:a65:654d:: with SMTP id a13-v6mr4046734pgw.132.1530867747711; Fri, 06 Jul 2018 02:02:27 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id e5-v6sm10837092pgs.59.2018.07.06.02.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 02:02:26 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Subject: [RESEND PATCH v10 4/6] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 6 Jul 2018 17:01:13 +0800 Message-Id: <1530867675-9018-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530867675-9018-1-git-send-email-hejianet@gmail.com> References: <1530867675-9018-1-git-send-email-hejianet@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_020238_560885_87390904 X-CRM114-Status: GOOD ( 11.04 ) 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 helper is to find the memory region index of input pfn. 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 ca59883..b0f0307 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 84f7fa7..c783b1a 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1676,6 +1676,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;