Received: by 10.213.65.68 with SMTP id h4csp974956imn; Sun, 25 Mar 2018 20:05:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELtZbe20kFA/s2WnsiShh0Zx7O05++dlVk2AhCzCvvwOpq1zs9P27oYDAYhi0zsNoHqywzlZ X-Received: by 10.101.97.13 with SMTP id z13mr27000311pgu.54.1522033524662; Sun, 25 Mar 2018 20:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522033524; cv=none; d=google.com; s=arc-20160816; b=UzHX0WHo/wIZicoSiDHSbk0GGSwIPWb5UOM/klYP44iuwCY2mvMJVZKzeC7xnHFoj2 VwQ1rnfV70Z40jvnVarCVQdBsAYNzmisCCzX41qEjageKpIhwvtCU6r2Px+Xw+Xg6KhZ Da0W9Xhc2GwqkTQk1DZ80ZotZ6ejgBSBlMa+tYSpuUxq9RWXB80KNo3BS8o5I8dAMQoC Q0mRKx6RvVaXHwgejkMmQeUflE7Bh5a0/IyqZkb4zh+2qCZDGq/4tPd7F8J0tHVHHBik ykuSTQbg8E1LJVm3jmkrXyeWsZhT4jqe67EDSzDuY8WomqMCM2rz+mQNjuvVNtzUqmD/ B74g== 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=DOoTmk8BHiY4nFZCdzCYSCelUomgGRwLJNyyWt+cTKDMFkhybfRU7EOjcqAbnwc454 qivArPWlcibZA4gGryp66N8AZu6PANm8KH3c1RqYYkBatH5Ie8YrIO4uC4pqc2hlHAVx 6ad/Z2DXnopF+5lOyGPFkT7Tu848fwxV404DIdfE8PmsugxGWtkJnj2T7Z+/2s6eN8Jz EmukKbVozCi89p/bYv78vXrjfMdG3q2pck7LV73+u+XE95SfL8S4ZxCHiFWXa3mR3Hks BNDXopiT6uxuR9oFdvrWr11xho8g6jsjU+Wi1HCDtlzEybgGH7a390q0S2SfRNeTSA5X likg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FR7U4Axv; 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 e90si9634134pfb.156.2018.03.25.20.05.10; Sun, 25 Mar 2018 20:05:24 -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=FR7U4Axv; 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 S1752129AbeCZDD2 (ORCPT + 99 others); Sun, 25 Mar 2018 23:03:28 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:38117 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751074AbeCZDDZ (ORCPT ); Sun, 25 Mar 2018 23:03:25 -0400 Received: by mail-pl0-f65.google.com with SMTP id m22-v6so11108961pls.5 for ; Sun, 25 Mar 2018 20:03:25 -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=FR7U4AxvWc4XGvftamO7l1n6iIRpjk9Vo2eUE7VXwfL3c2XGs09nNxLxMZ3F+Jo8UL X6iKB8aUiXocyPARyAREoAFHvciFozrrNi15jCrXprlr5duInIPK+u0wj+JWPV+E1z+2 41zm04PXPiLvoJySauZCyefUUYyDwVa4c8E+9O+ANrs5Kt/fhY3OOauozf93KqEBlkWh o3bf/92hoMtangELxopenYdQnLeNPaZt/pOUWn/5tJ9lOB1JZBZTQP8qxmTh+2/1jNLS NXFIoLMPo8OMm4Sl1Hw87rKZYbZWwzmUWwjmxw36s0Y9VzjQ/1boHIfQpkWPutXOMQO9 I1ZQ== 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=ajPNJjrUQN5jAfV0rNKmw5I0al9eOKtlRaPrjaEZu6H5z+lSSVvh2iul1+TiPrkg2A Bdi95JraKB+WiHl+vjOLsjN/uuNi5NDxll9ezjymFetS34dH/Kr3hYpWSYOSS/FL1rVx 2ay1cMwL7/iwHH/wUO2JAtYprcRwAp2JUtNceVOlOTHEAnoy6GvDVT8BPpNnt9hq4tMQ tEf2uS2fYsmqcfX6synbs3G6ORo8J4ubaB08V3u9HbQjjLLBPlqjOpR/NQ/eO945wglZ /vDB1+3eKwfXwL2RhqMQ+xDH1LJnzZH4KaNVZ5xJ0XKwgXDRdYvjx8jDNYQK/SL5Fvvc qN5g== X-Gm-Message-State: AElRT7GZyThNCUPn2cwno5iyZT+mDMWIhUO/NgKAOL/dZuVSet24+5Dd 2ogcYVQgwFCctAdriTQpHx4= X-Received: by 2002:a17:902:b181:: with SMTP id s1-v6mr988765plr.263.1522033405247; Sun, 25 Mar 2018 20:03:25 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id f19sm1634989pgv.39.2018.03.25.20.03.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Mar 2018 20:03:24 -0700 (PDT) From: Jia He To: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Ard Biesheuvel , 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 , 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 v3 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Sun, 25 Mar 2018 20:02:17 -0700 Message-Id: <1522033340-6575-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522033340-6575-1-git-send-email-hejianet@gmail.com> References: <1522033340-6575-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