From patchwork Sun Jul 30 15:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13333450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7935C001DF for ; Sun, 30 Jul 2023 15:16:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A05E88E0001; Sun, 30 Jul 2023 11:16:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B4A58D000B; Sun, 30 Jul 2023 11:16:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 807948D000A; Sun, 30 Jul 2023 11:16:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6D4CD8D0001 for ; Sun, 30 Jul 2023 11:16:14 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2FFECA07D2 for ; Sun, 30 Jul 2023 15:16:14 +0000 (UTC) X-FDA: 81068629068.20.40CECCB Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by imf21.hostedemail.com (Postfix) with ESMTP id A02C21C0009 for ; Sun, 30 Jul 2023 15:16:11 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WYTpzSFO; spf=pass (imf21.hostedemail.com: domain of usama.arif@bytedance.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=usama.arif@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690730172; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ouZz2dgRhulfVTdETwQCaMD2VZFH/MAUlpDLBWAqkC4=; b=D037SNoWJU72Y78qEIUexC3W15tG3UftM/WYRaHpcGbQ+87A8kz+w/XVuAScGH7W4f4Ord Fy4NUw5oRgorr2H+QxgGGKLkhEepFroLfWkKlHYxCgpHkEBQg3wARY3+kc/WqOadKK5abA t/5qDyBKPXxShdlWtPUu4TLQ9kbsCsc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WYTpzSFO; spf=pass (imf21.hostedemail.com: domain of usama.arif@bytedance.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=usama.arif@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690730172; a=rsa-sha256; cv=none; b=7vxAOOBbAPcDRBYMAoFGHx2650SvwcQRw0JRu6FCrJ4ogw4Y0NZ+ZtZ2nIFeNqyemuDjrT dDBkbp4xhcOX6jwf/SvQ8RDy0rRLQs9xFO+6cBdibp5M0PPJcDyVW7uGERJTTB7nYiBfwA DJ1BOP0kECB2fVp257V5p5hibKminV0= Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742eso42076495e9.3 for ; Sun, 30 Jul 2023 08:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1690730169; x=1691334969; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ouZz2dgRhulfVTdETwQCaMD2VZFH/MAUlpDLBWAqkC4=; b=WYTpzSFOlYTX+54AiGoo2AA6+qI3YxJezUgecbxkq/6VQ/LX7Ah6udam0ur8G0HjPX RztF/lP1AHUJ2o1PYC0taV8FxRDd1UlwjQfxZQmlUSkseRnHWdytaHx9vLUYLJYfj+aN fuybUXorlBSBwpIdZ4Ycg0xUrjHlBZItHlPKOiPgPzGs5B4NwRWq0TzxEuVhUFIMG6iU TU+gOjw1rI1cZIkIjQCSdZoNtaqWU/Xc3jk5NJJ1sB7ZAhVavj/a3nWEuHgQ+CUaPQ/n 4CwC1tggDxRRF2El08SFrf28EzZfrvE0NAH36Pa/IErGXSHXEjiaHX6TDZddoE5vnKlw JV1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690730169; x=1691334969; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ouZz2dgRhulfVTdETwQCaMD2VZFH/MAUlpDLBWAqkC4=; b=N6W3ZqwXhHRzJPM+ynYPFDs+Gl02EORgxL8HspyVHiSrMcLZ0SQxI4LjVxIbGwu2FC kiiGQjlC6lCNcrVLYtiqF4OkBHBMRbj+NTR7QAQeqqh58MKilwAipQilgqXuo0FZA7lP WudUTowaKQQ0HIugL0vJrkrcrSW4KGjlw8NSv8CHl1KDtsFFyeiH5Ti+/eNfUnjqjcA+ WaBm5gZ7ddgV6igbJDQLSpx5B+d511grUwDtrEzF1uLG0Lfrg+Gz/eTZ6kLkJiIvFiQP HL5in5DNHPlEQAZzygsie140NZiTY7GmuFdW1e3U9v/QrfMLyOdbJYAozfu6dGNFUORh Ljjg== X-Gm-Message-State: ABy/qLa9AAkm5itUEBwQl/eyvh5bJFFLJOVaC8WdrRuI8jAJV6fVx40n yZI8THQKGhDbDrUwMoYehMcJspWNOAX7pq/RDR0= X-Google-Smtp-Source: APBJJlF5dPGoSedZx/k6nvqInFyfA+121sKKm+aczGQUh4mWlfALM9vJLpnAFciGz6wtqb1QaD/A4A== X-Received: by 2002:a7b:cbd6:0:b0:3fb:ef86:e2e with SMTP id n22-20020a7bcbd6000000b003fbef860e2emr6360945wmi.19.1690730169537; Sun, 30 Jul 2023 08:16:09 -0700 (PDT) Received: from localhost.localdomain ([2a02:6b6a:b465:0:eda5:aa63:ce24:dac2]) by smtp.gmail.com with ESMTPSA id f17-20020a7bcc11000000b003fd2d33ea53sm9123027wmh.14.2023.07.30.08.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 08:16:08 -0700 (PDT) From: Usama Arif To: linux-mm@kvack.org, muchun.song@linux.dev, mike.kravetz@oracle.com, rppt@kernel.org Cc: linux-kernel@vger.kernel.org, fam.zheng@bytedance.com, liangma@liangbit.com, simon.evans@bytedance.com, punit.agrawal@bytedance.com, Usama Arif Subject: [v2 0/6] mm/memblock: Skip prep and initialization of struct pages freed later by HVO Date: Sun, 30 Jul 2023 16:16:00 +0100 Message-Id: <20230730151606.2871391-1-usama.arif@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: A02C21C0009 X-Rspam-User: X-Stat-Signature: 834jpowew593wp4kjzycfk4xjs36rb4a X-Rspamd-Server: rspam01 X-HE-Tag: 1690730171-734439 X-HE-Meta: U2FsdGVkX1+1GWhMvHN213lDI6mR8D0Xi7SQR7ajqWBcQV6kc/WbCnT14Hq1ZRrkmPzZ5MkTbgnoMTfitbRjwLpcWfGs4K5FWeAqyW6n677mkRJMydqbduKWm71kSOZpJp0FbqMS/IQaAxAJwN7G7Wn9i7r9Ei5oF0HVIHi1zNC1llK4djUlNnnnVprgvZTgP3/sTxWBQy3orWEM5CPOEqPjtqV0KiY2kiQ2R64xFAkBE0TwGHyk8R/vHOqwkIOTbCD4GM1uw7uGn7J1ruD9G6ZQdn99jPbyoctiVmM+6JxBUKqp8jI+27yaSfJGFZhNfQ+nGrQqBai5AuskeuQvn33giRD51Xt8MW2CAtgmpgeW1WNUJtqHR5vHdYhzTen4Jgup4c+2FhXyWuxKtFjfqffAThGsgn7la791xyrfT4yCPm7cl6q1jfvGUuYVCefKO9bmEYV8QTUbVwkmRV3fkbTcq8XVYthZcDW2F7DuZvpxBjqsX1DT3HUGzD1slFHSZgFwL1FBlfcv5Cgpgt8tE0Oi8nvgEEyETTpruhBgOEfjacAYvpOb0Ppb8mlxInzimG3Zs2zUSwkgxSlp+dZt3Lc2aDf9PwKuy/nenea8H57wkDroLJImbPMXcw+zSLDvpghV83pEPM0GhiuV0Ly9GGLsmmq4ItJWQhXGUclqatFH0npKPLNxGv5Ws6aO3r7ZScQN1K22QGwWMk/3p7aJ56V2UaKoNiafIQrqJTtrGx3gEo/AAstzHYTe26PGTRIzr9ROUyQWRhP6DLQ+3Ozxq+dKjC/Glqrx62t5m9ik71/h7PSik39EPBSw1sQ52QIulFJxQSwrr0USUje0ZhkhIwt26+N2+ZUMscUMXIeTSa19jnS1+kkktDKkoxpxg0NC7GP6rDeAIoCVw52pAnKeUWyjib2oab/T55VSWOt/I9m4abTixyuCyHmmqF7O3uxoam13l5Kh9y7gCpWM4Uy jjA7ZxgE jzQLZZYhPiUQMvJEeqUK+MvXUq81fKnblJrSbzeeFkq6lr2eO4OOCW3cN9Qb6TUqyz3D1rngtZTRG/FvCYnRkGNFOQH+Ic30jxrYq+MtanxliSM+8rnBfYyhYRWR3W/GsujR5QgEemeqVzkDYKdvybiHEn1Lpos2yXan7tlXkD+DamLZP1bnEriKmQzfe9bUFc0ErYA5Z3DnaN/yp7InkpgDvK4ccQSTGy35SJTC1m5kGEGPzT27IEyNimZ6XcbXS3QWWlFTgaOz1l9QFaRoKTxl2kXP4vtRRNmpHTkwOk9p+sRRTxvglOS2wFs7nSvdrvhhcOZABT8RQiLEB48BpOAEvSRmV0UCdxiOSuJeOyFwgc5Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If the region is for gigantic hugepages and if HVO is enabled, then those struct pages which will be freed later by HVO don't need to be prepared and initialized. This can save significant time when a large number of hugepages are allocated at boot time. For a 1G hugepage, this series avoid initialization and preparation of 262144 - 64 = 262080 struct pages per hugepage. When tested on a 512G system (which can allocate max 500 1G hugepages), the kexec-boot time with HVO and DEFERRED_STRUCT_PAGE_INIT enabled without this patchseries to running init is 3.9 seconds. With this patch it is 1.2 seconds. This represents an approximately 70% reduction in boot time and will significantly reduce server downtime when using a large number of gigantic pages. Thanks, Usama [v1->v2]: - (Mike Rapoport) Code quality improvements (function names, arguments, comments). [RFC->v1]: - (Mike Rapoport) Change from passing hugepage_size in memblock_alloc_try_nid_raw for skipping struct page initialization to using MEMBLOCK_RSRV_NOINIT flag Usama Arif (6): mm: hugetlb: Skip prep of tail pages when HVO is enabled mm: hugetlb_vmemmap: Use nid of the head page to reallocate it memblock: pass memblock_type to memblock_setclr_flag memblock: introduce MEMBLOCK_RSRV_NOINIT flag mm: move allocation of gigantic hstates to the start of mm_core_init mm: hugetlb: Skip initialization of struct pages freed later by HVO include/linux/memblock.h | 9 +++++ mm/hugetlb.c | 71 +++++++++++++++++++++++++--------------- mm/hugetlb_vmemmap.c | 6 ++-- mm/hugetlb_vmemmap.h | 18 +++++++--- mm/internal.h | 9 +++++ mm/memblock.c | 45 +++++++++++++++++-------- mm/mm_init.c | 6 ++++ 7 files changed, 118 insertions(+), 46 deletions(-)