Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1549222imm; Fri, 6 Jul 2018 02:04:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfgmqBOB0EeSwRb9EXM4GeIAw7G+SI9ATfSOHzvPFkihkrMX1LUBy6jCEv7Mbkn6z2UAwbq X-Received: by 2002:a17:902:968c:: with SMTP id n12-v6mr9444326plp.15.1530867854894; Fri, 06 Jul 2018 02:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530867854; cv=none; d=google.com; s=arc-20160816; b=YOosp7W5uCnrpxaLQ3pjDUyDABoyjWdvhmE3V/B57HmqWV0Wz/HXoGG9JCcc8l/Kvp nRHMtDPXd9XvAndq5vXu1975oklysg7NZTpi2BbVDuBabWbtttR2ctJvLKgoO7AzmbHH V2Xo+q+wLeOfQnqcgqr8SW+7XbwnVuggIdr6wRSfNOtk9LHMMJkrNqXqXPODWTYQWxR+ adCXIzkYIdsU1arXWoRmjkOzmCPPBJYPRygOEW/o2fRaHlfuLUpqObyaEUKLKoMo1nvc BAgK+Va0uKH0XwDu6eJHaWTyS6jPwYxoMxByzDdSsYZkpJUGyx7xtRF97svM7ZHy1mBz qvdg== 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=peKuZTU+hoqQE6CVxAsxaZYotkiRsBW3K0grLihNVYfidvjoeD+r3qtguO0NWADNzy 21UbiRP1ZqOtIunyAeK5A383RLsPResiq1k4ZfS7mM6vOkgoBuVwRzxp8EbKPyhS2R7/ QvchCmA7rjY8eUJtUrwEZxwdt9t7mJq5RPARoP3AEt4aW8CiG0t8rFrXbjACOGNfZB8f sASGRppK/0cMdTJTCf3Dqyz0RrYPI6UpHLeNQP4OWJvdiENB/hgcaG2Rl4ZT3rhZi3zz jcOeXE3W3q4XJI+hAKXDozcz5/kavYyjcU4l0N75FQ4fS8xIjatTkobuXze3HSzRmFe2 sqDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Lm5pdDs9; 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 k30-v6si7738533pgn.258.2018.07.06.02.03.59; Fri, 06 Jul 2018 02:04:14 -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=Lm5pdDs9; 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 S1753946AbeGFJCa (ORCPT + 99 others); Fri, 6 Jul 2018 05:02:30 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36428 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbeGFJC2 (ORCPT ); Fri, 6 Jul 2018 05:02:28 -0400 Received: by mail-pf0-f193.google.com with SMTP id u16-v6so7887885pfh.3 for ; Fri, 06 Jul 2018 02:02:27 -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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=Lm5pdDs9QXa+vQlbDY8tzb6VmT11HogGxmVTLSZVWXKjoApQH2S/8K6ey0OQti287R 8Dj/ayQDJFJx0/3ChVNfMU6g1ro3FqNZsjmA5l1I/Js5Q7GFWwGDKJQPCNuYyd3idtv8 sg1LFvAJI/t0LVmZm9rWTaELjUNpjntJ86f6GuNzveIFLq42qPu1DGcjkQGuPShAp3+4 vN5qH1G0+utDojn+ROf51Tf64OY8Ymqqi7tOtEMfD0O8mc11+MYXM9gZBUGgHvM0cwl6 AER7Jo6eIlTxCBFKkT+YaPjrgWc7BIvsQNUNu0eVD6JIfNUZYuzyzzcrocj+K5X7Br8J TztQ== 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=QS6x3jx7JXO4MmhHqS26Yxw1c+NSMSy4IGrnFynFgEQ=; b=pASP0Rv6ShsZVdojajbcBrZ8PYL1uRJXvKHUhgAHiXMrATdk5yJLlkiwlSD/gD1sc0 56Nex1rnhxknaWNQJRjaNlOvKh/PML27P0uGU6znU0ZGwrqKYSPpSi9jgtKApZ5Qz2aj GbsQQ1cY3OFnokhsZwlP5gAzObVC2IPHLacmOwkOvjGLbn1fMDaNV+RlXgjlUTpzOZI2 3c+E5botdjSOsmD+H/1fXxwshLOScmI6ThczrOWG8+UOCP+O3UTzeDtpGc+Xba+bcbHo ps74/z9v3QZYBP/9es6nsNJse2CytdjpMcHVN2DFp6Y/BtrBaMEPAF3L8Ck/VGJSMGxh QNcw== X-Gm-Message-State: APt69E0DX/OZKLXsKYqJbPCM2fQWSmbKP7NSFsX/wU1y711ZuWTVimKo t9/Q6hCpaw0ZWdnqjdMmeoo= 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 1.8.3.1