From patchwork Fri Jul 6 09:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10511139 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 D40A0600CA for ; Fri, 6 Jul 2018 09:02:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C60182855C for ; Fri, 6 Jul 2018 09:02:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8DDD2855E; Fri, 6 Jul 2018 09:02:40 +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=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable 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 65BEF2858D for ; Fri, 6 Jul 2018 09:02:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 454BD6B0269; Fri, 6 Jul 2018 05:02:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42B976B026A; Fri, 6 Jul 2018 05:02:29 -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 31CEE6B026B; Fri, 6 Jul 2018 05:02:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id E06A56B0269 for ; Fri, 6 Jul 2018 05:02:28 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id 39-v6so4185437ple.6 for ; Fri, 06 Jul 2018 02:02:28 -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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=idEaVqr0u6GYCy1dVOU3o6Wd0l2ia0l55Dj9FEiRqVo33Ebeghp+LIHg4WCuVk7sFk ulc+i05a6VQm3EvXiXiIiOCJ1UumJHIsn8u42pD+znxWmth2GCgXCZpyMX8ukFi9Z2sy GV7nOUtmlCn+bMKg3dyr0JcFojIZOUbZnS/aPX+RfBAtW5C9+87VOjc9+EDfv+Aub8D7 +6NAcm3CqD9gLTBJ6TXgW5M1UQWkAyZRF8D3xYelZqT4US6X/DAqdfxNHDfNaS66NJdP ZhMGkiB5ounRTdxKy+OG1Em+n2/JmznhM1XqaYfykmwhrZg4mxvrtZbDSWKS0QJxSvuF RszQ== X-Gm-Message-State: APt69E0QlDFckw/DS8esxdUk3/24bNhQ6fmMwnEXGeZehx0NYhWSEksu b4f7Qs0eee68G7IgFT4TTGzNvivWXbJ61Ccf3vG9GzAQpfOByzci0/3MC0ANdLDmiasOhUj6AWy ukJsVnsn9NOSdeD46FZpo3NVR5pPIqCA4I4yLJQNGCVOoFqettHS6MGKupSSQGwtfRFIZgRrzt5 5N/Xo/Av0421KWNoXhWa5JIXagWYpqUPkm6EZ6E/V6HApI/Lf2bPzsNaeUpgWHUrtZDHsdQP8zm LLopdkumm1PzfKpvi5Q66aVQnUD8IHJ4vmL1qKoc75rz21o7Ea7NuU6VMIu2huKLtwtbulAvyGI tBxa1edGzs0wURNsCkTitL/tJA9LbaREpLVLoiYPOf2yGkZcnj9mOVM8kqr86ui9fysBGRRBR1l j X-Received: by 2002:a17:902:650c:: with SMTP id b12-v6mr9511114plk.31.1530867748598; Fri, 06 Jul 2018 02:02:28 -0700 (PDT) X-Received: by 2002:a17:902:650c:: with SMTP id b12-v6mr9511075plk.31.1530867747942; Fri, 06 Jul 2018 02:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530867747; cv=none; d=google.com; s=arc-20160816; b=C6KUNCUJF38PCU6w8FEXFHfJQC6Azfmb4AFnRQaAoI4xGwaLNMUQQV9/jnSm43XldO YCvaWaqxrIlgc9fykWs1RalZqen1vDjnm4eEm9rmxbuuxuCEf0c56pIY4Sd+uMrBBWX8 DvtvVl0ag5QK60KdrZXCEGSYrZjHFK/YEv6bJYWp2r5zWhsDiSnWvf+O0FWcfOdrSiU4 42wDLlxDyCcw07xCFDHLFrohAhlA6Pl+Nflg0bfpMo7y9qVUhyAJsd8p52nR96nnX8He USbvlRVx/OMrEddqn+CY7lQLud3U7Il/YEqWD+9+rUYljoLMsGX90ugO5qbHm69NbvA0 UTWw== 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=KkwSDuvvPCtoBZRFfuuB7OBjF/ZsfPKOqS1m9giT8Iv2Nn/+oSrZhWqGg4KbI6gj15 yzWiv0Rkyy2IpjgIDLii2foBzvX0CCtrHFJmpr1VJeYLQy7MvYVf/j0xoru4Altp51Oo qKkanD+xHJqKVauFJ5QAePkZ5bYUBmecWuYJxE/jc0uIOb0HleGizGke5y9FOT+felYW O7IT3jDAPsLq8fIktrJthvHzxBwpWrBLQeMRAJz+JgbquaipUarqJte/TM6qrsZ1pH3G Tt9YQHZsv1FGFEMRiHYTkwbAKrrI2aIFqTcz+yCUUCW6nZu2iQc9XZF2Tqw7IKkZSuN0 46fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lm5pdDs9; 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 p128-v6sor2223634pga.26.2018.07.06.02.02.27 for (Google Transport Security); Fri, 06 Jul 2018 02:02:27 -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=Lm5pdDs9; 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=Lm5pdDs9QXa+vQlbDY8tzb6VmT11HogGxmVTLSZVWXKjoApQH2S/8K6ey0OQti287R 8Dj/ayQDJFJx0/3ChVNfMU6g1ro3FqNZsjmA5l1I/Js5Q7GFWwGDKJQPCNuYyd3idtv8 sg1LFvAJI/t0LVmZm9rWTaELjUNpjntJ86f6GuNzveIFLq42qPu1DGcjkQGuPShAp3+4 vN5qH1G0+utDojn+ROf51Tf64OY8Ymqqi7tOtEMfD0O8mc11+MYXM9gZBUGgHvM0cwl6 AER7Jo6eIlTxCBFKkT+YaPjrgWc7BIvsQNUNu0eVD6JIfNUZYuzyzzcrocj+K5X7Br8J TztQ== X-Google-Smtp-Source: AAOMgpdrQogf7Agsnn4Fhl1vyVKv8GHnUUkHWQWKrCYczG4NV7lTbP+FGOMEo+WNQawOegDtDjCUhg== X-Received: by 2002:a65:654d:: with SMTP id a13-v6mr4046734pgw.132.1530867747711; Fri, 06 Jul 2018 02:02:27 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id e5-v6sm10837092pgs.59.2018.07.06.02.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 02:02:26 -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: [RESEND PATCH v10 4/6] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 6 Jul 2018 17:01:13 +0800 Message-Id: <1530867675-9018-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530867675-9018-1-git-send-email-hejianet@gmail.com> References: <1530867675-9018-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 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;