Received: by 10.213.65.68 with SMTP id h4csp1056581imn; Wed, 21 Mar 2018 01:12:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELuYFIahjixcZcKBD8aPmuUhVTUjiYoeR+Xiy+uVgV6DG3RDg1eCWAYvoubVFgN9E4tj2N7L X-Received: by 2002:a17:902:63:: with SMTP id 90-v6mr20143176pla.125.1521619947493; Wed, 21 Mar 2018 01:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521619947; cv=none; d=google.com; s=arc-20160816; b=OisTLsBW+IcvBz6WA/ObpSZxdWo9qhoFmNx8gqHgyhFNpGvRnF2WtWLNgK3I5n/Yk/ +UwPxJtZyc5IhJ24fVFvbigNwax+sO0ElrRQ+VQMg811W9mUgkld1TE44DUZR+Oia/6t vPzgYb4/owiW6RAdsGYfx4JYgdLrNeLiT8+ltCkPazgg0rsS5oNGaVA4zwR8sg43tKrF arEHJY6tVDninue28MwTDxDCJF6OscdFlIXIqvK6WrbztQ+QrazLCEheOrbAlVX1Xtxt luDkjSbft29XEDz82lUNlzO2YczLC5pCDsy2ptfst4agxbCS3POiwI07BsPtM/1WL0zU WChg== 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=zGzDxI/pQbF6JtLTpDOhPdXBCDikCpmHgp2TY5damxw=; b=zM0hTMuDEoIqkUeQV9J62mSjDCTTSd3xD8JLj9srFQuJ4OAxY8tvYSmdhH0h2BpdX6 9fehvi3mbiVC4T6rNJrQCdTsf7rbNG31ogZ6mHBqf3yZiEtZUzxVctwEt+mU7pwkpgEu dR8pZ512xbg5V6vTSDYq6nUvtgyGZz+7aUnPkQ35/c/PPcp7gqnw30Y13D8rt+F9LrKt ak7+XknDrs+5VeoCiKdtqxGovXCuxpj+euLOS+diiZJT716VRXVT7dUDlfPcFy9rlYTZ 6JYLPcCPIJFtw2ZFfhINxCY0nY5gHQkaFQFqTIm3/cfbq5z+chsjJYWHCPKkg1Ku0e4D XAQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l6GoliF6; 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 c10si2394293pgv.591.2018.03.21.01.12.13; Wed, 21 Mar 2018 01:12:27 -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=l6GoliF6; 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 S1751889AbeCUIKu (ORCPT + 99 others); Wed, 21 Mar 2018 04:10:50 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36773 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbeCUIKn (ORCPT ); Wed, 21 Mar 2018 04:10:43 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so2697052plf.3 for ; Wed, 21 Mar 2018 01:10:43 -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=zGzDxI/pQbF6JtLTpDOhPdXBCDikCpmHgp2TY5damxw=; b=l6GoliF6OBFszmXBWUsCAcJj36OekxTmfI8eatAflExcaOxYHSOuRbF93FoFcZAIEH 52YeRufCCe12hvzTwiT6kKrg3fOs93tHZaP7Yatx7W1NvS6Czoe93BUJA8e7RqgD1eYi NXFgwWEJKies4su/PGTraEKy/Ftvkke288VPaTabKHjkOEy06SbZp7n/C877tFFgT6M4 hKqF570Y+/UXDW3PyznS+lh77/IDnuLqN6zZUnRWYmPJyGccBLP1EMKTDUHduDafzph/ /bc51+0qAfHbdiSjmcxrYC5fAFKvUGYGYmnwpVA59pdGcRnvi+AvIaVQWBWoyYsDRAmE 5+wA== 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=zGzDxI/pQbF6JtLTpDOhPdXBCDikCpmHgp2TY5damxw=; b=OwbXj7FHueNbef9t5O8LGtHQHruu6Nui5h/Ov38rFfPsZE59BIpy8Qt7BxkMAxLgI6 kqlHXHtq+vF9kaIoIEXXnnFy7oq4MVAULT4samXC3uOY+9nVk7juRmyYWDXPnW8oU3g6 TxlPNcf3YpS+VpZZAnaT5bi8OANA86vLFKxmlLB/MKZcP7TqyR/N2JYHTBy+c/4qb0Ha mwHW8XJsj9X+KGPOFQcW2pzp8fqUMhdJ0KUinQMnQGM5YpcDy33xN9qEI2E+wpETrH/s fZINfufEOnGyBydHciwnOqIfEKps4TEe7b+49aq1ADCZC0jfMPd/f57KxzNxGe0CjQ8Y DYrA== X-Gm-Message-State: AElRT7GC415L8To2E4bjRdCQoDsWMH6hmOxj2P83zM0Tn4wio3UR5jtN dZhmoQoevgMer6BrWS/ucsU= X-Received: by 2002:a17:902:5328:: with SMTP id b37-v6mr1008722pli.371.1521619843277; Wed, 21 Mar 2018 01:10:43 -0700 (PDT) Received: from localhost.localdomain ([38.106.11.25]) by smtp.gmail.com with ESMTPSA id w10sm5950775pgr.57.2018.03.21.01.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Mar 2018 01:10:42 -0700 (PDT) From: Jia He To: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Thomas Gleixner , Ingo Molnar , "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 , x86@kernel.org, Greg Kroah-Hartman , Kate Stewart , Philippe Ombredanne , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Jia He , Jia He Subject: [PATCH 2/4] mm/memblock: introduce memblock_search_pfn_regions() Date: Wed, 21 Mar 2018 01:09:54 -0700 Message-Id: <1521619796-3846-3-git-send-email-hejianet@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521619796-3846-1-git-send-email-hejianet@gmail.com> References: <1521619796-3846-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 the preparation for further optimizing early_pfn_valid Signed-off-by: Jia He --- include/linux/memblock.h | 2 ++ mm/memblock.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 9471db4..5f46956 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); + unsigned long memblock_next_valid_pfn(unsigned long pfn, int *last_idx); /** * for_each_free_mem_range - iterate through free memblock areas diff --git a/mm/memblock.c b/mm/memblock.c index a9e8da4..f50fe5b 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1659,6 +1659,18 @@ 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)); + + if (mid == -1) + return -1; + + return mid; +} + bool __init memblock_is_reserved(phys_addr_t addr) { return memblock_search(&memblock.reserved, addr) != -1; -- 2.7.4