From patchwork Tue Jul 10 18:49:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cannon Matthews X-Patchwork-Id: 10517935 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 C17C960551 for ; Tue, 10 Jul 2018 18:49:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B926028FDC for ; Tue, 10 Jul 2018 18:49:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD73E28FEE; Tue, 10 Jul 2018 18:49:25 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 4AD3328FE4 for ; Tue, 10 Jul 2018 18:49:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B14976B0005; Tue, 10 Jul 2018 14:49:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A991B6B0006; Tue, 10 Jul 2018 14:49:23 -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 9619B6B0007; Tue, 10 Jul 2018 14:49:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id 67D456B0005 for ; Tue, 10 Jul 2018 14:49:23 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id b185-v6so28383184qkg.19 for ; Tue, 10 Jul 2018 11:49:23 -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:mime-version:date:message-id :subject:from:to:cc; bh=bl/ppoRWkR41p8O8LfYbYXELJVdEuPvWgKM8i7oPNoE=; b=PZBcgmV9GYI+7Kz/OkkWrd8UCNq48VR5HuWKc1jwTuOADXxjS8RpFFx9/n7XV3IsIL EqjHOCVn1tf8OH6FyVU+FHdPb69+VAcA1dg62Ob/8Y80VDB/ntlR1zTgjopODpeoRkFS lzEHL40wW6zPYjtt49xTBdOsHxCfKhJxGma+fA7S+cXSojuqi/PDY227YerNs/u+gJ9w bWR15XwyDlI8g432Os2MefUibTH4JUVefC9F2CuIBikQlWpdSL55YYHqeqdvxgfQnqnJ 0Cz1N0dTbluY3y2FU485C/FOzPUCgVLMgeen5pAgPIEDiYDL8y9bRACpwH5upMVjrXB/ WOEw== X-Gm-Message-State: APt69E2h10oDUsBMHeoEsy9HXRPh8GAPd3Hv2M9fQZN8Zj3NfpEh6DyN TPFC5Y42C5TNWXkWmIUuu3pFBdWC9WCvSqg+OGbWKgslyIU3ZwPsHnJqlgvN4G34qo9Cx5bcXtz Toas8BrgbZifdQRpeckhubhU7dRsV7i81Z3jSSYUwGyMtpaz9LVngHss894mChtqfjLmluYlz06 loi+FNJtEVkaBewQ+ZdEggZAF3u8LXzT7whLuV8pGycb3Tr7wTqtFUKxSzYbwg8jJP0cyZbtWlx WQ7FzMvrhnvB+YpzqfVVSow9kF6/IZweCBI3eMVnk6UkSsS8zv/VsJFxhoFxHR3urrIoPHa11Z+ T/yszAqOcvm6MivCZVE3xEF1WCFOMUhOm8mjwfP4aALowkCK/m1XtwwV0zFjaOsqIVPN8AObLDd a X-Received: by 2002:a37:289e:: with SMTP id o30-v6mr22438269qko.432.1531248563211; Tue, 10 Jul 2018 11:49:23 -0700 (PDT) X-Received: by 2002:a37:289e:: with SMTP id o30-v6mr22438213qko.432.1531248561996; Tue, 10 Jul 2018 11:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531248561; cv=none; d=google.com; s=arc-20160816; b=0P7z33tJi2NQDrgF3st0osrXO2ml4vvSisKVhCz+3d6bcOy/sSavj3tyMuOLQ4NxTu 2tRBdngRC212ZfLYOLZfrehMbUWhgfMri/mc+Om8u+4KPTNAnJ/S2Gm8vKatkynEmpLM /H6kPipCn9AlgQG4WvyBMPhnbNphHj6Fo5rpdYDdMqyVbwQeO/XOrHQCBui3pDL1zpt1 fkQaFbEiFQepeczLIAFm9B4cuMq2SBJAc8xoeIYXQkQT1c9uApLna+jQIl3911NKK7ZB 899vHfmXDnSBKkMa4SFKVaymkOizDivPuOFX9/PU0rVsPP+4NjXo3DdqtAGQff3EfDdz JATQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:date:mime-version:dkim-signature :arc-authentication-results; bh=bl/ppoRWkR41p8O8LfYbYXELJVdEuPvWgKM8i7oPNoE=; b=IhzdIwK/QI4rCXSXNvWZWBN9k237eXBMIJb89ILbAcBou80hW+ul4QtcJpUGGP44kb Px4Umc1UbwYau70Ve/jXPIjiRqJ/5ScHR1bRarSeDy87m2w8VaP9XIOky9nh4RLayt+J eR+uXN3hh7EEhfBtt1vkTgeW2c8c/lvm1eSoxGS7cQr3DZ8Eabhhix9LwpCYurf6OUsI XiU8Ksvc+7ujqVJY25hpvKU8vzF4ZYHiEvJS9PNLaiAWAG54SQgMzwceLsqQQE6dBqS3 xaLyI08ToNibRysByZS1t6+gIvFDG7toGezOkY9o4Ji+JQTwdaGAmsKZU9FDILfj6+J2 /Jaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tpVBwsQR; spf=pass (google.com: domain of 3sf9eww4kckqgerrsrqexxliawksskpi.gsqpmryb-qqozego.svk@flex--cannonmatthews.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3sf9EWw4KCKQGERRSRQEXXLIaWKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--cannonmatthews.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id u1-v6sor3626963qvh.88.2018.07.10.11.49.21 for (Google Transport Security); Tue, 10 Jul 2018 11:49:21 -0700 (PDT) Received-SPF: pass (google.com: domain of 3sf9eww4kckqgerrsrqexxliawksskpi.gsqpmryb-qqozego.svk@flex--cannonmatthews.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tpVBwsQR; spf=pass (google.com: domain of 3sf9eww4kckqgerrsrqexxliawksskpi.gsqpmryb-qqozego.svk@flex--cannonmatthews.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3sf9EWw4KCKQGERRSRQEXXLIaWKSSKPI.GSQPMRYb-QQOZEGO.SVK@flex--cannonmatthews.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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-Smtp-Source: AAOMgpcEczjEjRhy1tPLM56bFeMNE/GBZkB7iGvTRrJKvpr6ot+oBRpXNE1U2DSRxfUI9jUSuUHOb7CpWBSyzf+pczIwPg== 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 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 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 Acked-by: Michal Hocko Reviewed-by: Mike Kravetz --- mm/hugetlb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.18.0.203.gfac676dfb9-goog 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; }