Received: by 10.213.65.68 with SMTP id h4csp1171488imn; Sat, 24 Mar 2018 05:27:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELtrHRKiHfOMmgWi+cwrAOvPxN2wU6K+fB/5XXBVeLX2VrJUPU42lzXAI6V+oQ/w0xz8sIDU X-Received: by 2002:a17:902:be0e:: with SMTP id r14-v6mr12911599pls.302.1521894437109; Sat, 24 Mar 2018 05:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521894437; cv=none; d=google.com; s=arc-20160816; b=sBPkUQRDqjP190a6EFoJWxX4e90PRDvn703Fo+3HY0cfXZ9y8l7/DVQMIiJcdkN73N HHxtl8gxJfIGjTvSstSp62S7E7Lte/4qVA6TMxEXyVg3vb3ta7tDzA+4H7I5HrzTqUSg 97MjrqyxTfYjZ4xqlXZqV819fORbUwiLdaDUDSoIq3kMjNs9p9oNkqjo97P1ED8rxHio 7jXRWILMfU3NVayjR4UvU4QP3/sC2AODayxwx2Vd8I84+8zj93l8wWc0g/uGmJZDhFSf 17SL4ZJ1UYlrJASO7KzDaqNJ9MY9Zq4Lmd4WrdlvDjZz6aFd0JwLgXk/7Zhi3UTbCaL3 Ug2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=A3iyvOJjQFbESrn9840Z+H7nJuG4UfdlxalRzNH63tE=; b=R0xVYsKEm6tWIuQ197nHBI7jmDZG8wW+X/cl6Ih9lcRSV+Ig7zu0VsjTbCoBAo8UMj mYnSQAibAH3q5V8Dco8Y0WMH4ZqxVX2KhzPlPlevLF2uBw3VLYJx97DQNsZ4z5RiXudA qUUgY//bku6dQ6M2JL9neT7cx9M5yp89ujFe8P+Mni2RJA0z9RYTqH+h2wtTHsr5/+l4 6QLNsqiUCgU7svTrUM754+FXxeTSzy/TBbDqSYyQkiRqOBF89SChxe52UwmBxDmKiw1c 1yYeEvDAZbQATVPxI0kWGKfaZGNae2IxuPR3vXIr+3nbjT4S/FMxSgTBcugdh0j8+lCj 21eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nmTUE6Gj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23-v6si10259923plo.272.2018.03.24.05.27.03; Sat, 24 Mar 2018 05:27:17 -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=@gmail.com header.s=20161025 header.b=nmTUE6Gj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752147AbeCXMZq (ORCPT + 99 others); Sat, 24 Mar 2018 08:25:46 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40242 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbeCXMZo (ORCPT ); Sat, 24 Mar 2018 08:25:44 -0400 Received: by mail-pf0-f195.google.com with SMTP id v66so3279550pfv.7 for ; Sat, 24 Mar 2018 05:25:44 -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=A3iyvOJjQFbESrn9840Z+H7nJuG4UfdlxalRzNH63tE=; b=nmTUE6GjjUZ/Q/SlY76c+Da0GYAeCAjhFn4PzFcbvhNKTSJVRbp/Eme3ajp7/+2juD NU8SSkinW7I8spL4I/bopXlgC8u5nKPA6KtJiwpMdrxoy5PMEb5csYLo0P0L6M65RO5D KYuLkuM7GxOAD/kgCNrkkPsEWYDv11GPINZB5Ws8assJOPQ2c0x7USOv2nT0WYsTTaNI t40KI08RWuOZZFZRkPkYmQHVkGtqd74pzpXpsvL0zGYs974JjlNRj8z/+646MhtOUUk1 5vJRM8lT+M6CUTjNtOp9QhfjyeznCwIKvTZAh34kTkzmvJOE1R0GtVlm9pY5UJHQUS2d Dfxw== 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=A3iyvOJjQFbESrn9840Z+H7nJuG4UfdlxalRzNH63tE=; b=fn6+5YI4dQH3Nm0MOeJsq1ZVGSK6mXpcxSpgNdSedgYQnFJssCWkgKDkjmJMW3U3IP OnhRVQBPZs1mQdwRpz4c2DXNWXXI2uexVWGqtww6zIU22SgusVf2Nt3neC90WBQucG8r xFfHY1wloJkRo1QUABoJwg3FiiPoE3Qg6rY30R9evbWAKhz7yRW6LqW9YHEhFU5sNQX6 IX6QKPUkWfS8BRN5mFJCmiE6DgxS4kaB+6VbfS3chJgF3wH+UXl8S9/ErPO+6Uu4pOHL 1xlNFT1pLp6kOrPfFACEQyTedALClWlT3WfjJmmXRY0xlu14MY0dl6O92ZfaGtqepRxe qEoA== X-Gm-Message-State: AElRT7G3tIDdPkXokyvXUUnh6evbNkR2MOKhtj/D3YnUSDA6hG90+8BC odroi0jPJZYnVUgFM/skOcI= X-Received: by 10.98.67.217 with SMTP id l86mr21690603pfi.40.1521894344087; Sat, 24 Mar 2018 05:25:44 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id b6sm23152371pfm.160.2018.03.24.05.25.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Mar 2018 05:25:43 -0700 (PDT) From: Jia He To: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Daniel Vacek , Eugeniu Rosca , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, James Morse , Ard Biesheuvel , Steve Capper , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Jia He , Jia He Subject: [PATCH v2 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Sat, 24 Mar 2018 05:24:40 -0700 Message-Id: <1521894282-6454-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521894282-6454-1-git-send-email-hejianet@gmail.com> References: <1521894282-6454-1-git-send-email-hejianet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 a8fb2ab..104bca6 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -207,6 +207,8 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, unsigned long memblock_next_valid_pfn(unsigned long pfn, int *idx); #endif +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 06c1a08..15fcde2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1661,6 +1661,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; -- 2.7.4