From patchwork Fri Apr 29 12:18:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12831930 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 00B0DC433F5 for ; Fri, 29 Apr 2022 12:18:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 593226B0071; Fri, 29 Apr 2022 08:18:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 542A36B0073; Fri, 29 Apr 2022 08:18:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 396086B0074; Fri, 29 Apr 2022 08:18:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 271C96B0071 for ; Fri, 29 Apr 2022 08:18:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id EAB9E604DF for ; Fri, 29 Apr 2022 12:18:35 +0000 (UTC) X-FDA: 79409819832.29.FECEB43 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf05.hostedemail.com (Postfix) with ESMTP id BC45310002C for ; Fri, 29 Apr 2022 12:18:25 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id p6so6981232pjm.1 for ; Fri, 29 Apr 2022 05:18:33 -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=3RkULuqhhhX3uuLQ5CElh2Ii/L2usT9wtqwuaXqStls=; b=6dgC+bHSAeFJrC8KYg2z7/2H3/R6h6zeIP2/TJM/lbA1VYy7SbJIMRyIrieRowIaQv kJ1SOEdSzpZW5RWIfKHc50pJY+MknWf6wyZ9mBDTSwdQHraDZEU1pDlp0hOXMDHzylgF ifJ3CIfECLSdzzd+Hs1I8D9emPRAiSTJWuOdPodBLLugKQxYi5DQ2J5LWb0UXB3GKT35 VjwlylSkcqgoLK/lJASS0z3jk/BKMsGyUtgguRSoE/UUVpx+Q6mT8cdv95iEao6gZnq5 eaE7vV4dtDupThy77SS0zIM29gLGBKU0oYc7ymGlICVJ/7p6SROAx9I4jN05YRtw2b5Q sVgA== 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=3RkULuqhhhX3uuLQ5CElh2Ii/L2usT9wtqwuaXqStls=; b=YLDAS+gjKu8yf8YJL/7v4hywH8aLvKa/8bnyQryjyXiN/1fibAXRd5NhzGEUOJmnKk jDxDtPhBlD04C9vviBg9+rPWpGuJNWi2kHkZAUq10vEDVrY434AkUnDSXez/moicDb/B fqIDmgcuNOhhvWJFrm0iAdjTnGziFBAOLhT/B2TKvoif1Qn2wJ4/FjOGT/krSvgOD9D9 9R/3lucg9Vx1dw43TR0SdaFZ7NiLfMKxK9E90anrx9nkQxuKVZvgA+rkw8jYABX+yqv8 o3/S/Q3svuQ7sKusFaLyTgcMaoRCO8V1EDWZUXpA/86QXDf/kYQRty14lqsexytizAEo BG5w== X-Gm-Message-State: AOAM533j5JhwVaySPvd9pbiOsB8WQuKUuJNUfcl0sYcpGeYHliLr4u9X HQenAInThYY1ufTQDm7heKUJ9g== X-Google-Smtp-Source: ABdhPJxtE+CaijPiIC9LAoGrQDqYJS3f51fjNp6Dgr2elQX0PSrsGMqnZLLhoG9YQBepjs7VbKUriQ== X-Received: by 2002:a17:902:7d83:b0:158:c7e9:1ff3 with SMTP id a3-20020a1709027d8300b00158c7e91ff3mr38794664plm.55.1651234713265; Fri, 29 Apr 2022 05:18:33 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id k11-20020a056a00168b00b004f7e1555538sm3101421pfc.190.2022.04.29.05.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 05:18:32 -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 v9 0/4] add hugetlb_optimize_vmemmap sysctl Date: Fri, 29 Apr 2022 20:18:12 +0800 Message-Id: <20220429121816.37541-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BC45310002C X-Stat-Signature: z1n16cgwbjm8qro7ocasabrcnbc3iup9 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=6dgC+bHS; spf=pass (imf05.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1651234705-88095 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. 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 | 30 +++++++ include/linux/memory_hotplug.h | 9 ++ mm/hugetlb_vmemmap.c | 104 ++++++++++++++++++++---- mm/hugetlb_vmemmap.h | 4 +- mm/memory_hotplug.c | 27 ++++-- 6 files changed, 155 insertions(+), 25 deletions(-)