Received: by 10.213.65.68 with SMTP id h4csp245783imn; Tue, 3 Apr 2018 19:59:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx49lU2VC73CjHP6DYDgn40C0+ge74xDKKJ05C12ukhz3z3wSV71ysueOZhbacakkFZ7JXR2s X-Received: by 10.99.100.132 with SMTP id y126mr10601547pgb.77.1522810744833; Tue, 03 Apr 2018 19:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522810744; cv=none; d=google.com; s=arc-20160816; b=f5BXCIbCocJzwx8Asv6cKoSn6ldubBIQO9RMR5QihHaKabdye+8MxFWPXdMKTDlwBO DE9TNg3pPTgo4mEEQt5d1HYtgPwzJz3XJJsJzJAuFRjPBmSOPcc6kSdjJcMTykvKgnip sxpceyhw2gvMWos0xEUiYQvP3oo3u+MKbf+HgutMSzQ59nJ4OzFH/fXHjiBqBd+uUWzR jDpHTE81HbHUq9Vd/flzzrMNi7j6d8Y7BW7WTn0sIpu1VK6f3hdy6mLdhcGU9IMo9Qgl swi8Ht9OHECkYSoWRgajbUL3K1XmnPpudoyiuQeCVvVK2WsBy86xTK8ztPKlqDoFWAMQ AKQw== 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=iBZHCBW4BvlpP/WE8DGI28xrDO81bOUvUzXIvggb3+Y=; b=t0I23KagQxJrpHBEbyaLhlcwFPVNfFjsRvdofWqvSdTM67h7AFFzfgVmqRvbMH8id9 ULt8QmA6IK58lSOBQWPXeg88ju+iW3vxKWk+8Q0y8mH+9zjyFMhuYEUNyqxtjC7Xm0PE Ic6+0UpG5qxJHBLRq27uGZgMmotAcldew3qSwc8sH/xlwRG2GA5lY/8w6LphiFo/Z+z3 xa3kvhG7FtDHnjdqeC81lTA22HpkCU+k8T2SEqrJX9n7fC3svEtXWDL/DzGltUv1+off kFXmbTbn5r432MSjzNNVJv+DvJ1Deb+wTsXVMHPol5MzCTlBKAK+X1kS9ZBlPNnxyN0q b6iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dKhs8r/b; 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 x4-v6si1970430plw.354.2018.04.03.19.58.51; Tue, 03 Apr 2018 19:59:04 -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=dKhs8r/b; 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 S1753520AbeDDC5X (ORCPT + 99 others); Tue, 3 Apr 2018 22:57:23 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:42734 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbeDDC5V (ORCPT ); Tue, 3 Apr 2018 22:57:21 -0400 Received: by mail-pl0-f67.google.com with SMTP id g20-v6so11986489plo.9 for ; Tue, 03 Apr 2018 19:57:21 -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=iBZHCBW4BvlpP/WE8DGI28xrDO81bOUvUzXIvggb3+Y=; b=dKhs8r/bVKZx4YMIyoXusi5DJyha5GJzRIjwt7zOgn+pnY7Mx379oYIywmq+2PW2wx tEGuQvW1w4FWB2AdDawRw9repXAducHBRYQ+BjnNjGZdSsQJOfulqx/0ehlDIMaLUFgH 2QXNA54nNfoo9yP8DaNOmnXdCAO0NanxYo66m/U7J2zwTBuu5xDDDtFoGDBauzmt/9UR HjZbQ7DFxSf9nmICUh0NEBZQnIcgaHukyxHiVAjqz+Q236CuRJhxSkXtqvw9m6iGeHKl xlMiPAaq4xpA6p2tNXIWBqFT/QIOKl1xNmKqSpf/JBvRKNmBYDa/OxAG/7XxEE/7SU0H 3yEg== 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=iBZHCBW4BvlpP/WE8DGI28xrDO81bOUvUzXIvggb3+Y=; b=KdnvqRbOPtQvRnJgYtzGoxisaQTYQUWsnHGkh7c+RDVFnwjpWSl9b/Y3Z2YjyDiunq N2AIYdfQkPKw10AeCryNT1EF40SGEicGnh1XGHG2GgVyo9nga4lLR0HkRFgboz+p94I5 ikjF2xgzBKNjdDtk68dwzaxuQJxr8Tkv6NdVdHaT5mAHTXcepE6MKkAS0vOlN3MIOcHB EXAOiaBH2LKtTYritVtA5ei0JEo8ps4S68gB56SnBrpqXdnTCV4GhnnNtO6CgUxqDffc xWYBzL6l5F94HsC21vFKYfpI1LBkv1WKfqCyhdj/b/R9Wu/MPCphMS50ekEVg7s0cfuA eMPA== X-Gm-Message-State: AElRT7HTcwn/RAPXtEPYeIeMF8PvnKEd89DXh0eHmwYdPGPiqLHlmx6w Pyjnt4AZVHWKxUfPWzEU3m8= X-Received: by 2002:a17:902:7b96:: with SMTP id w22-v6mr15281001pll.116.1522810641431; Tue, 03 Apr 2018 19:57:21 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id a4sm8020701pfj.107.2018.04.03.19.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Apr 2018 19:57:20 -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 , 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 v6 3/5] mm/memblock: introduce memblock_search_pfn_regions() Date: Tue, 3 Apr 2018 19:56:17 -0700 Message-Id: <1522810579-7466-4-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522810579-7466-1-git-send-email-hejianet@gmail.com> References: <1522810579-7466-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 to find the region start_pfn and end_pfn of the input pfn. With this helper, we can improve the loop in early_pfn_valid by reducing the unnecessary binary searches. 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