Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1516221imm; Fri, 6 Jul 2018 01:19:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpckjwNGEGGuRtGBRQWaFbkujJCJWwuNxdqZawx5kfDLvNMYWT7iN2uk+BE07p0oe0mvKR/c X-Received: by 2002:a62:2119:: with SMTP id h25-v6mr9519026pfh.112.1530865168208; Fri, 06 Jul 2018 01:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530865168; cv=none; d=google.com; s=arc-20160816; b=y3r+tZWVycJyPmZH6FmzamjifkoQdIq1fiI5qGDtRKz0zsYeq89vF5ifZIimwxuSgb XSZJTJPjhLpHg/+yc5ZTTj6ZFw9HBTQssVPM6XNa3LGlIgdS2058Q1SIgmmX1coYhbGA slr26qaTB9qCNF4vmGmqTXslg+pgkkdSj7JuqFe60Ex/ag3FIk/0dTcHVZe4mtBVsBSF 0cxUcnUa0OnTH7ymmfinWeqTbr4igq9EK3HcmyCXt75Z4LWWjj/sziDtTbw/L6GQEkSX GG3nGoNHMbtYc1+uLGyJg+mqatWz0XReNgJ5ZFyFH2eUibsvfJhJIlAos7mUHYrxSX/p bh/g== 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=Xu7zqDUX8QRUXRdUoSbKMwz6ezRAXWS/xMWnFnE8u6acUlwrnG66caEaVyth/4adie w83pDDR/fYfYi7qb7wvgin2VqXuuSGZ0nY6bKaegJgeamcZQgFmieatVwOKc+O1s2w+1 H/JgcKvo1+6wpbS5nJmLFQwWIM8zJPP4o+/LMZH7xkjeNOhMm/y4dHvRfRiaSk5JbMpA ktukwc3MMYnHn5RamLAXcWq1dp1wBjbOZ3ZfKGrHV6VM4A+67Nkh8eg/BzOeVZwOpfu/ vbOHRF4vGHxhQOBI0txIWQ9pIWNszZY7HJ1UEFNUqAk3/hNqhP72CQccJtqrDwesgmJT 4KPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qL6xuEtO; 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 x21-v6si5791340pln.319.2018.07.06.01.19.13; Fri, 06 Jul 2018 01:19:28 -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=qL6xuEtO; 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 S1754073AbeGFIPm (ORCPT + 99 others); Fri, 6 Jul 2018 04:15:42 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38576 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753610AbeGFIPj (ORCPT ); Fri, 6 Jul 2018 04:15:39 -0400 Received: by mail-pf0-f193.google.com with SMTP id j17-v6so7792863pfn.5 for ; Fri, 06 Jul 2018 01:15:39 -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=qL6xuEtOi873cJNN8yBFvJs5J2KPvYVlz1Exa+eLyhmIEjv/WSJKIC6UsN2mTjk0gb 6VOJSC6G22XEXdGatJt1pAnK4aFIpWi0l87jpTuZv/EknzJvhQZWQlpQmejXePFo1SCO zD18mecVcXhK138YJrjVVvUEUWXjb7055rOeK/QiQY/MGxOhaol0DZpTey0HISdu0SA0 l/flRC4G8+bi2PcqbNkWtL3lHzG+L8zfOT84LzURF86Lq19lk1k1VOaVE9aQUjh79a4S QN7xTAuVW8cgEdi7KeiA7PmgRlJDYAttAVYyBBXSpZ7DMuvoWBQIw2r08InQcyUVu/2u BkIQ== 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=S16rzW9K4WHyQ1VG357S3aLMThxRjFBG5ZBy3qnDO0g7j51Z0hocRN7e7od2cgwyyu BLfYKQUl6ox3FsAWyEpaOHzs3Vf75fiQgX+Krn31FpkCNl96qF6HN6p/0O5yTfCJtuCe lj8QKf1b0J4zaXrd4db+xFp7Rt7600pk7qph5o6U2lmf8WevsHbHAkHv97WSRawWBjAx EoURBhb3Rv6Z8Ft2aKVA7xTx4ca89Go9854gncOhI10cYiNw3sO+ERX7ZxzVu2UglJvM vwD/Lx4NGe5nnBYhnW4qAa0jemNHZQNfG+7N7aBUe/NccNWPU39Xyplj81ELmlU7wFWD HuVA== X-Gm-Message-State: APt69E0Heh1M93nQ7Gg7U7SWIhEMR7veJS+RP+3VVIcHWBX0l/xAuLO2 O6RqIbRAHuktq4PxOmZ5ge0= X-Received: by 2002:a63:b256:: with SMTP id t22-v6mr8810324pgo.101.1530864939054; Fri, 06 Jul 2018 01:15:39 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id c141-v6sm4673049pfc.25.2018.07.06.01.15.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 01:15:38 -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 v10 4/6] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 6 Jul 2018 16:14:18 +0800 Message-Id: <1530864860-7671-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530864860-7671-1-git-send-email-hejianet@gmail.com> References: <1530864860-7671-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 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; -- 1.8.3.1