From patchwork Tue Sep 25 15:35:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 10614305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56F3A15E8 for ; Tue, 25 Sep 2018 15:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41B6A2975C for ; Tue, 25 Sep 2018 15:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3555A29A78; Tue, 25 Sep 2018 15:35:59 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 BBB402975C for ; Tue, 25 Sep 2018 15:35:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D4248E00A6; Tue, 25 Sep 2018 11:35:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7839A8E00A4; Tue, 25 Sep 2018 11:35:57 -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 64C888E00A6; Tue, 25 Sep 2018 11:35:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 3C1BF8E00A4 for ; Tue, 25 Sep 2018 11:35:57 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id a102-v6so72333qka.0 for ; Tue, 25 Sep 2018 08:35: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:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=xP66oGEF+u9f7BSpkmxqbqRaFwS1WpxA5GQ7jYe350c=; b=nJbMxZg/7OPy7p1SN0Ts71JpEahGVGjpruGCOHzJ/XRB/fhdnQsqvGJ+4fNe7fzhO8 1xujleWSKfTfmwsXIXpHl69FFIRfZ5ROltob1HMfD5ZLK0uFphzz6WdtglhbDh2/NSRr TJJRC5DyPJjjTbKwLqmgFLAlnUNlPXVr17VSTgUkxqY+ltQNWP2Eo9sg3JiFpf5qYylp gazjxeXUTe+82nCCbD3eNSgTxKOCsjF78ElzJZBDT7KckGT6Hx6nJtCTw4pGKUOg76ue MGQkswi5tYmFLlUMatVQOv61z7lnpJUiClRXqXv4Vcewn6Q7GexcMVPYQYCIGWbPYReZ KDjw== X-Gm-Message-State: ABuFfoje/GJ8aXlRI9Dh1jIhTu4GAtvncnYSIiS9rxzyM6SBFiXdQOdI Cedfw9JHTlL8PxNOv7AbP49smpUYxSfmKKMJKCM/qL/2GLzaUfYBuhfQa1sxA3Zc042xX52tCrY PyJ3hcGlwJsgUdFk/zqyl8Q3NmKLMO328Og5G2SBo1ZlxzT8DK85chqbPCtZvERLVTWl5XC0SQf Lb/iIHRfIq76T2AwWm86Dort7QpyUmcyptf4OGTAPZhoi7uju5JhcsFHAE7tDuSOTSwOEF6UbaT n04VtpOkAT9BFpCgGwlN9JFzR26XxCwblUaO4R902+QzhOEtCyJP7kMKAgytc4Bf6tUzQTuo4mA GoAITFZmPz7dkx2eqrX7skd0cRgSBGp/pgpBqi2GVZXcnOgPnohpN3TnMgTvEzbSCS3YjBrc5eZ V X-Received: by 2002:a0c:80a8:: with SMTP id 37-v6mr1190179qvb.13.1537889757004; Tue, 25 Sep 2018 08:35:57 -0700 (PDT) X-Received: by 2002:a0c:80a8:: with SMTP id 37-v6mr1190131qvb.13.1537889756372; Tue, 25 Sep 2018 08:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889756; cv=none; d=google.com; s=arc-20160816; b=rfldVh2Rl/RxwR889lsVrvqVlak5n+7haitT3TthI9uS9aI2ZTQ5XoZ87Rz51p7LS1 lbE7n9j7Nh4TJmsvlDGlVCVdQHAewbwm+Kq3c/7iNzWPWItIQdGDIM7NreQE/6aOZUam QWz3uEV1U5vjPF3tEFXGBllJ/nn2oi1Kv+nM+IvPD35Dj4aBhfMkMxzd1FNMhIadSkMj ZSltzTw6rCQoZxPnuDrazKrrWrgqrmAbBm7sVv1b3DEgX2BSBOog+AssvETXxqH7rjHS LQxH+ZFP/e0ue3oYnruD9ej6dhgZCUV7W1AiWgi+UFv8u2OtQXeub8hOmVw88KAPa+si Z3Cw== 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 :dkim-signature; bh=xP66oGEF+u9f7BSpkmxqbqRaFwS1WpxA5GQ7jYe350c=; b=dZHecHu/YzsHouN8DVazDsyeX+mIpbS8rkkgO8pr33eVy0b+o/d39WTBc7+E4evLof VJYcwCJ+FPRdxpWbUypIxJZlP2VysJQHQRx3MXp6HOqBZvIXog3IJYNu+2HXMbmlZvBg oLnbixKtA9JkKl4mP1Ua5eKjHoY99xCT9ScTUMGdXNn59LEqXCwQ8NFSwbSWBELY5zDg 9V5jgFqImJXf5kS5LVGAA9JkngSTXS5pHJgQDcNmk1hzaZFpHTPzEVb/DdrupSAnDGAI 3HaS9TDAT6E+Wnz5SQnyjrdIW98E2HCEkf6klbmh7v0uKPhPjh3RboHY2LNm7BBZcM5B wBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oI6y2THg; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o22-v6sor838070qka.169.2018.09.25.08.35.56 for (Google Transport Security); Tue, 25 Sep 2018 08:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oI6y2THg; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xP66oGEF+u9f7BSpkmxqbqRaFwS1WpxA5GQ7jYe350c=; b=oI6y2THgwRwZfWatTuq71tZoL7JPsb0d8wRg3VmKIJs0PweEHxN6UwDgsQf69CM5mo 7clALQKSkomrbGRH/nvJU2xRh18/oawDo7AREjUzMbnEeUni5Hbbl9f+frpg0wl2evRK J54s4z+Me5J5+heT3vrgk896QPUrAjfkPd4gyXYs+WHRs3T+1Swfu7bgCD5jQaYSWdKh RU1i7+pT5+xUJ1HyY5+dLCH8KnWLoUHDYW115dPvFL++dSOToBA766v4G2zFJOS1Xx23 HNPm/yWVg/u6yZR6V7mkcF9nVfdGMwvH2w+tcVssQjB5WtHlj2levmbUcmDTmkqua9w+ oMpw== X-Google-Smtp-Source: ACcGV613+FJa5N5QpL6W+29rW2RnjjcNDuzMIfgK5NizIuOoNOllYEqXe5fzI0wTWJFc5SR24gE8mA== X-Received: by 2002:a37:cf04:: with SMTP id e4-v6mr1115171qkj.241.1537889755274; Tue, 25 Sep 2018 08:35:55 -0700 (PDT) Received: from gabell.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id p18-v6sm2056304qtp.3.2018.09.25.08.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 08:35:54 -0700 (PDT) From: Masayoshi Mizuma To: linux-mm@kvack.org, Naoya Horiguchi , Pavel Tatashin , Michal Hocko Cc: Masayoshi Mizuma , Masayoshi Mizuma , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 1/3] Revert "x86/e820: put !E820_TYPE_RAM regions into memblock.reserved" Date: Tue, 25 Sep 2018 11:35:30 -0400 Message-Id: <20180925153532.6206-2-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925153532.6206-1-msys.mizuma@gmail.com> References: <20180925153532.6206-1-msys.mizuma@gmail.com> 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 From: Masayoshi Mizuma commit 124049decbb1 ("x86/e820: put !E820_TYPE_RAM regions into memblock.reserved") breaks movable_node kernel option because it changed the memory gap range to reserved memblock. So, the node is marked as Normal zone even if the SRAT has Hot plaggable affinity. ===================================================================== kernel: BIOS-e820: [mem 0x0000180000000000-0x0000180fffffffff] usable kernel: BIOS-e820: [mem 0x00001c0000000000-0x00001c0fffffffff] usable ... kernel: reserved[0x12]#011[0x0000181000000000-0x00001bffffffffff], 0x000003f000000000 bytes flags: 0x0 ... kernel: ACPI: SRAT: Node 2 PXM 6 [mem 0x180000000000-0x1bffffffffff] hotplug kernel: ACPI: SRAT: Node 3 PXM 7 [mem 0x1c0000000000-0x1fffffffffff] hotplug ... kernel: Movable zone start for each node kernel: Node 3: 0x00001c0000000000 kernel: Early memory node ranges ... ===================================================================== Naoya's v1 patch [*] fixes the original issue and this movable_node issue doesn't occur. Let's revert commit 124049decbb1 ("x86/e820: put !E820_TYPE_RAM regions into memblock.reserved") and apply the v1 patch. [*] https://lkml.org/lkml/2018/6/13/27 Signed-off-by: Masayoshi Mizuma Reviewed-by: Pavel Tatashin --- arch/x86/kernel/e820.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index c88c23c..d1f25c8 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1248,7 +1248,6 @@ void __init e820__memblock_setup(void) { int i; u64 end; - u64 addr = 0; /* * The bootstrap memblock region count maximum is 128 entries @@ -1265,21 +1264,13 @@ void __init e820__memblock_setup(void) struct e820_entry *entry = &e820_table->entries[i]; end = entry->addr + entry->size; - if (addr < entry->addr) - memblock_reserve(addr, entry->addr - addr); - addr = end; if (end != (resource_size_t)end) continue; - /* - * all !E820_TYPE_RAM ranges (including gap ranges) are put - * into memblock.reserved to make sure that struct pages in - * such regions are not left uninitialized after bootup. - */ if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) - memblock_reserve(entry->addr, entry->size); - else - memblock_add(entry->addr, entry->size); + continue; + + memblock_add(entry->addr, entry->size); } /* Throw away partial pages: */ From patchwork Tue Sep 25 15:35:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 10614307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFD94161F for ; Tue, 25 Sep 2018 15:36:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A64296A0 for ; Tue, 25 Sep 2018 15:36:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B49102975C; Tue, 25 Sep 2018 15:36:02 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 8017B2A648 for ; Tue, 25 Sep 2018 15:36:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 989698E00A7; Tue, 25 Sep 2018 11:35:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8E4328E00A4; Tue, 25 Sep 2018 11:35:59 -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 7D3DD8E00A7; Tue, 25 Sep 2018 11:35:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 46AD58E00A4 for ; Tue, 25 Sep 2018 11:35:59 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id s22-v6so281545qkg.2 for ; Tue, 25 Sep 2018 08:35:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=yMIZaky490zrCi7TzYwl7/YRlXWpbT5ib/m7bZER82s=; b=jBHfovOlVLmWMHfrIN/iQ1mTjcNZmTdAJkYO1OCGI1XjP3uMwHwlwJ1+vBKbPWxYqs M+fKVQdVf8vQ7FphjISDM6j+SMc3aG7hiCB9E6eaWtHLug6rg8a5mSfLRw9q0qqO71mP 024SIVRyiEl6Q7o4wAsYu5x3CRbIfYnVXqR/4TYA4Ud4UIw1SKPaHRtP+6iK2rlisa/X 47H63vKQUl6406tJGhBA889oWMNa+gp6LTjJy51sj6pLo2TO2XRjWnTcbdNov6Lm4jzR dOtZ27CRYMcD1iJQ4NGO2hOADpoK/46n2KPUtwHcdP7KVzl/2AVp+YNzZoDBN3foftLF kGKw== X-Gm-Message-State: ABuFfohmrivn+6ptKsjEetQENGGeBYNURdJBG6KruVflHKNTLmLPxqn/ AGIV8vvIsGxpxsgeC+F0S9QCfyL2ap0vG6Q52p6nXdoJznQKWqHi6gHbUE01ayqXnw34n2AvP4L /PtSo4w6N8+Z6j+/m79TARulYdQLjYPAY6DUNMjUx1f7D03K5hNKiECgPyfNfkJfjv2fqU6WcKv TDss/sNMbo0dFn757MEhGneedJkKMkcE+D3qG+dJ8jnXKVjPHEP3xkmdOUesP2WsTr87FuiVQAk SDy9hur5heBzKItOPDSoZrgh11wMvc/VWqozVFHuEDg1GF2ykklgrX6XoZbCaZak3D6Ku5q75xi TN4gdunuu4ejUieH/+J1iWOu4jC/KPXGm+442cTvJFV4+HtTqwv33qfCsvzIDUBUDEPCGD21Tlm P X-Received: by 2002:aed:3539:: with SMTP id a54-v6mr1193003qte.153.1537889759021; Tue, 25 Sep 2018 08:35:59 -0700 (PDT) X-Received: by 2002:aed:3539:: with SMTP id a54-v6mr1192942qte.153.1537889757987; Tue, 25 Sep 2018 08:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889757; cv=none; d=google.com; s=arc-20160816; b=lOiAGt3hYvb33IHtBrBLX5PDcEhZCIm1AMbQtVzQ5gRzZr7H2fh7tHM0mV9oLdZVyf WUx1L9x8FftHV/uiQuhQR3EwbyQSHdkVsu4082FoWOOZpTYLyIh/MScasunAvk/hgtoZ ZsTfzTZLgEwX1pkUGYlI+KQcBvZogDRyPSApGVcnTAJl+G1Oi2s7nxGv01uKykD99eb1 rgzlXYNYY+xQeDxbqDVlILbWqdlb4X2dQ45A8q/PNaHpTkrkxe3c4SVDvsFf56Qr5m/i vi3c7hrX62w+r0C+rb+XjqGurZ9Ncc3haLM/I9ImrTBPAF4sELU29Ung7MZwQNQURXuq 2IOQ== 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 :dkim-signature; bh=yMIZaky490zrCi7TzYwl7/YRlXWpbT5ib/m7bZER82s=; b=JZoO0GxmYUZuDe98W2SvIXPgujhOhqvVu2BD8xrphkJkQZoluk4cC+m8j0iyF/r6fY Ul61YWRoBuJMKApr1IsosGdFFNmTH6ODLi20y1FoQqxVbUqBpRo6yIzw9nah+No9ZIUz DOKayjbgkK7Gp3H9LDR1e4BpM9s5H0Q+lH8JcI9JxPM0DKicV3tAo8SnYUvg7VerplSH mpeglkM45fV6OfOie4NNZoa54yL54h6Bn9hLBY9gdho5d3WssQWRvr3NyIPDy5bx8HGu paatFR+8Z5kKfJhLTBfs7UPU0oMZus4VFxCSakBI8f5Qejq72uRTqltqMO1RGZwnj0gM WfLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T1rUMeZL; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v6-v6sor369016qkg.99.2018.09.25.08.35.57 for (Google Transport Security); Tue, 25 Sep 2018 08:35:57 -0700 (PDT) Received-SPF: pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T1rUMeZL; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yMIZaky490zrCi7TzYwl7/YRlXWpbT5ib/m7bZER82s=; b=T1rUMeZLierRq8NkZ2UO3x8ONyv40fCqB33dyVeaJkwnbFIHs4H4Fe7l0QvhOPPSRq lBDSK5pDm63Hta7ykXbeBYJsGKgeT5sOHrHLtAWeCSN+DlMhM6/qHK6cJVCTewHOpDLE utMhgV6UDfWE/DvNKCKxoalCArtDYsA2BlCqHNJaiC5GWJ1V897ll7VLB3aUx8RRgN+R 0yG+r/LuLmpLpBxvv+PDB1KicnMF6YOkCWs+k4DMsMsihcTgIXh15pb7l5TAeIge8Eiu 93UwHipgw9fRY4C8ixAxbrEPvY8Fspy+9+spQlr1+bNdQhBb4Gw2bzCukTXUeG0lUomI hT8A== X-Google-Smtp-Source: ACcGV62xSPi51p6DshgcyABVlpng/UOpf6lFrUshDW3+7IUh1jur5lijdpUepGszp08Aj+1mUI1XMA== X-Received: by 2002:a37:3086:: with SMTP id w128-v6mr1105728qkw.315.1537889757270; Tue, 25 Sep 2018 08:35:57 -0700 (PDT) Received: from gabell.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id p18-v6sm2056304qtp.3.2018.09.25.08.35.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 08:35:55 -0700 (PDT) From: Masayoshi Mizuma To: linux-mm@kvack.org, Naoya Horiguchi , Pavel Tatashin , Michal Hocko Cc: Masayoshi Mizuma , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 2/3] mm: zero remaining unavailable struct pages Date: Tue, 25 Sep 2018 11:35:31 -0400 Message-Id: <20180925153532.6206-3-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925153532.6206-1-msys.mizuma@gmail.com> References: <20180925153532.6206-1-msys.mizuma@gmail.com> 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 From: Naoya Horiguchi There is a kernel panic that is triggered when reading /proc/kpageflags on the kernel booted with kernel parameter 'memmap=nn[KMG]!ss[KMG]': BUG: unable to handle kernel paging request at fffffffffffffffe PGD 9b20e067 P4D 9b20e067 PUD 9b210067 PMD 0 Oops: 0000 [#1] SMP PTI CPU: 2 PID: 1728 Comm: page-types Not tainted 4.17.0-rc6-mm1-v4.17-rc6-180605-0816-00236-g2dfb086ef02c+ #160 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.fc28 04/01/2014 RIP: 0010:stable_page_flags+0x27/0x3c0 Code: 00 00 00 0f 1f 44 00 00 48 85 ff 0f 84 a0 03 00 00 41 54 55 49 89 fc 53 48 8b 57 08 48 8b 2f 48 8d 42 ff 83 e2 01 48 0f 44 c7 <48> 8b 00 f6 c4 01 0f 84 10 03 00 00 31 db 49 8b 54 24 08 4c 89 e7 RSP: 0018:ffffbbd44111fde0 EFLAGS: 00010202 RAX: fffffffffffffffe RBX: 00007fffffffeff9 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000202 RDI: ffffed1182fff5c0 RBP: ffffffffffffffff R08: 0000000000000001 R09: 0000000000000001 R10: ffffbbd44111fed8 R11: 0000000000000000 R12: ffffed1182fff5c0 R13: 00000000000bffd7 R14: 0000000002fff5c0 R15: ffffbbd44111ff10 FS: 00007efc4335a500(0000) GS:ffff93a5bfc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: fffffffffffffffe CR3: 00000000b2a58000 CR4: 00000000001406e0 Call Trace: kpageflags_read+0xc7/0x120 proc_reg_read+0x3c/0x60 __vfs_read+0x36/0x170 vfs_read+0x89/0x130 ksys_pread64+0x71/0x90 do_syscall_64+0x5b/0x160 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7efc42e75e23 Code: 09 00 ba 9f 01 00 00 e8 ab 81 f4 ff 66 2e 0f 1f 84 00 00 00 00 00 90 83 3d 29 0a 2d 00 00 75 13 49 89 ca b8 11 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 34 c3 48 83 ec 08 e8 db d3 01 00 48 89 04 24 According to kernel bisection, this problem became visible due to commit f7f99100d8d9 which changes how struct pages are initialized. Memblock layout affects the pfn ranges covered by node/zone. Consider that we have a VM with 2 NUMA nodes and each node has 4GB memory, and the default (no memmap= given) memblock layout is like below: MEMBLOCK configuration: memory size = 0x00000001fff75c00 reserved size = 0x000000000300c000 memory.cnt = 0x4 memory[0x0] [0x0000000000001000-0x000000000009efff], 0x000000000009e000 bytes on node 0 flags: 0x0 memory[0x1] [0x0000000000100000-0x00000000bffd6fff], 0x00000000bfed7000 bytes on node 0 flags: 0x0 memory[0x2] [0x0000000100000000-0x000000013fffffff], 0x0000000040000000 bytes on node 0 flags: 0x0 memory[0x3] [0x0000000140000000-0x000000023fffffff], 0x0000000100000000 bytes on node 1 flags: 0x0 ... If you give memmap=1G!4G (so it just covers memory[0x2]), the range [0x100000000-0x13fffffff] is gone: MEMBLOCK configuration: memory size = 0x00000001bff75c00 reserved size = 0x000000000300c000 memory.cnt = 0x3 memory[0x0] [0x0000000000001000-0x000000000009efff], 0x000000000009e000 bytes on node 0 flags: 0x0 memory[0x1] [0x0000000000100000-0x00000000bffd6fff], 0x00000000bfed7000 bytes on node 0 flags: 0x0 memory[0x2] [0x0000000140000000-0x000000023fffffff], 0x0000000100000000 bytes on node 1 flags: 0x0 ... This causes shrinking node 0's pfn range because it is calculated by the address range of memblock.memory. So some of struct pages in the gap range are left uninitialized. We have a function zero_resv_unavail() which does zeroing the struct pages outside memblock.memory, but currently it covers only the reserved unavailable range (i.e. memblock.memory && !memblock.reserved). This patch extends it to cover all unavailable range, which fixes the reported issue. Fixes: f7f99100d8d9 ("mm: stop zeroing memory during allocation in vmemmap") Signed-off-by: Naoya Horiguchi Tested-by: Oscar Salvador Tested-by: Masayoshi Mizuma --- include/linux/memblock.h | 15 --------------- mm/page_alloc.c | 36 +++++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 5169205..2acdd04 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -265,21 +265,6 @@ void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \ nid, flags, p_start, p_end, p_nid) -/** - * for_each_resv_unavail_range - iterate through reserved and unavailable memory - * @i: u64 used as loop variable - * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL - * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL - * - * Walks over unavailable but reserved (reserved && !memory) areas of memblock. - * Available as soon as memblock is initialized. - * Note: because this memory does not belong to any physical node, flags and - * nid arguments do not make sense and thus not exported as arguments. - */ -#define for_each_resv_unavail_range(i, p_start, p_end) \ - for_each_mem_range(i, &memblock.reserved, &memblock.memory, \ - NUMA_NO_NODE, MEMBLOCK_NONE, p_start, p_end, NULL) - static inline void memblock_set_region_flags(struct memblock_region *r, enum memblock_flags flags) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 89d2a2a..3b9d89e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6446,29 +6446,42 @@ void __init free_area_init_node(int nid, unsigned long *zones_size, * struct pages which are reserved in memblock allocator and their fields * may be accessed (for example page_to_pfn() on some configuration accesses * flags). We must explicitly zero those struct pages. + * + * This function also addresses a similar issue where struct pages are left + * uninitialized because the physical address range is not covered by + * memblock.memory or memblock.reserved. That could happen when memblock + * layout is manually configured via memmap=. */ void __init zero_resv_unavail(void) { phys_addr_t start, end; unsigned long pfn; u64 i, pgcnt; + phys_addr_t next = 0; /* - * Loop through ranges that are reserved, but do not have reported - * physical memory backing. + * Loop through unavailable ranges not covered by memblock.memory. */ pgcnt = 0; - for_each_resv_unavail_range(i, &start, &end) { - for (pfn = PFN_DOWN(start); pfn < PFN_UP(end); pfn++) { - if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) { - pfn = ALIGN_DOWN(pfn, pageblock_nr_pages) - + pageblock_nr_pages - 1; - continue; + 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++; } - mm_zero_struct_page(pfn_to_page(pfn)); - pgcnt++; } + 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++; + } + /* * Struct pages that do not have backing memory. This could be because @@ -6478,7 +6491,8 @@ void __init zero_resv_unavail(void) * this code can be removed. */ if (pgcnt) - pr_info("Reserved but unavailable: %lld pages", pgcnt); + pr_info("Zeroed struct page in unavailable ranges: %lld pages", pgcnt); + } #endif /* CONFIG_HAVE_MEMBLOCK && !CONFIG_FLAT_NODE_MEM_MAP */ From patchwork Tue Sep 25 15:35:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masayoshi Mizuma X-Patchwork-Id: 10614309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03ACD161F for ; Tue, 25 Sep 2018 15:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A0B296A0 for ; Tue, 25 Sep 2018 15:36:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC985299FC; Tue, 25 Sep 2018 15:36:04 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 6817D296A0 for ; Tue, 25 Sep 2018 15:36:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 012478E00A9; Tue, 25 Sep 2018 11:36:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id ED79F8E00A4; Tue, 25 Sep 2018 11:36:00 -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 D79FE8E00A9; Tue, 25 Sep 2018 11:36:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id A884C8E00A4 for ; Tue, 25 Sep 2018 11:36:00 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id y130-v6so26749228qka.1 for ; Tue, 25 Sep 2018 08:36:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=XGK6fptIFX5w28HkvYDbujSCehR2SgbbRAuYHW9cCO4=; b=jruXTjxVjApvEdBRmZxJaOKk8ns3G+deFJBJ/CrfbKUSDKd9qDXgsJNTKQW/RtOIK2 MOtDGJDhvfl1q+M2kffPUPRPDP3vQVA8a/guXT+hurJhVD8oGFqbHEoRXs8SBxaD1+ih AjLRqkHDZpEEDaweaWimpduUaBJ6rRTNFLXDyxvddbIFoxC0j2th95OgLJIw1bnPRouf UukoyZFXRSmljaLu3tXtEaeV144PioVPtSai3fEU2Dz/PsIcZ7vq6uvbYpHkrLj0X6xF k4Mnd650n6aU9ZYEta1oegig+XN5JIm5OVEmYzdmHugz6sjIQ/dUvkC7DvO75yo4X8MJ J8uw== X-Gm-Message-State: ABuFfohduSaNx2OL9lZ948pnwF0HmsAdjbR9vRtM5QPtu6beqmZFFfxt WAsZHiiaARlwG9pm3iNJkD8Np70g5C9cQex0fUMHmt7qsEQQlFpaM0Vss2txCjt/c//u6MRgJej 2qxfcLighJlCs8I4b0XMAAGitB44/Q1bsl9VTt8JpiOR9U9Ei7bxGjP1MjlMpx6OD2rRCSAEQbO vncRSWfD9qqNtA1YW0JJ8kYWVhvqe522vHGei9SnQGsrOwHaoDuv5YWH6WygCUoMOvyYNASeEVx 9MZNDd+Q6cR1KYCNs6D61z6FeeC4n2OvuzkJqr/33ZyNJPaxjCcREQA57qdd/ZkXfhldJgzdkKV eDcs2aEFjflyy/Q5hxdBHlCspt5k5nqq+62n6rAauu9Yx1wjdt6sv0xRBtwV7954301eUfSA0mH y X-Received: by 2002:a37:1511:: with SMTP id f17-v6mr1132751qkh.245.1537889760407; Tue, 25 Sep 2018 08:36:00 -0700 (PDT) X-Received: by 2002:a37:1511:: with SMTP id f17-v6mr1132722qkh.245.1537889759729; Tue, 25 Sep 2018 08:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889759; cv=none; d=google.com; s=arc-20160816; b=ocnNTC4wnOXkK3tCMEoSeHjbHUuTq09nWLywj3XmiXiIkJ9TjV7HxgYNBVE2QCI1Zp 98O56Y7GCHrNSNhUmY1kWQPGB/O4TEGKugLxzmWhMyomqdlV10LbsX/Zq5iCes4AAjyJ gqD36ZWeOA16Xe6BBQzmSm1BealG9WcC6P7xbOTs2+7jpxoEYSPEcl5JYaRq4Dg0AqCw 6kLd7+7/dFGAYeePzdKYViXUcMfHpOX1X9qL351/l1r+jn4VBSRYNtFw7n1fdb/JDzjz FbiFwdHyr8WmJ5WWL0qIUuFW+zsCXIuxDcoJZRpZJHTh0PBkIcWsEh3ctmcvt7V3PUFM 2PNA== 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 :dkim-signature; bh=XGK6fptIFX5w28HkvYDbujSCehR2SgbbRAuYHW9cCO4=; b=hwJO8J/VBxzDofgumXK/yTz6OWqiYuor/cWrUZRmxMBYLyRTDnT/rXIRW6JCH6mgBc oYc69TDMnNboID3kML4GQOMfPK4XdaRkg9sOpxK/YCfeKEKT+ftCKHmQsamgYML5NzS7 0h2X6jz0AmBdrTMyGKDbLDqyN1Mnaw0vEz14EKgaGRDxoV2Plu/XlWxcculPw+2QHcUA /65YHSMaj5wyAyg/CKo2BQV2vqoXN1BOMXfrKuyNVLy/wMv8OrOooKWe2cqUonsX+ud4 luTNk91Cp/X8GXcpCNzlXk93F4EfcT3FoefHOX7KT/8WfF5UpO+wzETORZREOepc/XQj zPGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AsDhtFGy; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h130-v6sor839145qke.82.2018.09.25.08.35.59 for (Google Transport Security); Tue, 25 Sep 2018 08:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AsDhtFGy; spf=pass (google.com: domain of msys.mizuma@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=msys.mizuma@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XGK6fptIFX5w28HkvYDbujSCehR2SgbbRAuYHW9cCO4=; b=AsDhtFGybEYiZ7vlChRYgfPLS8p4zxURidmslHjc1MTf+dAYgVGYv0RMWduAY6K2Sf +TQFfkeddhKAUVNgkV02vu1oHFgCXLxx83Z9FOIYUYhhK3lixQ2YxwEzrEgWIjBTLXLh eD6ECF5iEFio1QB+CUiVzEu12sDxphi+h3m/IXxFDKYd4KlRq+LQ17Sa9ooP2fIQ9V3M WhDCXc3NFd2wijpqp52sLhoaWauQ41XqWsj8Cf+YhJy0cTkfDMZtvbtc/Ir2+nK75NLh qNXWL41+nTMtmvNE0G7R5CopT5hmhsU0B2cvmuGlzd32kbDmP98s313EH7zytJCBEDES 0chA== X-Google-Smtp-Source: ACcGV62FU9dOFkB9rBQomIyHek5dpMz2ir1A4bcVo/+X23elJCJHE/m0gUQNxP46/v3HBzZXYpPaAA== X-Received: by 2002:a37:1a59:: with SMTP id a86-v6mr1137670qka.191.1537889759160; Tue, 25 Sep 2018 08:35:59 -0700 (PDT) Received: from gabell.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id p18-v6sm2056304qtp.3.2018.09.25.08.35.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 08:35:58 -0700 (PDT) From: Masayoshi Mizuma To: linux-mm@kvack.org, Naoya Horiguchi , Pavel Tatashin , Michal Hocko Cc: Masayoshi Mizuma , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 3/3] mm: return zero_resv_unavail optimization Date: Tue, 25 Sep 2018 11:35:32 -0400 Message-Id: <20180925153532.6206-4-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180925153532.6206-1-msys.mizuma@gmail.com> References: <20180925153532.6206-1-msys.mizuma@gmail.com> 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 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 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 */