Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp428024imm; Thu, 28 Jun 2018 23:43:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3PtjF4hqeKbryQRSf8MnMj5nYBOewodSJ1kAIBsYtrxs56tFovviSeUaVUzyQB3gbhSWE X-Received: by 2002:a17:902:7581:: with SMTP id j1-v6mr13654169pll.218.1530254607020; Thu, 28 Jun 2018 23:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530254606; cv=none; d=google.com; s=arc-20160816; b=r/Po9sqj3aaAKO2xP8+ozCLaThdXq3XIe9Zw4VWhggReOWOkG45hGfjN+KpscDVzHH zelphuN22qHqQKuVBEa/lS7fUDJGxLMqdpDTq03pzBVenSwdsnZwsQtoFtRL0OxDVpQq vCC3JunVe15zTLEGXzVvIHSfTjA61Fx++4KfSQgiXDzhGM59FAHVI1hSIgI9yGEqidJh NvtTkTOzdYItTdM7zgI6u467JNR6rH3rziFW6FEUHf2XNjgKKuBo1RH/zzgXOb0sH4Xl Cw7rCf/xlgJ442/lvAZgsCjb8lPzhJhqY4Tdkz4xASrHuCwWnjodlo97r6Z3YdKKIFIx rPpg== 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=KLZcLD+HkQuv1Dms0jlXw2m73ukkpfbtFF2qHvkCt0w=; b=MaHDPbyY3rWbANoXGe0FKRGg5qSC1Xq+v8ijcQIE6ml43iZtXnXmTP2hQyKaQUOkWs kikv1LfWpCRcULGqZCItL1aT7Jkk2hvGckCc8s+S2CGYHdNoYS4z0pFd9vLclwhg5F4W tpezptl7QqduP87Dgm1npnyFQFHG8kpfKrBfN17GNZbAsEy7UXd9VkTiA4VmTn+JTwIH Rg+Nkhz4xuZVlrulV3Y3O/OZAZFpo9SFSx7krACZ7ZmgkBG/Kpwmxc/xbvYPr/EMiPAH LxKfReUMuokoCgWtkR2j5RSvGYIqYclqhDWmz4RNATnBllMxl+xghJLN9JgMML61ACo5 RNQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jLD1uaCn; 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 4-v6si2329423pfi.362.2018.06.28.23.43.12; Thu, 28 Jun 2018 23:43:26 -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=jLD1uaCn; 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 S936540AbeF2Cav (ORCPT + 99 others); Thu, 28 Jun 2018 22:30:51 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35485 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933679AbeF2Cat (ORCPT ); Thu, 28 Jun 2018 22:30:49 -0400 Received: by mail-qt0-f193.google.com with SMTP id z6-v6so6654041qti.2 for ; Thu, 28 Jun 2018 19:30:48 -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=KLZcLD+HkQuv1Dms0jlXw2m73ukkpfbtFF2qHvkCt0w=; b=jLD1uaCnW2yi/0nTUGve3btvmgoEsJvpgd7cocgIDa7q7nc5b3sM2LWRfSkvSt8ZQN n/tnQLeh1oTUjUstwaoexrZNdwkgUQmpGHtt1UkE+kYx7crIGg+4u8/ZJLEwGRt+fism m5Ke20TwBgxd82Bi65dFeY9U8226mlTWQ5Gwlfxxz8cTizdo5IaEwtuGn5DNXIbZMFxB B5V+S76Jm80tYrGbxsgMxtQVSC451dIJwQRjzVr6liEzvqycI/YPf+WjZxQ07c4iHAUb OkfLrZqCjD5JeWsmN/EpRN+sCYBpDJ9tvhimHGpDms8phHW4YYmgaerkA2Uo2b1hcIHX mVtg== 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=KLZcLD+HkQuv1Dms0jlXw2m73ukkpfbtFF2qHvkCt0w=; b=I1Lfs18Urw5Fgk6nSzu64MhbitvZH0P8QY5GeQXI3BK0pnpX39Mf6hV2wI5owLmq7O bv8Seuap4dMOS1EZKvUsUqdxUb4BMOAodjzyXQO8HfeXyCHMdbXWjmPX/Z4PD5xdOaKU o+9WbPDMq/OWSOE652GptSTSo4VxPyEKrQEDXEn5GMZJnL8YjFE9kFS+cCbGUwPsYgrI AW2tM0AntlTDFvTql/+ajNRWI0upwCJjTBG4J9plI6xLwCuQoOVd5sjcLtTMPig11Ivh d0Y5DtR+4MmcuGf0s/1fG7yePWbJ9gpUi0OHjiczBjG2iIeEnQfSfpx9lb+7VHoa3mYs GDQg== X-Gm-Message-State: APt69E0JD/fMzQIcOAvOucpVCI6J1a3d+RWF0be/kVgKNlbeOncrv2FO /Pf2yLRLibJgboWrs41iQv4= X-Received: by 2002:a0c:be88:: with SMTP id n8-v6mr11429432qvi.78.1530239448543; Thu, 28 Jun 2018 19:30:48 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id y25-v6sm6390186qtc.48.2018.06.28.19.30.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 19:30:47 -0700 (PDT) From: Jia He To: Russell King , Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , "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 , Thomas Gleixner , Ingo Molnar , Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , richard.weiyang@gmail.com, Jia He , Jia He Subject: [PATCH v9 4/6] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 29 Jun 2018 10:29:21 +0800 Message-Id: <1530239363-2356-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530239363-2356-1-git-send-email-hejianet@gmail.com> References: <1530239363-2356-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 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 611a970..3a4d251 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1625,6 +1625,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; -- 1.8.3.1