From patchwork Mon May 21 10:15:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 10414573 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 4B5BC60365 for ; Mon, 21 May 2018 10:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CA3D28763 for ; Mon, 21 May 2018 10:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30B3828782; Mon, 21 May 2018 10:16:15 +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 BC4EA28763 for ; Mon, 21 May 2018 10:16:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC3726B0007; Mon, 21 May 2018 06:16:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B4A036B0008; Mon, 21 May 2018 06:16:13 -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 9E9CA6B000A; Mon, 21 May 2018 06:16:13 -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 727576B0007 for ; Mon, 21 May 2018 06:16:13 -0400 (EDT) Received: by mail-qt0-f197.google.com with SMTP id x30-v6so14459837qtm.20 for ; Mon, 21 May 2018 03:16:13 -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=CL1IOb5B0+U1kGHujSuJwgp4KS92EvFzE8HuW1QzKJI=; b=Lc3ahn96mrf2IzA4dGXz4gmZHLm9wqlgJrRB20x87bcY29YQfiYNMt+ex+ko9XcwQL 6rSSv1ghFFEv6go1rOj6OEDl+XfJVl7qyl2HlMboOD0OqQ261I5P+SwNoRgr2UU3Qvrv isTS652Uc27C79LR3pCR/uocBl/C2Es1BC9emR4Enpi7yKllvuzDEHuXpDqPIHF1Q0E4 KoGc5kCgBplO454Q9+gtNqQIJa3UqB1+rW1yxkxjhLVmLGfMKwBoWquXOywqp87z2TW5 9Dnoq0EtKYePOubUnBfcNEVG0tVpnGzprHyhTT3AsJZ5zuWFWc2CmBe3USyQIjDjTLd1 b4mw== 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: ALKqPwfp/QBZTbEpXo8qwRef3+BIYpfclKG2f/R6/W2SglrATBMXqor8 gb7iQSQaj3AAe6g2kcYhgPAIf8GPI68u8a5E8u2O55SR/hsTvVV0qKmnV9QBFlDQqei51lOfIIc hPxYz7DsbaopJBAaqf6wvKJHI5VbTa6uvRFF5p6g55mZ+FLczjIzL6N1lsT9AjSJXVw== X-Received: by 2002:ac8:7259:: with SMTP id l25-v6mr17637480qtp.325.1526897773262; Mon, 21 May 2018 03:16:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrkLruZ1TfjhrshS5j0NvrjLUb8GNjlRK2sg5GnpEOO4qWG//torFNh2sl/Bl9H4MSfjR0t X-Received: by 2002:ac8:7259:: with SMTP id l25-v6mr17637460qtp.325.1526897772750; Mon, 21 May 2018 03:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526897772; cv=none; d=google.com; s=arc-20160816; b=Jm1r4htGR0GjwjfHVtOoxWfxPlQ8XaQdHGuPuHgsdEveRIwGr0l7YbkVuOXD2u1ELP mXO8QUq5eLuWnnb4XhvVOxXd1Rp3ANp0CvCwux9FcxCLJP5dkK1QBBA5/OZ8SOpbZQFH kI/iMvKGJhIS3SgkkYo06vfqMhsNFzxWxJOgmJxdN0Fn5npWx5UMyLeEOZu5hp8lNH7g DphUOGQeGgGXpUttxFV6QB3xXLvGAgIJmITLIp9SMPeNg5qbci9+ZOMuCZy4lggZHzDZ 2f4o4B9L4Bj9xBVUpJdnZa5a1qAlES9TxrqXMVG3Gzq4gJUFDDByNFW7nZETnBvbCBZi g3Pw== 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=CL1IOb5B0+U1kGHujSuJwgp4KS92EvFzE8HuW1QzKJI=; b=ohi82IuSD+I5v99DE6U4x5IYpyXOlhH+UawGxnCoMJVVN3leXYQw3LXq+op50uKpa+ 4dwqK2RcbflnO5LST6RR+jzrIze3L0sG+Q3N4Yn3EY7Npx7oPMzQR6GXtQZpGKe2pQPV 00RbbdVshoiKqJBr29EjhBX7D+dwxBr2cnPhszApkoftnXmE5dHTzG187mMl1h0BtEFe 3bMYbChgFahq2H0E1Iick2jfv411yxQEEta80aBL+6ocqeGlwIhof3+ys9tRIBJx7US6 m1DepS2rTWBLM820d2Q/foHLD/wu+QP2j9UekZYotXNFY8JTo6VYvvihy2Fk4NvM8/RD kEdA== 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 m126-v6si699170qkd.147.2018.05.21.03.16.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 03:16:12 -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-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C56E401EF02; Mon, 21 May 2018 10:16:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE77E2026DEF; Mon, 21 May 2018 10:16:08 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, pagupta@redhat.com Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, Baoquan He Subject: [PATCH v4 2/4] mm/sparsemem: Defer the ms->section_mem_map clearing Date: Mon, 21 May 2018 18:15:53 +0800 Message-Id: <20180521101555.25610-3-bhe@redhat.com> In-Reply-To: <20180521101555.25610-1-bhe@redhat.com> References: <20180521101555.25610-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 21 May 2018 10:16:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 21 May 2018 10:16:12 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Acked-By: Dave Hansen --- mm/sparse-vmemmap.c | 1 - mm/sparse.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index bd0276d5f66b..640e68f8324b 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -303,7 +303,6 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, 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 48cf7b7982e2..3d697292be08 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -453,7 +453,6 @@ void __init sparse_mem_maps_populate_node(struct page **map_map, 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 */ @@ -481,7 +480,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 @@ -585,17 +583,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);