From patchwork Tue Apr 12 11:14:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12810520 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 5B057C433F5 for ; Tue, 12 Apr 2022 11:15:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D064E6B0080; Tue, 12 Apr 2022 07:15:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB71B6B0081; Tue, 12 Apr 2022 07:15:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7DA26B0082; Tue, 12 Apr 2022 07:15:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id A84386B0080 for ; Tue, 12 Apr 2022 07:15:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5110C183D71F8 for ; Tue, 12 Apr 2022 11:15:03 +0000 (UTC) X-FDA: 79347970086.26.5C4B871 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf27.hostedemail.com (Postfix) with ESMTP id 2110740007 for ; Tue, 12 Apr 2022 11:15:01 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id h23-20020a17090a051700b001c9c1dd3acbso2588466pjh.3 for ; Tue, 12 Apr 2022 04:15:01 -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=/LHQ0nWmz2r/pD7wgSsiKJq8hFpZAK2dEG+C+pVYguk=; b=RgweYEl2njKBQ/qkD0QsEqFYmun8JoT7QAE9/9a8ypuYGYrQVmiL8WG0sENk1bRlB9 DdpFfhUEl39HPbnsBVsXjIw2BDTBBBRE6jW52nEPelTno7oI4BvsIluMkuuDnVa+rLTc IRDl9RdjBI/bp5RnOopsKDizvkCpGgwrnVJRcXQMBCo9Qy8tF05bIqofh7dTe1WMzO/C aP8eewe6tH4gOiZXlafAG1vJkFZ7GEHXZnSDtvOyH9rUT8+DOtrdEL9VYRK4rU9dnMTA vLOYXWfy422owFKiQuP8ohMxu+lE1GU8qWWkK+3QOwg2UPuxJWhpveIPPimR77YwZmkA pLvQ== 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=/LHQ0nWmz2r/pD7wgSsiKJq8hFpZAK2dEG+C+pVYguk=; b=VOpLQJ0ap8qZ+beiU6cQrsgW7s8sWuYJvXcuhBO3LmFrRFxb2g0AuU1B9R7RMORnwb QouSJqAz/gPw5R9wtmUQmFo/VpobuTbh4OQx2y4lVK4RBi/owfF6jIPpb0ud3OSiQA/g n8+kJDHNfxiDhc4pdefwg0Im4IbP2hKBvl86NwvhHU8/xLTxPwNuQ4EhsxgRSzghiOj5 iiQ02mwFj9AymTw0+DXvfDNTwKvduuMyePdKUo05ecgtLQE49FE4HV7wvU8pQk14atau M9t7F6mxoW9dPHO+vZ+bLKwB0fxWNW6kCnbycHZesE/+62few9k5WySF3bmN0LaCvq9L EFXw== X-Gm-Message-State: AOAM530JH/oXdRVk5n2XFHUQzL6lUqUkCOvd/8q4aSFwzl+lIncx/5Qu cedtH2g+z/mGnHzPktAxN49zvQ== X-Google-Smtp-Source: ABdhPJyxhPc5PVq3oT4Nhp6xmJ9VdjMh9PULiQuZiylRW5MGUuA3lL9aU58g8xg3Wuc8aEJV27QiLA== X-Received: by 2002:a17:90b:3b43:b0:1c6:f878:ea52 with SMTP id ot3-20020a17090b3b4300b001c6f878ea52mr4428201pjb.68.1649762100641; Tue, 12 Apr 2022 04:15:00 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.229]) by smtp.gmail.com with ESMTPSA id l25-20020a635719000000b0039da6cdf82dsm402507pgb.83.2022.04.12.04.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 04:15:00 -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 v7 0/4] add hugetlb_optimize_vmemmap sysctl Date: Tue, 12 Apr 2022 19:14:30 +0800 Message-Id: <20220412111434.96498-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=RgweYEl2; spf=pass (imf27.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 2110740007 X-Stat-Signature: 7zrte4ctapqg3peamguu9m5cjzoz8ff3 X-HE-Tag: 1649762101-39115 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-20220407. This series amis to add hugetlb_optimize_vmemmap sysctl to enable or disable the feature of optimizing vmemmap pages associated with HugeTLB pages. 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: introduce CONFIG_HUGETLB_PAGE_HAS_OPTIMIZE_VMEMMAP 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 | 27 +++++++ Kbuild | 19 +++++ arch/x86/mm/init_64.c | 2 +- include/linux/hugetlb.h | 2 +- include/linux/kconfig.h | 4 + include/linux/memory_hotplug.h | 9 +++ include/linux/mm.h | 2 +- include/linux/page-flags.h | 2 +- kernel/autoconf_ext.c | 26 ++++++ mm/hugetlb_vmemmap.c | 102 ++++++++++++++++++++---- mm/hugetlb_vmemmap.h | 8 +- mm/memory_hotplug.c | 27 +++++-- mm/sparse-vmemmap.c | 4 +- scripts/mod/Makefile | 2 + 15 files changed, 207 insertions(+), 35 deletions(-) create mode 100644 kernel/autoconf_ext.c