From patchwork Thu Jun 28 06:28:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10493145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 86AF7603EE for ; Thu, 28 Jun 2018 06:29:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7565A29D95 for ; Thu, 28 Jun 2018 06:29:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6946C29DA1; Thu, 28 Jun 2018 06:29:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECAAB29D95 for ; Thu, 28 Jun 2018 06:29:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 039FC6B0269; Thu, 28 Jun 2018 02:29:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F044F6B026A; Thu, 28 Jun 2018 02:29:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCE406B026B; Thu, 28 Jun 2018 02:29:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by kanga.kvack.org (Postfix) with ESMTP id B271B6B0269 for ; Thu, 28 Jun 2018 02:29:16 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id o68-v6so4490188qte.0 for ; Wed, 27 Jun 2018 23:29:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=s3qYdbBFFPUkPCaFrn2o3p95rkvXHlOCNxtSJ20sFYs=; b=GCPgmztdr8fC879M4o/NqI8T3JHd70ihwBaCAnmE2seo5Mxzv6aR5cw2UiFQFyJOmu oi7tp/h3XzS4LRB2SHQ8x7anQ6rqDWzLB+lImO5H6fU9hnD2SQ3RaLyTyzWV9w1RhDEO egBImnb1B5c02jWbzLZhV+WpwShl5obHo6i+foaxeTeDquSE9A40OZ0vuefVsx+m1y1b XfaCaJJTvHZvsZ7Bfs7d5+x1Mt8o26VZLK9r9GqEI/HY+XdZPhzQdXe/gX0jCpmGd+yV aSHI/+WuMTWB/kV1Pwski43hVuINIRse9bt3PcHg7k9rCsT2e2MAqDqiwMISOQhChhRN 9Vqg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APt69E0NoB3MOzPo82lamoAgKrtDhhnuw5C4X0PIMIPWArWsx/iTE1I8 dQKzxTBRS9xb/1lcGnmS+FYjQoMN7TU+9GaMF5lvTKAHFoVWRE92MFsLdtzyzgrhRYjzKGyV2zL iUpAXSHfetkkSIMrh8eRiZIwmqaIWcRbSC3NjJZKQiDxnwnOThzfAMJHQLHCG7LgNsQ== X-Received: by 2002:a0c:becb:: with SMTP id f11-v6mr1159550qvj.217.1530167356519; Wed, 27 Jun 2018 23:29:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcF6EwB1qjekuAuOZy1da2rBjrIUIhvjdtUyK+AUTf1PpbHYwucE7YgmgWAYz8BqAXFSvSv X-Received: by 2002:a0c:becb:: with SMTP id f11-v6mr1159526qvj.217.1530167355790; Wed, 27 Jun 2018 23:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530167355; cv=none; d=google.com; s=arc-20160816; b=sSD9SinMIweb5+ZSWXRo8Lxg3h8eSuO3Kg/O4QePYLlvA89A137EgKkRwmZo8TBcjV W6Br6+kC9JS60J3WYZfahkO0JCLsFjkfmN3NsmYkmEV6d60mlGCsTzek7wys1KJLPuC0 HOoviBv+HgCvFoNiIptRkjwmzO2GgQDtrp6XXW2Op6tzS7wDMI86NsNrE2MqSFm7NfI+ y+ESkTxY9tpawwTbJzRhzaAjCZsfmaIpBCY9BDYgWoqfGngNhAJIuLj1XU0JUjFWwVrB xAadAPk6+6b2Xr6Q0bA4LedWZKcjGfmqrO9GwxhPAOIYGvUYrcT+njDcUGF7iKfB1/sP uI7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=s3qYdbBFFPUkPCaFrn2o3p95rkvXHlOCNxtSJ20sFYs=; b=CZdNp8FW2N/YH7/kfZM61k8EzEuUsXAXTN6NV59vl/SbG0wzMWUthKl67vfb+5j3mF SyoFLLyWQ34fRNq68jFQUKylg6589S1uuWkTJQ1vn35hCE40CtZ75P5SwelFTrU/5w9P Ju//nCzZOvIbvdCeNfAZLjW6w51GUjtg8VH8aVlpZS8Z6/FDxwzSqytAkXA5SB7sPcL5 4kDHqON/26Oxl7jVRa5J87t8e+pt4JxoP28K/CNsDGhFV0+NommbYAl0ZhVsp4zbJoPE iqOGQ6FnzfhnfsQ0ItetyWyftlq/kG1w64xTvM/rOeOnIy84dpQGMQyjDNYYkdW8kfQy 3O9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id c141-v6si5818337qka.343.2018.06.27.23.29.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 23:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of bhe@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of bhe@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E898401DE6D; Thu, 28 Jun 2018 06:29:15 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A80D2156880; Thu, 28 Jun 2018 06:29:10 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, pagupta@redhat.com, Pavel Tatashin , Oscar Salvador Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, Baoquan He Subject: [PATCH v6 2/5] mm/sparsemem: Defer the ms->section_mem_map clearing Date: Thu, 28 Jun 2018 14:28:54 +0800 Message-Id: <20180628062857.29658-3-bhe@redhat.com> In-Reply-To: <20180628062857.29658-1-bhe@redhat.com> References: <20180628062857.29658-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 28 Jun 2018 06:29:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 28 Jun 2018 06:29:15 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In sparse_init(), if CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER=y, system will allocate one continuous memory chunk for mem maps on one node and populate the relevant page tables to map memory section one by one. If fail to populate for a certain mem section, print warning and its ->section_mem_map will be cleared to cancel the marking of being present. Like this, the number of mem sections marked as present could become less during sparse_init() execution. Here just defer the ms->section_mem_map clearing if failed to populate its page tables until the last for_each_present_section_nr() loop. This is in preparation for later optimizing the mem map allocation. Signed-off-by: Baoquan He Reviewed-by: Pavel Tatashin Reviewed-by: Oscar Salvador --- mm/sparse-vmemmap.c | 4 ---- mm/sparse.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index bd0276d5f66b..68bb65b2d34d 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -292,18 +292,14 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, } for (pnum = pnum_begin; pnum < pnum_end; pnum++) { - struct mem_section *ms; - if (!present_section_nr(pnum)) continue; map_map[pnum] = sparse_mem_map_populate(pnum, nodeid, NULL); if (map_map[pnum]) continue; - ms = __nr_to_section(pnum); pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); - ms->section_mem_map = 0; } if (vmemmap_buf_start) { diff --git a/mm/sparse.c b/mm/sparse.c index 6314303130b0..6a706093307d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -441,17 +441,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, /* fallback */ for (pnum = pnum_begin; pnum < pnum_end; pnum++) { - struct mem_section *ms; - if (!present_section_nr(pnum)) continue; map_map[pnum] = sparse_mem_map_populate(pnum, nodeid, NULL); if (map_map[pnum]) continue; - ms = __nr_to_section(pnum); pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); - ms->section_mem_map = 0; } } #endif /* !CONFIG_SPARSEMEM_VMEMMAP */ @@ -479,7 +475,6 @@ static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum) pr_err("%s: sparsemem memory map backing failed some memory will not be available\n", __func__); - ms->section_mem_map = 0; return NULL; } #endif @@ -583,17 +578,23 @@ void __init sparse_init(void) #endif for_each_present_section_nr(0, pnum) { + struct mem_section *ms; + ms = __nr_to_section(pnum); usemap = usemap_map[pnum]; - if (!usemap) + if (!usemap) { + ms->section_mem_map = 0; continue; + } #ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER map = map_map[pnum]; #else map = sparse_early_mem_map_alloc(pnum); #endif - if (!map) + if (!map) { + ms->section_mem_map = 0; continue; + } sparse_init_one_section(__nr_to_section(pnum), pnum, map, usemap);