Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp122501imm; Thu, 27 Sep 2018 17:23:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV63uwsXM1Y9JeUSJLUmgW4/nxT9/fl4yYINWDlekqABWLSuCXLcuGHeQS0UdB1Nl+5mkLK3K X-Received: by 2002:a17:902:6e01:: with SMTP id u1-v6mr13693316plk.13.1538094200141; Thu, 27 Sep 2018 17:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538094200; cv=none; d=google.com; s=arc-20160816; b=c7pjgTmvaQ88rzCG1JYOmpptylCDjybS9Sta2qICvHPZGBfzk2piKU8/CW6c+xh2xM 1eWzUHHOCuUCiWsnt636FV/hYrv8wuzQh06jcmraMldc2hiMc/IcTmBAaS5RTdAxnhfN XKmwfkMwAOXoJLW8w+iDGif/HM/Vuoz67kt0tTnEM92o7DUuGKhxe9DRXNaMUGtZ9uJV QqZO77xzmbOOjUSSj7zwPLqSopmuaUYu2sgMwvkOQ9jc0+OjiVp1LJaF5r4RlcqIPvuD uu1LVefmb/IJ5D6CWWo7fSwL4MuH8zNsevpP/JvCTAw5JVXwH1cbwNzwLOoHfzRel4Z9 g99Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from; bh=Z2gOc01/7M6vZ1gatb3a+ItaVVYAV2wg5eRBIoO5JEM=; b=sswBttJvfOF7rE+VzGiYdfpRpIQ04SpStjQN4RKi0UhNzuIAvMe/MpGOHuUpdx6foL epmICRQ0/mZNXmL6e1Dsn70840gIowTySRGAAHD+wQcv1OuMcq+2wwaduaANWdsNSx8g sJdimPK9oZuc5snBo5ZGDcwxCeL2GkKDdYoFobFRTwKvYaiCPAWsUuOQRfREp1lUdF1s IuHXyMFSDbSSxTzMZhHTZZQUBVzNvvC6UbpuCDZT2dopj6n3Tn0gKTPaHJJag92ecSb7 MlavW9y6HsGnwuU2vlPnOz4nDYmYyxhyq/AApzf5yN7xL9+n0c8FvvjXGZZJhy/z68MA UNdg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i189-v6si3407797pfg.281.2018.09.27.17.23.04; Thu, 27 Sep 2018 17:23:20 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728375AbeI1GnP convert rfc822-to-8bit (ORCPT + 99 others); Fri, 28 Sep 2018 02:43:15 -0400 Received: from tyo162.gate.nec.co.jp ([114.179.232.162]:53321 "EHLO tyo162.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbeI1GnP (ORCPT ); Fri, 28 Sep 2018 02:43:15 -0400 Received: from mailgate02.nec.co.jp ([114.179.233.122]) by tyo162.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id w8S0M8kE027119 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Sep 2018 09:22:08 +0900 Received: from mailsv01.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate02.nec.co.jp (8.15.1/8.15.1) with ESMTP id w8S0M87b002523; Fri, 28 Sep 2018 09:22:08 +0900 Received: from mail01b.kamome.nec.co.jp (mail01b.kamome.nec.co.jp [10.25.43.2]) by mailsv01.nec.co.jp (8.15.1/8.15.1) with ESMTP id w8S0M8ea007255; Fri, 28 Sep 2018 09:22:08 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.149] [10.38.151.149]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-4045469; Fri, 28 Sep 2018 09:19:46 +0900 Received: from BPXM23GP.gisp.nec.co.jp ([10.38.151.215]) by BPXC21GP.gisp.nec.co.jp ([10.38.151.149]) with mapi id 14.03.0319.002; Fri, 28 Sep 2018 09:19:45 +0900 From: Naoya Horiguchi To: Masayoshi Mizuma CC: "linux-mm@kvack.org" , Pavel Tatashin , Michal Hocko , "linux-kernel@vger.kernel.org" , "x86@kernel.org" Subject: Re: [PATCH v2 3/3] mm: return zero_resv_unavail optimization Thread-Topic: [PATCH v2 3/3] mm: return zero_resv_unavail optimization Thread-Index: AQHUVOV2twFtLyKByUeUtjALly2L9aUEQT4A Date: Fri, 28 Sep 2018 00:19:44 +0000 Message-ID: <20180928001944.GA9242@hori1.linux.bs1.fc.nec.co.jp> References: <20180925153532.6206-1-msys.mizuma@gmail.com> <20180925153532.6206-4-msys.mizuma@gmail.com> In-Reply-To: <20180925153532.6206-4-msys.mizuma@gmail.com> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.51.8.80] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: <3A91CF9D70C2E0439334BF262801CB9F@gisp.nec.co.jp> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 25, 2018 at 11:35:32AM -0400, Masayoshi Mizuma wrote: > From: Pavel Tatashin > > When checking for valid pfns in zero_resv_unavail(), it is not necessary to > verify that pfns within pageblock_nr_pages ranges are valid, only the first > one needs to be checked. This is because memory for pages are allocated in > contiguous chunks that contain pageblock_nr_pages struct pages. > > Signed-off-by: Pavel Tatashin > Reviewed-off-by: Masayoshi Mizuma According to convention, review tag is formatted like "Reviewed-by: ...", Otherwise, looks good to me. Acked-by: Naoya Horiguchi > --- > mm/page_alloc.c | 46 ++++++++++++++++++++++++++-------------------- > 1 file changed, 26 insertions(+), 20 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3b9d89e..bd5b7e4 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6440,6 +6440,29 @@ void __init free_area_init_node(int nid, unsigned long *zones_size, > } > > #if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP) > + > +/* > + * Zero all valid struct pages in range [spfn, epfn), return number of struct > + * pages zeroed > + */ > +static u64 zero_pfn_range(unsigned long spfn, unsigned long epfn) > +{ > + unsigned long pfn; > + u64 pgcnt = 0; > + > + for (pfn = spfn; pfn < epfn; pfn++) { > + if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) { > + pfn = ALIGN_DOWN(pfn, pageblock_nr_pages) > + + pageblock_nr_pages - 1; > + continue; > + } > + mm_zero_struct_page(pfn_to_page(pfn)); > + pgcnt++; > + } > + > + return pgcnt; > +} > + > /* > * Only struct pages that are backed by physical memory are zeroed and > * initialized by going through __init_single_page(). But, there are some > @@ -6455,7 +6478,6 @@ void __init free_area_init_node(int nid, unsigned long *zones_size, > void __init zero_resv_unavail(void) > { > phys_addr_t start, end; > - unsigned long pfn; > u64 i, pgcnt; > phys_addr_t next = 0; > > @@ -6465,34 +6487,18 @@ void __init zero_resv_unavail(void) > pgcnt = 0; > for_each_mem_range(i, &memblock.memory, NULL, > NUMA_NO_NODE, MEMBLOCK_NONE, &start, &end, NULL) { > - if (next < start) { > - for (pfn = PFN_DOWN(next); pfn < PFN_UP(start); pfn++) { > - if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) > - continue; > - mm_zero_struct_page(pfn_to_page(pfn)); > - pgcnt++; > - } > - } > + if (next < start) > + pgcnt += zero_pfn_range(PFN_DOWN(next), PFN_UP(start)); > next = end; > } > - for (pfn = PFN_DOWN(next); pfn < max_pfn; pfn++) { > - if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) > - continue; > - mm_zero_struct_page(pfn_to_page(pfn)); > - pgcnt++; > - } > - > + pgcnt += zero_pfn_range(PFN_DOWN(next), max_pfn); > > /* > * Struct pages that do not have backing memory. This could be because > * firmware is using some of this memory, or for some other reasons. > - * Once memblock is changed so such behaviour is not allowed: i.e. > - * list of "reserved" memory must be a subset of list of "memory", then > - * this code can be removed. > */ > if (pgcnt) > pr_info("Zeroed struct page in unavailable ranges: %lld pages", pgcnt); > - > } > #endif /* CONFIG_HAVE_MEMBLOCK && !CONFIG_FLAT_NODE_MEM_MAP */ > > -- > 2.18.0 > >