From patchwork Fri Jul 6 08:14:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia He X-Patchwork-Id: 10511015 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 16BAE600CA for ; Fri, 6 Jul 2018 08:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0941428161 for ; Fri, 6 Jul 2018 08:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1B82284E9; Fri, 6 Jul 2018 08:15:41 +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 8F9D428161 for ; Fri, 6 Jul 2018 08:15:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6A7B6B0269; Fri, 6 Jul 2018 04:15:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9F3F06B026A; Fri, 6 Jul 2018 04:15:40 -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 86E7B6B026B; Fri, 6 Jul 2018 04:15:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 414AB6B0269 for ; Fri, 6 Jul 2018 04:15:40 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id y16-v6so2355065pfe.16 for ; Fri, 06 Jul 2018 01:15:40 -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=soJ92Qu9tM2JFI5ZID5kqWcsPl1HiS+kkAQHu5c0E4Hg+gM8dRl9zGW9NjJ1A0+B30 PylL4JGEeIunWHBrfOY0lKClDiajZLDL+vyxiwybR3r4Cf9tcWflGrCwCUttSWplHbYX oVmQcZrew/08xfqIGqmwE6Tnd2vyFbsO/FdlG4DnD1dSY2cjKqkJ0tgFevFhICUynBb8 vBHLXQ1cboHYKNAvc5VrGRMu16TQbgG/sXXBV/ao2zubgw8x0F4fTotLcxpnqgDknmFQ y97rDSQBBEDdPkb75OIDOzm73XDCxO83L2Ie8+kEc5ENKXB9OqbIF09QSSoNLFuZJst/ WqCg== X-Gm-Message-State: APt69E1dotVi88TEzK9Sd1NjfwBRUk6PgLkZujNOuPw451QEsqz+yX/I DrxHJdTu9e2zRVujzzAU7HxklR2Pa2ONWCb5lmR1ShEzZEQv0E9NekTkAtWsfhB//9UPqduWSci XwbfrbJKORWgVNoy1cau1NmqZM/KOrP6oKA6L6DKtokoVaRUxMK1kP99eHhwRLh9pbce5T1Njec 2Fw4re+A2+/CuzLGmSVKyMhrkDVJnVMsGq31Pp9PPaB/BQdag0cs9D1l3d8ymNWyvkzBX0q1k3L evcj5+qTGA3tWUK4121aoI6lq/4OFjdDX6F+z8IEOCxBDnimqmjmYD7fwFELDDbnFnhd1RWQ5A4 PQlXU2W7o3vxFEhnZD3UPI9Hs1sd0ILMdC/nncN8fipKoztWwpZPXGkfCgAllwOBJL7kao1enVd h X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr9576383pla.287.1530864939948; Fri, 06 Jul 2018 01:15:39 -0700 (PDT) X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr9576350pla.287.1530864939283; Fri, 06 Jul 2018 01:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530864939; cv=none; d=google.com; s=arc-20160816; b=RZGjm2f4UwNZiPQWlGzxCUS3V0EAdW4zwkRysV+lL6OUG7CQEy4Orq2OwPwWu5PEvy kCxZDSwLhms9D2mPtRUz4Hn857ZdLPn0WdKx5grk3t5HwcZ/E7onnyCbTv+QlJY0dSBw +MP9ESKQWm7g51TFoiW8rGmoSfiMTvFmAsfPbo+d37wPs+izwedxus+00a/lNofEg2ao +RCKhIesI39C+UPl+fjShS/JcrOWnmiU+ZlBLUMm/89yG+6380sj0RsMVRwle2kIPwHI u8RDz9NNUAoDxiWL7Q3oDnDn2N8MKnJbnJpBdyzlZ/EdD8hBCZPD94ebom5t39u9zrAl 7G5g== 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=uWKarZbWS3+McbAOpxQTMj9dnw7E2SOjVj3+99nBwfsqbUoHCvyzKa7JloWDSNwUVE 5eZPhpXJdskz2qASzrXyBx9+lAAY20lL4PUZ758SE09XKM1bmy5R7uEHxTI54X5WioW3 w5ekYyXEZqlSjOM2Za8dmgDy4LZwT1MuvUwJViP4Iki6ImPK57XADzidh4toU5xUyNC9 5xfAWL1wKbSzKbIZH+IMksoLEsP5TSBkVUWXQ+NUjnmaArF0htBtMYNGzh9H1sDlXWUy /zE6AFxeeh1kBKoQsRwtl692esi1AKzWwZ5yOQBd690AoNLZ0VB9EuYCx4bNfVu1bEC2 Pylg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qL6xuEtO; 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 l11-v6sor2150114pgr.113.2018.07.06.01.15.39 for (Google Transport Security); Fri, 06 Jul 2018 01:15:39 -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=qL6xuEtO; 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=qL6xuEtOi873cJNN8yBFvJs5J2KPvYVlz1Exa+eLyhmIEjv/WSJKIC6UsN2mTjk0gb 6VOJSC6G22XEXdGatJt1pAnK4aFIpWi0l87jpTuZv/EknzJvhQZWQlpQmejXePFo1SCO zD18mecVcXhK138YJrjVVvUEUWXjb7055rOeK/QiQY/MGxOhaol0DZpTey0HISdu0SA0 l/flRC4G8+bi2PcqbNkWtL3lHzG+L8zfOT84LzURF86Lq19lk1k1VOaVE9aQUjh79a4S QN7xTAuVW8cgEdi7KeiA7PmgRlJDYAttAVYyBBXSpZ7DMuvoWBQIw2r08InQcyUVu/2u BkIQ== X-Google-Smtp-Source: AAOMgpcLe2k9iOOlEKpuznSMye/t44iTuqQYI3UOihRsRGGhobmGVIcWWnjOOdQXe6YrLHkoCIKV9w== X-Received: by 2002:a63:b256:: with SMTP id t22-v6mr8810324pgo.101.1530864939054; Fri, 06 Jul 2018 01:15:39 -0700 (PDT) Received: from ct7host.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id c141-v6sm4673049pfc.25.2018.07.06.01.15.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 01:15:38 -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 v10 4/6] mm/memblock: introduce memblock_search_pfn_regions() Date: Fri, 6 Jul 2018 16:14:18 +0800 Message-Id: <1530864860-7671-5-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530864860-7671-1-git-send-email-hejianet@gmail.com> References: <1530864860-7671-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;