From patchwork Wed Jun 27 21:44:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cannon Matthews X-Patchwork-Id: 10492707 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 EA36B60230 for ; Wed, 27 Jun 2018 21:44:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E188D2A350 for ; Wed, 27 Jun 2018 21:44:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1BDF2A35B; Wed, 27 Jun 2018 21:44:57 +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 6E04A2A350 for ; Wed, 27 Jun 2018 21:44:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AE526B000D; Wed, 27 Jun 2018 17:44:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 25EBE6B000E; Wed, 27 Jun 2018 17:44:56 -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 176816B0010; Wed, 27 Jun 2018 17:44:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io0-f199.google.com (mail-io0-f199.google.com [209.85.223.199]) by kanga.kvack.org (Postfix) with ESMTP id E64696B000D for ; Wed, 27 Jun 2018 17:44:55 -0400 (EDT) Received: by mail-io0-f199.google.com with SMTP id t11-v6so2660958iog.15 for ; Wed, 27 Jun 2018 14:44:55 -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=urO4q+tiItkRCEIpbjrzywMw7hfVdQdAHx4bAgIywCI=; b=dCTWio/R/3hkwl+EdAaiHa0mIIkAQoAOAqAEmxjtUI6UK1lSXP5tr41m0WLfuFmtDQ ipR75X+j+bpKqNU8kolhA7l6xNY9jC2qJvnOVQHxIC+af7TIbDDcAau33LSKJcEONI5c ladQbU1a2Q/MkLZKgmroFNwYs5BPcVCHdONQKjw0OX94fs7JnVv4qChlHsRNvDWkYU7C Ic9tU78P8e8GV8u/s4uRI331/AM6imOfcRm4dtrAn06v6roRKfkJqjznmvc+SLJxoJ9/ /4vz5eRD198hn3TWJOam7FhcYYXj3uyusDJFoxG76eGHdUo4mUZQaOetQU3cNY5sYIOu XsIA== X-Gm-Message-State: APt69E0LLf/PXFDaHPLnukD4qTSiXzhYOGvV3rbqYTX7Cn3kJOj8CD1N 9ewFqgMtsS+/KrwccbLpNbtFtDoAVHNxk92JFrQdu4XljdHeW4QsC/NqA02xCmuMv8hTW3WC9Qh bMjNT9JJ+rSjYZiFLf7bXoX+i9/ZtW0oCTuWHrZtmJwuWkkHdzTyiQkygdyBCCFuy609RG1XM51 fy2QEAHidot1D7LJ2IZKWi1KqH+cUF9kcQ9Y7pM3FaiWqDPsicVsb6dHwoISTGHKp9wLrNIWXZ/ xUzTDGaQrI2hlQR7AQyXiegbKJCBE5vIieXK7te5Hk5dmWbnBMCJYRgK4cjJAWP48Y2+rm+nI55 Ylb8H/h3/GI0AA406o8bVX8m81U3hfZv6mvmxeSZUmXePWLWamHSVPPR+TYF9N+Y56oXRMCe9V9 z X-Received: by 2002:a24:69cb:: with SMTP id e194-v6mr6949674itc.102.1530135895718; Wed, 27 Jun 2018 14:44:55 -0700 (PDT) X-Received: by 2002:a24:69cb:: with SMTP id e194-v6mr6949643itc.102.1530135895088; Wed, 27 Jun 2018 14:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530135895; cv=none; d=google.com; s=arc-20160816; b=V5rsAfNdHCgaA1k/eDA8CitDRx86z+4IvtFAxMDmaLdPoyg0Dqs00vW7uRVAVy7CGW 8CjzkTUDoE6QmzHP/1r2X9m1h68l2lI7vvKJqnYDlHSgOFiugnAwFBmYfGx0Y/+d5MVf Sdrp0+vw9ruxr/JTSouY8YpA7c6VV71//sSZo+5oOZPvkvh58jkvUMwo/RC1irrbTqfu PkuwovSc6sV2gwHI11tRYM/v0iThAcE70U0f9idmY4WRigZfOYNeN6OEAIAFNrdQI/Gk hek5XTlkFEv6IHjxsmL9JJOyemEgZkFt5B+gZ+Mef303M2VA820V8TeYeixd0XsLxUD+ OnAw== 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=urO4q+tiItkRCEIpbjrzywMw7hfVdQdAHx4bAgIywCI=; b=pbPb9V+SK/e/v5uPUWMp0OrIfR/cK41TY0dqCzn+6SSYZUzUiozANEUJ5Blv6ONkz9 QBem2mQqIt6/rfNdTbt7JABaMxRCMoohy9EzOE8HTNFMn0wqkTGn7EDT/DdjOiThN4E2 1z9edoReP/5RvdKYiS8MUXr1A5nPGtZoJEpVLW7k1KFCpVjT3x4ljcOJPkwmxbW3SfzE 2pYgVCmczMf97AiPhyAFcqyvNg8JMk+u+TY6yBGUnZhmcuZ7MBOxmW5hoz3l0AC/nm+W p2g9E4n0l7ivlP3kJ0Ng9KnNyTm0Op74+Lky67Zs/il4MzIBRL5eoj2HsEJBZtQOm9Xc Zb8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IypmtCXU; spf=pass (google.com: domain of 3vgu0ww4kcbetr44543raayvd9x55x2v.t532z4be-331crt1.58x@flex--cannonmatthews.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3VgU0Ww4KCBEtr44543rAAyvD9x55x2v.t532z4BE-331Crt1.58x@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 b67-v6sor2090264ita.33.2018.06.27.14.44.54 for (Google Transport Security); Wed, 27 Jun 2018 14:44:55 -0700 (PDT) Received-SPF: pass (google.com: domain of 3vgu0ww4kcbetr44543raayvd9x55x2v.t532z4be-331crt1.58x@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=IypmtCXU; spf=pass (google.com: domain of 3vgu0ww4kcbetr44543raayvd9x55x2v.t532z4be-331crt1.58x@flex--cannonmatthews.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3VgU0Ww4KCBEtr44543rAAyvD9x55x2v.t532z4BE-331Crt1.58x@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=urO4q+tiItkRCEIpbjrzywMw7hfVdQdAHx4bAgIywCI=; b=IypmtCXUgTyUTwhxq3vPhsCw7J4mbo4XNYAExZZ5j871dFf16lpu3bx50u5UqP+hyW ViAPGVokcEbA/hw191bM4cBt5HKEGLiqsyR26AURN1ONJU11cPODD8kFf7EtAyYZcPra 4ZMeyBKY6ZMnpWuwem7cIDG3FpWtZE+QDlTFYZb0kvQJ4ZazlY0unxhP1yysIxHkfLND 0zZw4C2j0vQHjzHxL7AUqqrZIJwexKq/lUXWMjuT+Qb0fIBMVa0QPIiepaLSDW6ObcxG a11vh4ylrfPOKWt+N5lscp0heDlEzga0P2VShXw5ikAMlFKzHRufujqD6JQtWUiqItA1 M1BQ== X-Google-Smtp-Source: ADUXVKJhVx6+2KxG3qCuDdjWOQydkNneiAFdF8I9WGWU57WvXKBnVbntv5xda3oFIl9IWXXNMMGFJj+UnB2UaoEHLWNSVg== MIME-Version: 1.0 X-Received: by 2002:a24:324d:: with SMTP id j74-v6mr3101177ita.26.1530135894703; Wed, 27 Jun 2018 14:44:54 -0700 (PDT) Date: Wed, 27 Jun 2018 14:44:47 -0700 Message-Id: <20180627214447.260804-1-cannonmatthews@google.com> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog Subject: [PATCH] mm: hugetlb: yield when prepping struct 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, gthelen@google.com, Cannon Matthews X-Bogosity: Ham, tests=bogofilter, spamicity=0.001271, 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 booting with very large numbers of gigantic (i.e. 1G) pages, the operations in the loop of gather_bootmem_prealloc, and specifically prep_compound_gigantic_page, takes a very long time, and can cause a softlockup if enough pages are requested at boot. For example booting with 3844 1G pages requires prepping (set_compound_head, init the count) over 1 billion 4K tail pages, which takes considerable time. This should also apply to reserving the same amount of memory as 2M pages, as the same number of struct pages are affected in either case. Add a cond_resched() to the outer loop in gather_bootmem_prealloc() to prevent this lockup. Tested: Booted with softlockup_panic=1 hugepagesz=1G hugepages=3844 and no softlockup is reported, and the hugepages are reported as successfully setup. Signed-off-by: Cannon Matthews Reviewed-by: Mike Kravetz Acked-by: Michal Hocko --- mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a963f2034dfc..d38273c32d3b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2169,6 +2169,7 @@ static void __init gather_bootmem_prealloc(void) */ if (hstate_is_gigantic(h)) adjust_managed_page_count(page, 1 << h->order); + cond_resched(); } }