From patchwork Wed Apr 13 14:47:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12812095 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 A93A3C433F5 for ; Wed, 13 Apr 2022 14:48:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4143C6B0073; Wed, 13 Apr 2022 10:48:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39DD96B0074; Wed, 13 Apr 2022 10:48:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 217436B0075; Wed, 13 Apr 2022 10:48:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 135856B0073 for ; Wed, 13 Apr 2022 10:48:32 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CD5308249980 for ; Wed, 13 Apr 2022 14:48:31 +0000 (UTC) X-FDA: 79352136822.23.BCC6AEC Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf22.hostedemail.com (Postfix) with ESMTP id A6D17C000A for ; Wed, 13 Apr 2022 14:48:30 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id d15so2148499pll.10 for ; Wed, 13 Apr 2022 07:48:30 -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=D/LdJAtOUO57Ha4IsgdkfD8oFYqd/Z71aYJmqNULy+Q=; b=tDtubE/ZwH48VZrJoDlBbZ3+P3KQGydQEJdFXKPOZgToajCjO+pn4TZojzE43ltN6s Ce0D9N8Rb0wPcLdJLIq4w1n1syJkOLwRvAU3gTbLNCPHkd1fJyQZAFej1vcVXzqThQpI cQIWi0FWFWFUZRDlVFfCbHKV3RH0O+yGzMPZBmljFsVoO+TjZ1PnjMgq3Rf5eDxhW1wC Cv/Iim/J0Zj2Jbe4/3jTDCqt7pzLtHzbrKeJ6gR7d2ef75OOCujFGYKxgn69xvFOzWxp /v4yVUV762iD/MKcDOAOvrbzG+6iNxTTiuzIl5J9zzVfR2G2gQV1tqhQRpLRCuqLh2Dq Q15A== 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=D/LdJAtOUO57Ha4IsgdkfD8oFYqd/Z71aYJmqNULy+Q=; b=6A8hJxPoPVsvCgHxbzPJKAL/1LGuPLRFUkps7K9C5ypwo2F27H369k/Ot3mkQ9yd0+ 82UyJc9Px2pyHw4PXiUiE1EgXW5cQ0wZisBG7+pKsLI32Tu/EML0fhpMBervjyrtR9LD W12bVbAh+2HZn/JAxv4KTipQyBQELPpnKpQBklwB1oHMqAqsW6u+kWH/yOWcid0uGqQH 5ngVD7BYZeBjtkiJUbgKKeBZXxqQbc6P7u3Iy/zpBRRk+1S5psayysWrvWVfDcVCbuQV tU8/owykBnoEtp2dUQArBIoEkUfrF+loLoeUvc0JSau1LOMsI6mC/Sj+RaQxUvfF29Od 5EoQ== X-Gm-Message-State: AOAM531yQv7nYQUAgzgpKIp1XkUbNhBHQdA1x61Vc8XRrfKdEiJoOtyg FfgxZkIfW03pxYJgNgMa+bAbtg== X-Google-Smtp-Source: ABdhPJz2EPmb6m43FkHiFxBEpO7vn7u8K8m686phmKJ6SIsaXxoigMHrk2FsX/UcUEV3dgNYt4fFKg== X-Received: by 2002:a17:902:d4c3:b0:158:a79e:9bf with SMTP id o3-20020a170902d4c300b00158a79e09bfmr2237005plg.40.1649861309243; Wed, 13 Apr 2022 07:48:29 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id p27-20020a056a000a1b00b004f3f63e3cf2sm47817257pfh.58.2022.04.13.07.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 07:48:28 -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 v8 0/4] add hugetlb_optimize_vmemmap sysctl Date: Wed, 13 Apr 2022 22:47:44 +0800 Message-Id: <20220413144748.84106-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-Stat-Signature: o1o8n38xnszhs3qq18a19kno8pdwhrgc Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="tDtubE/Z"; spf=pass (imf22.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A6D17C000A X-HE-Tag: 1649861310-759629 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. 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: 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