Received: by 10.213.65.68 with SMTP id h4csp88729imn; Fri, 30 Mar 2018 01:18:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RTEiMVcW6NztX1zw2lXQ9s56gwO/kFvQKQb2SCatfUBAUgl53PxO5xu3J2vjPrkqBzzbD X-Received: by 2002:a17:902:a508:: with SMTP id s8-v6mr5203365plq.216.1522397928476; Fri, 30 Mar 2018 01:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522397928; cv=none; d=google.com; s=arc-20160816; b=TVxJxyXreIJcVtL+tQkk7PULePAiL72Q0mfUAyRPBTWRmP7yK61CjXj81ELSdTsoDc Lr7AIZX4mCH2Ob1A0X+tzBEvP2SIK5IRFSv40rFVVfAvkpOOIZNQKk+Sd3Zl+d8V7gyd pUDXOgyEJZU7tLSbwaqcH87t2aR8uhuNVoRpST6ScNbGDBFSteCnn57oESex5Z9LU6IN p4Cqpg3FhZ/CMEDeq9qWyD+6MF8oawD/V5lVvNj34YcU8PztvbLJfE46TlkVyq0elR5k 5eEQlxbInWNLD38mmGTjDv0JzlReMApGcdUfIMIHrxR/4oRbJaEz4ycL16onGcTN1mnl nUag== 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=ql718HBqIe+7+iuhay9/LRkOOHZ0YXmTv5WZq0MYrtTut+K5Fp6jtgX+WgEgKJQ/RL HK3Lb3xtmyvIuQ+Ss3gD8hpJMYRsJTUMNmdfE9RnOHC0VXQ/w6OGxhJpqBb5FJVeo0/9 liCvPIdCoYjVfkHdv4KVyrmSyYMfZ0YkniAWZHf5wi5d/SJkF6UoX2WewMlyLwNmyZ49 BeQZ6bxeMdkjzUGeltLGiNLnQ+P7FnSeli3BHBemyAbo2YJ4kq9nq2LV5J75X5NkA88f gydx8mO+bNHINInZkcEES5C2+jrRjBLwYLedyvuqNicgw8sk0WUR5e/45vBFPdJhQRg9 rl+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mVkfziFH; 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 g6si5250742pgu.737.2018.03.30.01.18.34; Fri, 30 Mar 2018 01:18:48 -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=mVkfziFH; 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 S1751322AbeC3IRH (ORCPT + 99 others); Fri, 30 Mar 2018 04:17:07 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35861 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeC3IRD (ORCPT ); Fri, 30 Mar 2018 04:17:03 -0400 Received: by mail-pg0-f65.google.com with SMTP id 201so4706426pgg.3 for ; Fri, 30 Mar 2018 01:17:03 -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=mVkfziFHvatrCIH+PIWqC6Wdd2IugISG0xx85DlgAlhurqxeWlaQRz4/nzDJfEPYzM BALatDkil0HXFUtr1aSkLV3OCgrVymSAx9sMy/k2q2sUrGMQ9M86haQ4joyLwC1ajNVb pc2rbuYOFaA5AoOIi83bsSxeYdKWKLF9uBcGWTN/rQLIH5WWA4HW1pAQ3xLg90hFukR4 elog1EtZW4krchSiAeI8dtIGxsTXCNsmz7KI/jC3B+aDbC6s7c0V0LDBOHt4xPt4ii/y kjRH0l0X3JHtgmshbeERLKOCI+as0noQQrH93Qted7jpEZejrPar4W3o0uPMzFJ+iNhY vJAA== 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=bamP60eH2lg5+LtbcqJ0RHpWDWyaZ3psguPuui14YZrJPn5JCd+Nb4m068DsgqnIcd oQ8AlqtLJsS+zUYcsGJRcGXmiDB7pB9aHjvrNYwhKIzKLd2w5Mhgx71AKbTJNUzZbl9V gDYHzbnEtBAzktwdm8ZLa5H+OrSrJTBx5B+yIn18Klikyoergna2rfcFARW9r24f9h4V Ih9RPDK64EIQclQN7M4GVtNED2nar1jrRyDOlBauDgnTMdV/5TAYnbXR0E2jS3cOiqxa /ChZV1ypi6MIFyx9V6AeIpbQA2RzKvKHlNw6JWQQkoklRNFdiXYbO1thfkdCrUwx+6wI oidw== X-Gm-Message-State: AElRT7GqLsMdPA2Yd9W0oKy7ixiTdSEPGKZDziB6Xtcu4VcJxVDNtKwH y/77lMux3XWxrQlUOiKZ1Xk= X-Received: by 10.167.130.76 with SMTP id e12mr9172971pfn.192.1522397822665; Fri, 30 Mar 2018 01:17:02 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id l8sm4269837pff.126.2018.03.30.01.16.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Mar 2018 01:17:02 -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 , x86@kernel.org, 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 v4 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 30 Mar 2018 01:15:53 -0700 Message-Id: <1522397755-33393-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522397755-33393-1-git-send-email-hejianet@gmail.com> References: <1522397755-33393-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