From patchwork Fri Jun 29 02:29:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10495533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 60E0E602B3 for ; Fri, 29 Jun 2018 02:30:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CA572A6B0 for ; Fri, 29 Jun 2018 02:30:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 400EB2A6E0; Fri, 29 Jun 2018 02:30:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B49AB2A6B0 for ; Fri, 29 Jun 2018 02:30:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C46206B0010; Thu, 28 Jun 2018 22:30:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BF5E46B0266; Thu, 28 Jun 2018 22:30:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE51B6B0269; Thu, 28 Jun 2018 22:30:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by kanga.kvack.org (Postfix) with ESMTP id 8331E6B0010 for ; Thu, 28 Jun 2018 22:30:49 -0400 (EDT) Received: by mail-qk0-f197.google.com with SMTP id d66-v6so3581816qkf.11 for ; Thu, 28 Jun 2018 19:30:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=KLZcLD+HkQuv1Dms0jlXw2m73ukkpfbtFF2qHvkCt0w=; b=JQOnMEq+krZl1//okC1oKBcc0s35LeAiwNu1C8pneO6ZgTQA0mjJfPpV6WjcI0hSne ZvV7q+AX5iZkAuYy7nhJIfcCYOkBD6Ona1bZw+NBnjmaipK4VRly0uXrLSR7rphaiawa K2BDqKhNj4hP6YSzByM7NReqTBE7RA7nzH6XxeP6b+8g91WyJwyz7jkcydrqOhbb5N+P POSnwrio7C6ExeQ3Rf2F+ErmOH8KRv86qfL8Sq7ajui7qVLtiq1CfgAFNF8swSMfUufe vOEuZtqR/GG2GWas4GM4cX9+byTWQKp54bjVGQRxvoLJAVi4y4H7aHR2SGM6UMnW5AMP OKCQ== X-Gm-Message-State: APt69E3BkF9JifBSw0tBnPZhySZ2uu1gPW0VTmIIo1oaNfKVxrpxhbua xTBD9YIRHHO6twRmYzQqLaHABPpECzB70z6a+79ovuOaLlr6XvYrnzYf2JKTIRQZi6JjAdv/wb/ Pfoi2ngW6nDblWkII1Rp9I0g0wA2eifiLCS2w9RnZPkrk/tC/FKnCQ+3adgmcInAOJLlVeEu5QR UUx7E29Xcvg3LRYS9bXkMkNqAKgV5UDNGBvTXWUcGM4DzuFMHolo23IDzzCin7PFTMevG1xxnDf 8Id85jYv2fAMXw8LMbkgLotV0woc9EM8zJDSeep2gBbhbl2NNvxFnhKm3CyUi6x4N9FT3yzq6Qv 2h8I6Qv7O2lgPT+As93a3TxduPe2MSkGYfWATB9jXp2W0knFLdX/sIcdi7VTF0aYLwx0Syy8U3R Q X-Received: by 2002:a37:bbc5:: with SMTP id l188-v6mr11048313qkf.243.1530239449327; Thu, 28 Jun 2018 19:30:49 -0700 (PDT) X-Received: by 2002:a37:bbc5:: with SMTP id l188-v6mr11048286qkf.243.1530239448706; Thu, 28 Jun 2018 19:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530239448; cv=none; d=google.com; s=arc-20160816; b=SXM0B4+VO5hen96WEJ9oBceZ2K3p0G0JI0y8jjBCoefC2yZsfrBD0pEDoqg/Eb1Yxp vS2OB9GCn9m6z2GPW/4srDuhEcj+HW2R2qUt0cR4vt5IzHzSlBqyi7DlCYkNQvRR695I UrdGBGAvmc7zYVytk+qFRIri5nU8ggbVWna9CiuqOy1wLrPmFvNGyS0ct10RN0Ko8wtd OOK5dohJTX3NukVqrlOUwyQX22/7KYTPibIKE7+tBaAzsw964N/cNnZBAsWpijX4B3E9 MGUbfcWYBW5hAxx+4coD+j4VRsDyUkY9NWPJIwHWVvk0CxD83R+x45TqZlaS6pJD/gQD RRYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=KLZcLD+HkQuv1Dms0jlXw2m73ukkpfbtFF2qHvkCt0w=; b=s0S2kjIrg9S4iU3LvRIsIUMfb+u8coEY2Nclx8h6zKAwzIxxXZHmVCq5pc87Wl9peA MKKTPOd1H9fwCDzyZyFGH2xvUlDRoa7CpH+5vgZEIZiOBq1HtYPUlYwz3RWxmfFi0myt 1FX6cARJEEI9fRDwD23iBfdPo+p9aJsQv2Vc5UEcb4iH1BhUZf4VAW//hWJzBcPBn+4a uy3X2TYuoouG2Pmjq33nflgBYJOcIkV83MtpVSCOr6/TIO1xMc7kDQgLRTWu+kEP4Wdd LcPqaPVaF8euQf0LhYtZGl5y1vT+Im1ioQWXm7SU4hbrUSMD0VbcGuWpOkzUlAB0ANxo CyMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jLD1uaCn; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e45-v6sor4016978qvd.130.2018.06.28.19.30.48 for (Google Transport Security); Thu, 28 Jun 2018 19:30:48 -0700 (PDT) Received-SPF: pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jLD1uaCn; spf=pass (google.com: domain of hejianet@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=hejianet@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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-Smtp-Source: AAOMgpeQz4N+gOPnSzkC/neKDGvGOoE2lHAAjhcPRr1fNU2STUx8yTthJS9cFX3y5WYhcegenwaRMQ== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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;