From patchwork Mon May 16 10:22:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12850545 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 9568BC433FE for ; Mon, 16 May 2022 10:23:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1573E6B0071; Mon, 16 May 2022 06:23:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 107E86B0072; Mon, 16 May 2022 06:23:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F104E6B0073; Mon, 16 May 2022 06:23:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DEB3D6B0071 for ; Mon, 16 May 2022 06:23:04 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A090320D3A for ; Mon, 16 May 2022 10:23:04 +0000 (UTC) X-FDA: 79471218288.18.6F446B0 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf16.hostedemail.com (Postfix) with ESMTP id 3F15A1800DF for ; Mon, 16 May 2022 10:22:53 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id q76so13647471pgq.10 for ; Mon, 16 May 2022 03:23:03 -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=wM6Azq4KvZFXPTLv4RjX04U+2mm1UIR+U1KSQ2B9MTI=; b=8H8QXlCOxjBgjGZh3+z6KHLhzw4I/ccGgMza3sUfGcJ+ykdaqDuU7NJXywJqXBmZvm PPb9ZKan1kfrxhDdsKPryMHGMax0yEKcyFZcEs3baaX23BtrzlOgvT3ijDwn92aNcYVT rIY1UjeWjfnn6WsbW+NJ4GczWjtYtJr5qOjrk12P4s6qHql7WRb0/RrPSoUEw/VTfiNY 1e7zhvlatMu3Kj6s3Q8WciSzxWO4jZjeBuLtzoa/5+/MKSd8/BwwrpTJ5+16BO81hVxX WeK3JkMVs8MK6NyaFCm0yMZkQ8f5Q4hs/2fEqv96Mtp5NUA5hRTOO9IQdg7bW1JxFo+6 tSQA== 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=wM6Azq4KvZFXPTLv4RjX04U+2mm1UIR+U1KSQ2B9MTI=; b=QMOteLpD/wSVzrWy4etlv0kFYZSa6oSBFznJol21X6TRt8vv2JrcTaAD5Adhz3xZye XHjuvuq2snxf+fvy4GSUm2AV0/SySAjK1kveEH9rK3sEEkSxLEhG43dgzfasmkdTH4h8 Qn9zV7g6aCaWaGvlI36lMq2HimlJ+44FsdJCwwhMwvzdh+ZD5SoaOQefU5EIdZ9K+6lz LZTTahqgZxy0mv7lWGgw3MmHcG34i8lycxfyYnWXkKKxsyqSXyMuOToLyx4RJVtPaSeN MuE2xK/crMzQMqopAEG9DGQ9QeExnyBtIdODxgDHfhvLioNH+SHBgcoK7rW4DaJ9wfPG IH/w== X-Gm-Message-State: AOAM531I/o+3aVJ43NpaO15QOsnaYf83r3+5X0STtdNGs59hoFUDxEZd HCnSm397JEOLC3ORtfluW0pqwg== X-Google-Smtp-Source: ABdhPJwA0KYogIQnhHX+aOs8Ju/cjBq8V+xpTctszclbnMr/9fG5BJnPxGY5TbdCQtotKncPsTpNvQ== X-Received: by 2002:a63:89c7:0:b0:3da:ee16:c84 with SMTP id v190-20020a6389c7000000b003daee160c84mr14940129pgd.320.1652696582639; Mon, 16 May 2022 03:23:02 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id i9-20020aa79089000000b0050dc76281e4sm6472731pfa.190.2022.05.16.03.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:23:02 -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 v12 0/7] add hugetlb_optimize_vmemmap sysctl Date: Mon, 16 May 2022 18:22:04 +0800 Message-Id: <20220516102211.41557-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3F15A1800DF X-Stat-Signature: oix9rfc9z8k31mawd8ip44cs64mkpy79 X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=8H8QXlCO; spf=pass (imf16.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1652696573-719307 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. v12: - Add patch 3 and patch 4 to handle the coexistence of hugetlb_free_vmemmap and memory_hotplug.memmap_on_memory (David). - Remove Reviewed-by from Mike in the last parch since it is changed. v11: - Collect Reviewed-by from Mike. - Remove hugetlb_optimize_vmemmap_enabled() check from flush_free_hpage_work(). 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 (7): mm: hugetlb_vmemmap: disable hugetlb_optimize_vmemmap when struct page crosses page boundaries mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing mm: memory_hotplug: enumerate all supported section flags mm: hotplug: introduce SECTION_CANNOT_OPTIMIZE_VMEMMAP mm: hugetlb_vmemmap: remove hugetlb_optimize_vmemmap_enabled() sysctl: handle table->maxlen properly for proc_dobool mm: hugetlb_vmemmap: add hugetlb_optimize_vmemmap sysctl Documentation/admin-guide/kernel-parameters.txt | 22 +++---- Documentation/admin-guide/sysctl/vm.rst | 38 ++++++++++++ arch/arm64/mm/flush.c | 13 +--- fs/lockd/svc.c | 2 +- include/linux/kconfig.h | 1 + include/linux/mmzone.h | 54 +++++++++++++--- include/linux/page-flags.h | 16 +---- kernel/sysctl.c | 22 ++++--- mm/hugetlb_vmemmap.c | 82 ++++++++++++++++++------- mm/memory_hotplug.c | 7 ++- mm/sparse.c | 7 +++ 11 files changed, 186 insertions(+), 78 deletions(-)