Received: by 10.213.65.68 with SMTP id h4csp1929039imn; Sun, 1 Apr 2018 19:34:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx49k0lARkDcYklHtscVN2SI96h7DzpNSQ53CYBKbBW6tQXoaaAsC/mstkcnlCN9g94HCBFUt X-Received: by 10.101.75.15 with SMTP id r15mr399765pgq.97.1522636473626; Sun, 01 Apr 2018 19:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522636473; cv=none; d=google.com; s=arc-20160816; b=F/KskKbNxhhiNZ+C7nCXYKWIucXIWIqwDrVTWiYI/kGtUM/yvyWpJApsU386Vg5Xhs CmpYjTmeQvpVLJ1muIsbyFMczxT2XZahaEPOXB39J+HlIykFBR4tukiVUrEAJeOjFZf2 LKiNqC+oQrtCX7PsJbEJnW/44JhMPdphMgUYOI/RoLE6Rn4ZBZTBvL0xrpZvJrRXYCkC maJMrxD3Rm6X6JdhrVmpqQmiL7MuXwFEfCvzD9aQ2j/HMNcrAIopKYWJoWGK3gyQ5Tsg 3ZSQB4wRlElZUlf//i/Ig8ABagjuGvzGKWtTdtYyhv4QwoUaLZu8aU5vRPzB57lausOK eXtg== 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=qp5NKpTdcRM6Rau/uqwRW72+6gftVpoNr2Kh3FeSdLk=; b=f6ArwvNtJaLRCpSO0A+944T9rDEidpbTmsRaaHc325ES3i+u8SVWhXHlxbLJztNpdr B/LxhKmNrSO9+8lwxGJ9eqHBk6n0nb7KvPdQQQhsp8mLjRtg99AYzbVNUsSQQm4wDkW1 3n6sSfro1MpVQGrwT0fyK2XTANe43k82DLbAfdBLQ/oNl6lA5iSf7Kuq8JGjqaebfFmq xZmtJjqCULBwDN2vZVdN5NpWbC2xUF0W0GO2z7qpypUH/UCkqZf5RlgeDseC937t0Upy Lf3wBlp8YJzWEj0X0uNn/1h1LlZZ4yq3+KqEMrOb/WCVFwdK+HlQIQ8QEKS8Y+ZrdzK/ s77g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dDDbGEDL; 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 z20si10014335pfe.158.2018.04.01.19.34.20; Sun, 01 Apr 2018 19:34:33 -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=dDDbGEDL; 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 S1754181AbeDBCcv (ORCPT + 99 others); Sun, 1 Apr 2018 22:32:51 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40386 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754132AbeDBCct (ORCPT ); Sun, 1 Apr 2018 22:32:49 -0400 Received: by mail-pf0-f196.google.com with SMTP id y66so8542025pfi.7 for ; Sun, 01 Apr 2018 19:32:49 -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=qp5NKpTdcRM6Rau/uqwRW72+6gftVpoNr2Kh3FeSdLk=; b=dDDbGEDLCy7gkR/kblFWe8VDkNyGj5uiDLQ6K0Q+Sb3owWc8wnQDu5qIK3FjLOX8s6 nrhXd8CDbutohKYkxL6GH1HWqzGyrMVY+zqbCij1jgvxujvNw4aahQinNkwmOhabGWXO WZgncQ1IhVP1k0pKyZ6b32v+egcP+xIzfMNAQ/ZI442F4cKaMPDPZdJ/jML0tz1+qpxC Of9YjnlgFt3BqE8hT6c16Eq9ZsH5AjJHVYh4j/z3QYokv+vugreVykgM4xkDXr37dlT8 lnyyxAzNr8MObhlCDFCGHCHfZNA0U1iB8V5+GqfKzbAj6dLJ/27KkZ+HVjE2UmMSVKFm tT7Q== 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=qp5NKpTdcRM6Rau/uqwRW72+6gftVpoNr2Kh3FeSdLk=; b=spADO+LW2EW8nJdpJq52RBaI8Xp+zDiNIEg0gOkDbHk05UFMlBatDyo6sKxD8wCevm /6lciePPSMq7Z6cAqKRq9Te4hnMokbR+9+S8RS1pNQLS3Gv6t3PORhVQHr8JZA5tvWOz FYL2wEQhjiOx+xyLfssSPYG6nL6PdozyplkVqTMGVIxAPR+HeITliUFPVl5thbUJ2D67 S1f6wsUFdjNkBR8QmxaTyd7OO77B5vl2i0ubRpK3+sN56nCFQ6zV8z9n0lgDBexDjsGT gt33Xc8xGRuumEGU5UgoNoipb62OBoHR/I7AIGcfuLeHdW+CKW4/iG+KJx5esenK8cwH Qlsg== X-Gm-Message-State: AElRT7FAfeo9RaaTuZDYEfldzkF4wsuRecUKVpcVqWXwKY1gVVFZsoYw ahVrbB3UuX4AVp8ZEZrjzPw= X-Received: by 10.99.95.84 with SMTP id t81mr4924886pgb.400.1522636369410; Sun, 01 Apr 2018 19:32:49 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id t20sm25934371pfh.182.2018.04.01.19.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 01 Apr 2018 19:32:48 -0700 (PDT) From: Jia He To: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Andrew Morton , Michal Hocko Cc: Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , Grygorii Strashko , AKASHI Takahiro , James Morse , Steve Capper , Pavel Tatashin , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jia He , Jia He Subject: [PATCH v5 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Sun, 1 Apr 2018 19:30:34 -0700 Message-Id: <1522636236-12625-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522636236-12625-1-git-send-email-hejianet@gmail.com> References: <1522636236-12625-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 0257aee..a0127b3 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 ba7c878..0f4004c 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1617,6 +1617,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