From patchwork Mon May 9 06:26:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12843060 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 2C3D1C433FE for ; Mon, 9 May 2022 06:29:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7776D6B0071; Mon, 9 May 2022 02:29:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 726EB6B0073; Mon, 9 May 2022 02:29:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 615D96B0074; Mon, 9 May 2022 02:29:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4EA116B0071 for ; Mon, 9 May 2022 02:29:19 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 08FC62F089 for ; Mon, 9 May 2022 06:29:19 +0000 (UTC) X-FDA: 79445227638.06.24CFB51 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf11.hostedemail.com (Postfix) with ESMTP id 43DE24008C for ; Mon, 9 May 2022 06:29:13 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id fv2so12258182pjb.4 for ; Sun, 08 May 2022 23:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q/ROXewp2cxt4q3Bz4z9TGgbOWGYmpSqNQy/66wnJeM=; b=Nd+Eloii8ZKgFxPbiLDEdOiwu9gNmv7JQhUlmY18jKXPbt8GZYA3VbL+0xQKqnO/rs K51O5M/mOEAHIdWaUS3TzAOe2e3rIHF2xCRpeoVqGQG8x3TyUC7H1Ku50uE2gi4opZMo M7jWGEOulU2tOo6bBHGlDVgFQkHdgx/knt8Xs2cQC0MWU+7HBSFD8XiqDOyGyrChyDib VDuUwsnoJA7BzYQtXPiNkbBN9NCnyJ5JZ1Mb4feFscvUpp3VVJwrSL1Q3obb5OABQZbK 3xtqpOUJpFYYR8AWZMuOoyrnfMzPvTGTLplK1T1ChNkqeyUzEOf6uwKDLO0mABCJtqxZ tV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q/ROXewp2cxt4q3Bz4z9TGgbOWGYmpSqNQy/66wnJeM=; b=7ElT6ZauSp+i/8d65gUOjdGL5bXz30ngQfhBk5YyV+yK+FReinDpu1GeWf5HLd6DRW vEB06dTs+M3aOEuBDUlDykN4HBhuA1VaICTUVQZfk89ny8DVJlaRuTguN2j5u1BjQKYD W7sT4ZqEm9+R49PuLYB6lUQJtehtZr//FCAysem7ai/qnv0Aad9ZAJzx2055C3ofjwkd cJ4NYfL6K01vJRakqLRK5F0blqyugLzCnmJYQv3OCRG6YBLPXDwYNs3xJb8RCsPuTl9N 9JsqlTm7LOLrQzKIb2+/Drx+3rz7zvdMjAASjLp99bsQcaHtxKwCfaS3SXSQ2VqYIQ07 tfYw== X-Gm-Message-State: AOAM532GrG4ref/6Xde5GcT0Mj7mlOezzTqX8HRWkOZ+gqiZoFtJGzuG OAP4oq1kMnyXnaxbp45n/wfSww== X-Google-Smtp-Source: ABdhPJxwZiwU/4zQ7JSumL48lEGxXI7GAVzr7kAz6DKM+6n6aUS++edLr7xdJqjOjuqdGRPiyXaVUw== X-Received: by 2002:a17:90a:cf89:b0:1d7:7055:f49c with SMTP id i9-20020a17090acf8900b001d77055f49cmr17109634pju.12.1652077756422; Sun, 08 May 2022 23:29:16 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.250]) by smtp.gmail.com with ESMTPSA id k17-20020a170902ba9100b0015e8d4eb2c2sm6162001pls.268.2022.05.08.23.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:29:16 -0700 (PDT) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, osalvador@suse.de, david@redhat.com, masahiroy@kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v10 0/4] add hugetlb_optimize_vmemmap sysctl Date: Mon, 9 May 2022 14:26:59 +0800 Message-Id: <20220509062703.64249-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-Rspamd-Queue-Id: 43DE24008C X-Stat-Signature: 9t51yscbga9hboxk4pztep8hktqipwti Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Nd+Eloii; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf11.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1652077753-992120 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: This series is based on next-20220428. This series amis to add hugetlb_optimize_vmemmap sysctl to enable or disable the feature of optimizing vmemmap pages associated with HugeTLB pages. v10: - Collect Reviewed-by from Mike. - Remove hugetlb_optimize_vmemmap_enabled() check from hugetlb_optimize_vmemmap_pages() (Mike). - Add more explanation to Documentation/admin-guide/sysctl/vm.rst. - Fix cannot disable the feature via hugetlb_optimize_vmemmap sysctl (Mike). - Update patch 2's commit log (Mike). v9: - Go back to v3 since checking the size of struct page at config time is very complex. v8: - Fix compilation (scripts/selinux/mdp/mdp.c) error when CONFIG_SECURITY_SELINUX is selected. v7: - Fix circular dependency issue reported by kernel test robot. - Introduce CONFIG_HUGETLB_PAGE_HAS_OPTIMIZE_VMEMMAP instead of STRUCT_PAGE_SIZE_IS_POWER_OF_2. - Add more comments into vm.rst to explain hugetlb_optimize_vmemmap (Andrew). - Drop the patch "sysctl: allow to set extra1 to SYSCTL_ONE". - Add a new patch "use kstrtobool for hugetlb_vmemmap param parsing". - Reuse static_key's refcount to count the number of HugeTLB pages with vmemmap pages optimized to simplify the lock scheme. v6: - Remove "make syncconfig" from Kbuild. v5: - Fix not working properly if one is workig off of a very clean build reported by Luis Chamberlain. - Add Suggested-by for Luis Chamberlain. v4: - Introduce STRUCT_PAGE_SIZE_IS_POWER_OF_2 inspired by Luis. v3: - Add pr_warn_once() (Mike). - Handle the transition from enabling to disabling (Luis) v2: - Fix compilation when !CONFIG_MHP_MEMMAP_ON_MEMORY reported by kernel test robot . - Move sysctl code from kernel/sysctl.c to mm/hugetlb_vmemmap.c. Muchun Song (4): mm: hugetlb_vmemmap: disable hugetlb_optimize_vmemmap when struct page crosses page boundaries mm: memory_hotplug: override memmap_on_memory when hugetlb_free_vmemmap=on mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing mm: hugetlb_vmemmap: add hugetlb_optimize_vmemmap sysctl Documentation/admin-guide/kernel-parameters.txt | 6 +- Documentation/admin-guide/sysctl/vm.rst | 39 +++++++++ include/linux/memory_hotplug.h | 9 ++ mm/hugetlb.c | 3 + mm/hugetlb_vmemmap.c | 105 ++++++++++++++++++++---- mm/memory_hotplug.c | 27 ++++-- 6 files changed, 165 insertions(+), 24 deletions(-)