Received: by 10.213.65.68 with SMTP id h4csp1123333imn; Wed, 21 Mar 2018 03:16:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEJ5UR9WReDT+Lij4ar2NK+Ty4IapMXTZY/fCd0O0h4fQGx9XgWPnPqxg3pSrQFHJgnTw6 X-Received: by 10.99.4.202 with SMTP id 193mr12473728pge.409.1521627391971; Wed, 21 Mar 2018 03:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521627391; cv=none; d=google.com; s=arc-20160816; b=po3mfCeeDtrbXxYB2iOiVo2WzjbiobIXBrVl9ZYYQHp84Dl8ObNDG/KV2icFC0HvFg OCjrY/csV7bmrOkORbJMaWZJR+PbLg/t2t0YtgQrTLl0VUKn/0vERHWEY0jPljTQtHw2 kNyot313X4ii43YA2cZQG/cZfg7Cjelc14d74kGeyuzRaOKHHp1BMB8/zSVtyvkam2nx vLE5fOYMfWvfcXiLtbNyMJcTqRJDSjQGjSQJxk2tV1kQHlduaV4L5sxdLJ+GtzZNQyDj EyNG3E8hn0t7d1hHZUmY4ZDan2W+8NNc4m7CJuKmEykX3Ur71PkiSSezLOEvAWA7QiLX dniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:arc-authentication-results; bh=rb8E7xzu3B/j2jX6M0xYrJe4esTwL9tb4y6BZ9euzhE=; b=jtNmKSQwrjCpSptUJNz2L3xlg6JAHq9fqhCEW7Z+H+TXaZl3s+IQmp9d1qzteC5LGI HAxxJjQnbz6wHo+YYq+RNwiAPEKauuJkqb9AQab/Q2ZRt2ymM9CNnhvubcNgCCUoUIm3 16+STPwrPClicxVcBw/ubgEioo5LcaBsgn8xnhuhuq0yWp+xfgugRcB0TtwoApW1sBEy 8/2kBcKCXwRJtTuajsVjtHZo7d9MTsH5ac+yPaN08ESbHGGpjmpsCNVDZuBHYQqAaVtL WKAJnSb2UWf7ADgVHVfhTohEtteWCLsd+qh9WMSfShi3s0K1lfcyoBc5zLGJUPe4yQt0 Q0qw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26si2841468pfg.303.2018.03.21.03.16.18; Wed, 21 Mar 2018 03:16:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814AbeCUKO7 (ORCPT + 99 others); Wed, 21 Mar 2018 06:14:59 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:41628 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751714AbeCUKO6 (ORCPT ); Wed, 21 Mar 2018 06:14:58 -0400 Received: by mail-ot0-f195.google.com with SMTP id i28-v6so4990828otf.8 for ; Wed, 21 Mar 2018 03:14:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=rb8E7xzu3B/j2jX6M0xYrJe4esTwL9tb4y6BZ9euzhE=; b=CBYocBdxKPjnKn428fHd6TGZheAtyltp89rf66TfkglRBLALyRQNvUsYbNtAVRTauF R6ZrMEfsZugRy3XbLE1ATEH43kMTPMHrD75vCX42w2FuZk+5HpLabSkOziXbIHrmzwB9 +V7Zf0o/Brr3sMSGVlPQQ9N5IJ+97SIgwj9/1zOOR49h581MrNd+cD+FouDc1Je/XWnJ ab0jOKe5QjVnp4MuGQHemyMBMlPA4z4uo9S6AGAWLYRiLPO1Zyx/0Fq39ATmwxg+Ma8t PWcZwMckQn3LPYjZuuxrBsTaxHSJ7TCtJqrAPp4KevA1P5432qXURtpQai6QbD2t/W8V X8Jw== X-Gm-Message-State: AElRT7GJHQKy3RyYRvKvCUtkfn0xLLWjddpkOwcOd1lnYwTqov6o8ugg 7jEMRj/ExWqBmhKMWOYZeQhjYRcYoDBKbMkhDYME4Q== X-Received: by 2002:a9d:252b:: with SMTP id k40-v6mr7449733otb.141.1521627297508; Wed, 21 Mar 2018 03:14:57 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:39f6:0:0:0:0:0 with HTTP; Wed, 21 Mar 2018 03:14:57 -0700 (PDT) In-Reply-To: <1521619796-3846-3-git-send-email-hejianet@gmail.com> References: <1521619796-3846-1-git-send-email-hejianet@gmail.com> <1521619796-3846-3-git-send-email-hejianet@gmail.com> From: Daniel Vacek Date: Wed, 21 Mar 2018 11:14:57 +0100 Message-ID: Subject: Re: [PATCH 2/4] mm/memblock: introduce memblock_search_pfn_regions() To: Jia He Cc: Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , Will Deacon , Mark Rutland , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Pavel Tatashin , Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , Eugeniu Rosca , Vlastimil Babka , open list , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 21, 2018 at 9:09 AM, Jia He wrote: > 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; Why this? > + return mid; > +} > + > bool __init memblock_is_reserved(phys_addr_t addr) > { > return memblock_search(&memblock.reserved, addr) != -1; > -- > 2.7.4 >