Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2025404imm; Tue, 10 Jul 2018 11:50:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpevIHRFzpXPC5JW3nH7wFRPvBNihg+ACKaENvJQjFGIqRm9QDz7fW5d7oBlpT33mN+/cIUe X-Received: by 2002:a17:902:6b86:: with SMTP id p6-v6mr25946947plk.75.1531248629083; Tue, 10 Jul 2018 11:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248629; cv=none; d=google.com; s=arc-20160816; b=noCMZVIH/W6MtPkLGUUtlvgkJQv0hNbVw2HAUNiHGazw3X4ARQbv4RJEygLYlDa4YE q+3i6w+zXLhnTUH4J0C43911ddBucjX+JecmBu5Z1MM5ZjyhtVcsSi/g3SNx1ZuEjj6m +YPEA1cxE6VCxNb3Xps6cSUuVWocxhZorb05L2aqdAJmQyleM5ar9npwL/1BygL2zrey lGLErCkQ1Mn77V9HdpUblXjC1MKTsnLK7k3sT5sbI1/pQRZ1+6+YE03a/S+b0YSU8v2f uJik9UAWkzoth55leqZXFTGrQxMNJwHOJgqoM+ix5yyLPIZkiTLnFx1VXLwHQ7kQ/ldW 043A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:message-id:date :mime-version:dkim-signature:arc-authentication-results; bh=bl/ppoRWkR41p8O8LfYbYXELJVdEuPvWgKM8i7oPNoE=; b=KlUh6dmt1KMZ1RAtj/kxV9p4GkDG88pf3HocHH3utoc8qq+p6aM4YZNkAqc800SBud Q5nu+GiMdniGpxXsjkxkV5zn33dzleHB/RiztuKfDHVzJHly+vQNe9RFKeZ/fHwRbP3U szPzCfNAvRTD4j1v9tuzp9Hn6yktf48Ty192Dz/3P9kwbW4Tj/hTJSYGpUaTphWd6bY+ oqO3jtTe9N0fpRnRPK3XTp7QnHKfHh7gb/mhVxQrhVKbrgDk0M1AnFydkjUul6SgaNDY AYXvwaa+Ti+2dME5Fn8KfdpTP0ivHTb9mWYI6xYmVHR7wNq6KM/1v6MmnATyXRjEGCA6 wooA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tpVBwsQR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si16758669pgu.649.2018.07.10.11.50.13; Tue, 10 Jul 2018 11:50:29 -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=@google.com header.s=20161025 header.b=tpVBwsQR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388542AbeGJStm (ORCPT + 99 others); Tue, 10 Jul 2018 14:49:42 -0400 Received: from mail-qk0-f201.google.com ([209.85.220.201]:48872 "EHLO mail-qk0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388505AbeGJStk (ORCPT ); Tue, 10 Jul 2018 14:49:40 -0400 Received: by mail-qk0-f201.google.com with SMTP id 17-v6so5290343qkz.15 for ; Tue, 10 Jul 2018 11:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=bl/ppoRWkR41p8O8LfYbYXELJVdEuPvWgKM8i7oPNoE=; b=tpVBwsQR+DAc3hffLoxUhLMEjQnV7n6+SDi5acXPi8ff8l19Yt9XSJWbNc9Z5td11k y+MBYzkH1Of2tzAF6VYvgg8pm9/4NFZBE/MqLAP7IpCCcyKmOLicb5LcrC4ldPmne8Kx 76DcjQ6824J3GCB1wW1zXWN1sPqKQILUkBU28ibs6ltKA6PTDWloSe2mGG07O8YCPjgO 8BJ/XH6pcfkbUA2JhYaDUfr2ClrlEftuXO+ijO3c7qPaAawX5eQh1YYsb8LjXhp2eCdn sE3zBqJ6elTA7ufPxMhL5RAET/YBqD7rzqd03Ato5AsFYfn0Ei/58bnfpd2i1Nl2Vdep Oe+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=bl/ppoRWkR41p8O8LfYbYXELJVdEuPvWgKM8i7oPNoE=; b=Kz4/svWTNK4J6Qi+uo2Hm3yAPiCy0m2LOXseh0aj9ISuM2jQw2Bz2rGXHYMmSAXOX3 oEsUptmnygjkl/Nr8ZBGKu/T8D3TiS0iGHq5p+E2opXYlruvc+5YFG9jsuJDuBuw1fJM bEMS7uSQSrPAMJf5WN2Q3dnuAH6LvKLP0iLm5+sDhsqjBlA8iuRyctwMQMMgtfQ+6ncx 9+o5ehr7Hontf1pYaan4awe3vP1WgbMzA3e8DJM7k78AW0e8+eRJr8c6MokRY4sst8YR jSlHi2xyR5brC3/ATLMSZmUGf23suJv2td0Q0bUIfwBPel0REG0ISoWKm0a97CRW6vHr aPzg== X-Gm-Message-State: APt69E27rLG21dEAZNQe2g3C800cNj4rK1pFaZwPYx+VRK2S+vEwyng/ uSxIQlC6aqfJPbCvazQkxx0AW7sbP3Fumw9AN0ysaQ== MIME-Version: 1.0 X-Received: by 2002:a0c:f886:: with SMTP id u6-v6mr15386612qvn.48.1531248561617; Tue, 10 Jul 2018 11:49:21 -0700 (PDT) Date: Tue, 10 Jul 2018 11:49:03 -0700 Message-Id: <20180710184903.68239-1-cannonmatthews@google.com> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog Subject: [PATCH] mm: hugetlb: don't zero 1GiB bootmem pages. From: Cannon Matthews To: Andrew Morton , Mike Kravetz , Nadia Yvette Chambers Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, andreslc@google.com, pfeiner@google.com, dmatlack@google.com, gthelen@google.com, Cannon Matthews Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using 1GiB pages during early boot, use the new memblock_virt_alloc_try_nid_raw() function to allocate memory without zeroing it. Zeroing out hundreds or thousands of GiB in a single core memset() call is very slow, and can make early boot last upwards of 20-30 minutes on multi TiB machines. To be safe, still zero the first sizeof(struct boomem_huge_page) bytes since this is used a temporary storage place for this info until gather_bootmem_prealloc() processes them later. The rest of the memory does not need to be zero'd as the hugetlb pages are always zero'd on page fault. Tested: Booted with ~3800 1G pages, and it booted successfully in roughly the same amount of time as with 0, as opposed to the 25+ minutes it would take before. Signed-off-by: Cannon Matthews --- mm/hugetlb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3612fbb32e9d..c93a2c77e881 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2101,7 +2101,7 @@ int __alloc_bootmem_huge_page(struct hstate *h) for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { void *addr; - addr = memblock_virt_alloc_try_nid_nopanic( + addr = memblock_virt_alloc_try_nid_raw( huge_page_size(h), huge_page_size(h), 0, BOOTMEM_ALLOC_ACCESSIBLE, node); if (addr) { @@ -2109,7 +2109,12 @@ int __alloc_bootmem_huge_page(struct hstate *h) * Use the beginning of the huge page to store the * huge_bootmem_page struct (until gather_bootmem * puts them into the mem_map). + * + * memblock_virt_alloc_try_nid_raw returns non-zero'd + * memory so zero out just enough for this struct, the + * rest will be zero'd on page fault. */ + memset(addr, 0, sizeof(struct huge_bootmem_page)); m = addr; goto found; } -- 2.18.0.203.gfac676dfb9-goog