Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp900806imm; Fri, 28 Sep 2018 08:36:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62oFMLpNYoS34wZDdsZcpwGG6OIb1qb50La1xBo/rwfjmQPPTH7h6rTGHgPmViAwKrAf5T4 X-Received: by 2002:a65:588e:: with SMTP id d14-v6mr10100097pgu.117.1538149004714; Fri, 28 Sep 2018 08:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538149004; cv=none; d=google.com; s=arc-20160816; b=Ly1qjOdH8BxP0yWz5VDtOVH/8RNKKCE0HR7aO/gyn2jxgOoj9lSKaIDpvEeuC68M14 OWFqqQMhJ1NBCcMsYDcMtL4pBpjKCovDSl+x7/4F8Kcx2aPNfty4kYAFpFYVV1aMQb7t /KO38+syeuuNTY9NWpj0Icf7IJxOVCFcgRhs1yh+AqmsIX7ZHdzZ0HArh9DyNnij965t TwMDLWBFNA1aT/vXOtFDF3EkjMldQqr3Nnxha+HoL2xPslRY4JQHb8DnBYdNDAWV6HP0 eXJTBD7ghQoEHH3jksF2qhfTOPmr23qHwoyaAB58XekeEWc6iyoQLLTz4SJh15PqOFrW kMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nKm2YRs2GePh2jvk0yw4Oucb/WjAaxWxxbBWcB29RMU=; b=ITWZfc2mAE4ipc/HnQND8CeAzW4HuURJ3e07KZg4N7erK0C3lP8afE4/CTNihtoIT4 XQM5pj5ebF5hq/QR25+WmXvHs7PtQfDV/HXI7nZRjhUEbCzDDcO5RMu82Lr+gYTmMwrW y7zN3UFRfQHQ/j4/rK9MMCKDMOEK0kfjZF0WS/mfuZFNXRLAnWu0nL2UARkAsSYwv21r GZfeFd67Xcn/57p5xPDcm9hqpUuF/zKwlgfdTNNtp6uZQnn36g15vlR0DsK1G+harHE+ GXDOx3knbRdBYUpeXOmTds4QTOSWf7UlcF9aTh2rAHRMAVHcsAdUELNy69b7i/ZM2ogD NFyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tOkWRa0Z; 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 f130-v6si4594622pgc.625.2018.09.28.08.36.27; Fri, 28 Sep 2018 08:36:44 -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=tOkWRa0Z; 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 S1729344AbeI1WAj (ORCPT + 99 others); Fri, 28 Sep 2018 18:00:39 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44340 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728873AbeI1WAj (ORCPT ); Fri, 28 Sep 2018 18:00:39 -0400 Received: by mail-qt1-f195.google.com with SMTP id c56-v6so2179097qtd.11 for ; Fri, 28 Sep 2018 08:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=nKm2YRs2GePh2jvk0yw4Oucb/WjAaxWxxbBWcB29RMU=; b=tOkWRa0Zd8AySTCMGQqA3W5BBQV+rtbD9+gYtngE4G27h9AVh11Sz1ljrYUOl8RDhc JIyWOO+WxI3wDjeMpRmLQxEuu6tWIRKsmNsEYeeEwOBv9KUtEJtSdWuHmHDJVyeTY1zC KgLgF2om/w7j8i8qVICv7KciIHjp4YDDJKRIC6lSSt6A9gtpHeTll7vLcmyyQpSKk6uZ LE6AeMj4chjK+qSUGk3kehYO/91LS4Q0qZfQmUe3Zwe1FQ6sQmagwcUghSmb1wKnts9i hwE2Hov2zHe4XyN8taTHapxer2ECWy14ZZ1VHRO1JvOOqF+ctYBpbzriHXStzhG5eEC4 +K0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=nKm2YRs2GePh2jvk0yw4Oucb/WjAaxWxxbBWcB29RMU=; b=bdMMXPM6DgPvS9aAfyrQ7cRnfAfvp47RT/5pepgzo9wTvrAeckOwT4tZTn097adadh h6pt0KM3KJyfrav2lqv18nbAI5uWcVtaDs2d9gFEtvrxiLnZ4t9HEqldN8Y6Q3ALFd9C bAfMXf1ZGgi4Q7WSIPJI2yegsWbJE/NINXwABGTC8QXYNjje2KX3OT/k0JHN0zkbpBuM fqKzuibhrDvVkcRS1dkrbs/Nej4iHcxqN9Dh+RGv9JE74R691u5uSv95b620Fcvs+u2n Nc/BrQZJEZVdvUHf4CdpM/Ho8xlTDLw6XdZIQ20vsGgtGVSCCkOmci7IY+RA/lRLsomo Ho0w== X-Gm-Message-State: ABuFfojcVfH6v1zwj3Qx+040MuxhuiYGWMnOw0NvTl+j4GzB/tmMa9SL LTI8yFjQsDKCGbNhxE0ymA== X-Received: by 2002:ac8:414a:: with SMTP id e10-v6mr6478907qtm.330.1538148980943; Fri, 28 Sep 2018 08:36:20 -0700 (PDT) Received: from gabell (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v51-v6sm3113573qtc.65.2018.09.28.08.36.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Sep 2018 08:36:20 -0700 (PDT) Date: Fri, 28 Sep 2018 11:36:18 -0400 From: Masayoshi Mizuma To: Naoya Horiguchi 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 Message-ID: <20180928153618.gdxyb337a4w32vit@gabell> References: <20180925153532.6206-1-msys.mizuma@gmail.com> <20180925153532.6206-4-msys.mizuma@gmail.com> <20180928001944.GA9242@hori1.linux.bs1.fc.nec.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180928001944.GA9242@hori1.linux.bs1.fc.nec.co.jp> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 28, 2018 at 12:19:44AM +0000, Naoya Horiguchi wrote: > 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: ...", Sorry for the typo... > Otherwise, looks good to me. > > Acked-by: Naoya Horiguchi Thanks! - Masa > > > --- > > 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 > > > >