From patchwork Wed Oct 30 12:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13856489 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 3B013D5CCAA for ; Wed, 30 Oct 2024 13:03:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B5BB6B00BF; Wed, 30 Oct 2024 09:03:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16C896B00C4; Wed, 30 Oct 2024 09:03:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC0276B00C1; Wed, 30 Oct 2024 09:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B29BA6B00BF for ; Wed, 30 Oct 2024 09:03:54 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4F720120C2D for ; Wed, 30 Oct 2024 13:03:54 +0000 (UTC) X-FDA: 82730285358.05.6752167 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf12.hostedemail.com (Postfix) with ESMTP id B965140029 for ; Wed, 30 Oct 2024 13:03:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=eUcKZTex; spf=pass (imf12.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730293352; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=x/+J4VNwyIjYndlAztlVz2EFWQN/WXmhUknqKDEMai0=; b=0bT5y+2YVulCNjyPd45gYVXaQ6JCota1OeVBJwmqxRoiL2StT63huqoMLAUQyvWeCLi9Bg GLBIBuoUn/lDJtBUHiysHjhZ1NjTbjEqYjILelJ++y0EKJ53ldKuwNra32YrJ29wtN9beZ QlR7blkOqLTDj8Yc1VCClcQC9l2KC4w= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=eUcKZTex; spf=pass (imf12.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730293352; a=rsa-sha256; cv=none; b=d9VxBMsfE2by+ZA9SfPcXQNhhX2N9pV+mJTZD0GHbGTheK/+PNbUBqz7vD2NX9uYI2VNK1 h9EK1ItIOdCx5WgpU/5szqVO4SfMhyAGiG5rC8LmmsYX+gaMJvG//uuaimFh/PYg5UNo1f LfTASx+KRLHVv+8PyGKcqVyDqzLkpYQ= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x/+J4VNwyIjYndlAztlVz2EFWQN/WXmhUknqKDEMai0=; b=eUcKZTexxC8M2Wcn30sWoZqyrh LRP8JP0FKQ7H6mI4jJPzJasXn5FjP4SI+86Rk4Y2y+LLjP5yX8tNfAF7HOupm4XdtVK6GYJJltnXv Bii1xx1Lszwsm1Sk9XipuwCR7WesaGLsQWxv1K8M4nDfto6PNgH91hdlxpZw/U8TmeR3WkUCaxwxP 9e05jUf7ku16Xrdqq5krv0SN2z2/ktQAPwydgXKS2DaY/XYz88gcC1yI6Ifwo7iXUkvjmfcUr9YgO HGBP1vZXhg4m0Gh89vceRFzZgwj23LY6lgdxkFEmqno/aBR4spbKMiHFHtUzsjB9SyvtY9BTvrmjz d4nXaHRQ==; Received: from [187.36.213.55] (helo=morissey..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t68MI-00H5h8-GV; Wed, 30 Oct 2024 14:03:35 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Jonathan Corbet , Andrew Morton , Hugh Dickins , Barry Song , David Hildenbrand , Ryan Roberts , Baolin Wang , Lance Yang Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= Subject: [PATCH v3 1/4] mm: fix docs for the kernel parameter ``thp_anon=`` Date: Wed, 30 Oct 2024 09:58:55 -0300 Message-ID: <20241030130308.1066299-2-mcanal@igalia.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241030130308.1066299-1-mcanal@igalia.com> References: <20241030130308.1066299-1-mcanal@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B965140029 X-Stat-Signature: adh43yaa8uux9zqg3p596xz6nez4bb9a X-HE-Tag: 1730293420-822709 X-HE-Meta: U2FsdGVkX18T8exqurft4HF9yWhQoA3NbD030EPi133bRw2BXZiqzVovhoEaWDEvitYbhjaqRaK8OpZP5CScWTSq9rcH/1u/A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82hi2NG8CBoXJ3fKhpssFFY8zRHW0z5AZAdEOLG24G2ddFMctgnDOtT3+lKLnieW91FbL+fl6Pir9IA7qPRJm+e/6MUufHe+nbdP1+MHpIVZBXQdaG/ny1yyMm9icjR2P2wiQkKG8YkbEQ2ME1yw9gTnAcHdxioFlRs4AzsJBfA1Qtrjt1/MvHkZYO7sMRnsK3ZIrArEcpSdP6w6xxxgDXnhBioc3+L646r56s= 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: List-Subscribe: List-Unsubscribe: If we add ``thp_anon=32,64K:always`` to the kernel command line, we will see the following error: [ 0.000000] huge_memory: thp_anon=32,64K:always: error parsing string, ignoring setting This happens because the correct format isn't ``thp_anon=,[KMG]:```, as [KMG] must follow each number to especify its unit. So, the correct format is ``thp_anon=[KMG],[KMG]:```. Therefore, adjust the documentation to reflect the correct format of the parameter ``thp_anon=``. Fixes: dd4d30d1cdbe ("mm: override mTHP "enabled" defaults at kernel cmdline") Signed-off-by: Maíra Canal Acked-by: Barry Song Acked-by: David Hildenbrand --- Documentation/admin-guide/kernel-parameters.txt | 2 +- Documentation/admin-guide/mm/transhuge.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 1518343bbe22..1666576acc0e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6688,7 +6688,7 @@ 0: no polling (default) thp_anon= [KNL] - Format: ,[KMG]:;-[KMG]: + Format: [KMG],[KMG]:;[KMG]-[KMG]: state is one of "always", "madvise", "never" or "inherit". Control the default behavior of the system with respect to anonymous transparent hugepages. diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 203ba7aaf5fc..745055c3dc09 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -303,7 +303,7 @@ control by passing the parameter ``transparent_hugepage=always`` or kernel command line. Alternatively, each supported anonymous THP size can be controlled by -passing ``thp_anon=,[KMG]:;-[KMG]:``, +passing ``thp_anon=[KMG],[KMG]:;[KMG]-[KMG]:``, where ```` is the THP size (must be a power of 2 of PAGE_SIZE and supported anonymous THP) and ```` is one of ``always``, ``madvise``, ``never`` or ``inherit``. From patchwork Wed Oct 30 12:58:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13856488 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 8DB44D5CCA9 for ; Wed, 30 Oct 2024 13:03:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC5266B00C3; Wed, 30 Oct 2024 09:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D73626B00C4; Wed, 30 Oct 2024 09:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBD046B00C1; Wed, 30 Oct 2024 09:03:54 -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 909536B00C1 for ; Wed, 30 Oct 2024 09:03:54 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 45DF840CE4 for ; Wed, 30 Oct 2024 13:03:54 +0000 (UTC) X-FDA: 82730284560.09.272A702 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf03.hostedemail.com (Postfix) with ESMTP id 7DB7F20013 for ; Wed, 30 Oct 2024 13:03:40 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=dZPbD1RG; spf=pass (imf03.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730293352; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KhLqGBl5TV6NmgS4fHCrJuFzbGHnT6xMy1eOztxHavg=; b=bwYSWH7hP2seqtY+0+PI0RZpXScQREOkLwV3wrAIpDbDJUsZYz6+WJerSNXknj3fbElj71 yVheusBLQWzWvejo2fc81Xw7K0bgUNKM8FnCZEA0XvNPUDkf9aVzL0ZV2TjGe9a/AJvJuQ /t+YQWNMrON/UPy7VPc62uDam7LzoT8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=dZPbD1RG; spf=pass (imf03.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730293352; a=rsa-sha256; cv=none; b=hYhOzNLfSla5LpDH1xzB7gZFVAZjpA2abwL0mErbF3FjAmmqDQiEMRTF8LtXvQvl86LIXq MwtAYej1mRPuhYUm0JxJjF1mihcRDV6H7FS3KmAyTg4Ad6cxPCyVOhCdWH80+vTjjc1MBe tpz6Gfl+A91rW8uNcF/iHGRsVfZ+T9A= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KhLqGBl5TV6NmgS4fHCrJuFzbGHnT6xMy1eOztxHavg=; b=dZPbD1RG6pReVV1dOCJ0ApCQE/ KzEL6y45ASLkh2mZ6IeR+Eujl9rct/rDPOZ83WttX0a2JnM/jPkILvD+T0CS1O5Olxar+9Q2txQgR Hc7ff5FWE9Pv3eP/oubI1C816wuK+LM1F3z7HDPPRJo/k+ewyEHQW40C1eA5cWEtpV3PsS/v5kRiD bO3sCfaKSyrrA29QeAjdQavHF/2hKaiS/ivzOOj6tjZo2dBqaxqJwpuPLPi5p45fhnWqIMePahczs k9qHbvmOgJ0DYa8a/yr0tvRmLhev8Hz6lhBu/O1TWP2/vvH5kVvfJOf7dp5iTMUL0AntC/DQuow/r qeguRXuQ==; Received: from [187.36.213.55] (helo=morissey..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t68MN-00H5h8-Qy; Wed, 30 Oct 2024 14:03:40 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Jonathan Corbet , Andrew Morton , Hugh Dickins , Barry Song , David Hildenbrand , Ryan Roberts , Baolin Wang , Lance Yang Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= Subject: [PATCH v3 2/4] mm: shmem: control THP support through the kernel command line Date: Wed, 30 Oct 2024 09:58:56 -0300 Message-ID: <20241030130308.1066299-3-mcanal@igalia.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241030130308.1066299-1-mcanal@igalia.com> References: <20241030130308.1066299-1-mcanal@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 7DB7F20013 X-Stat-Signature: 8cuxnmc9o9c5bzrp6qxguswn84rd5dkt X-HE-Tag: 1730293420-629370 X-HE-Meta: U2FsdGVkX19gWVf0gk/1zt45ID73ZMm8QvP1Z+LO0GpiafP8TEhBk9DTV/Em9c7ET6rXiLivcIm6nEJK/MguVlbgHQc+WmpEARW8pbHlN57hCqOdG44hMHAuUJB7Vd9zduObuFKBaq0Wvsqum6OHS0hPgBebugwcxRRXmp/XNNDrb4ru2N85wXjFQWuQhVVwvNAI+3awsIBVdkAXi540Yu7ZRb037kCoXJlKY/qSuVMfxCaASI/B7l0YKDMJuKJKkc3qc9SpDw5m82qDuhCQYQ9puF8NGYC9ZKifwkcHMxXSvrXsRmQz5pEvMt1F6rcdTyS+IZ5P3QlBwo7ByUfO4Mj9xHliP/urAGs8SLKZlMYgcImziKg6YuGE3X4aOPf7I4mUdV4QNGBcMtn33tUuU7V7UWmQUrs6R2x0iQ9AHnIMysbVScCWq9IwtgUvX57LMgw3NliqK0ZMqhBKrj+xvoghWLdolS3tEQBg6yuUpodT44LLBqmzCP1dIIKqJnpU7EY2MV9i2rX5jG43G/rXKIWsjJOTiqNhcZtbBStGYG/DQAwUrM5akSr8yDN90ECpqztbUWrzOvbkgctb6gPqgKfRZ+CM5BhaoepXi2jdezBJEf72NsTTnPyQ3rth10KgO/Ftz+HXm2qNnxxYJcHWF/VWtbe94U5Cb9gXWDbuhlqzhgNyxpGY0FYzFW6xgpzvH3iRyt8+jLOJTIR8W/bHpRR9C6ABWzEy0KRgdvhqit/vl3fQEFMW8TRnIrpVc5xxA1HYmV/cAuioLwK7qUEQmrylG26g/EkQg4MazqSlMWJM58pZ0/QqYSTlHv0J1f5rewlBRuD22DtuuNJmuSJr2qbqABoQOtZGJzTEamaYxZFdL5U2lk5z0+5xvrwAosJx/IhgyFKiBM+5H6ZzYEUyonHDKKkx/NhJnf5CTPBnbwyXycr5GVFOaziULQr59ydsKo8VQjWH+40f24H5/mH GMGw7D6d hco6RO43woZAhA0Gp5BkX3zyRwM6LHGa/HkwNVjFl5/EPItjs63EVXfio2GZ5D/EsgVquJaUiu3eAxU2cbQ1JG+bunF7EKLfDPIgoZXJVAEca0eKvkASC+3nIQuGVVUyDnVWgS8WUjdnZjQ3N47SHuZvTuy4SzdPfhWJ+iV5AXcwpMomKuIz2QfuLRlGKKmKNP4QkMVPUbOM6sc0nh9ECJf+ZVZjiXs2NdCr/OUsJ87apZ4ZQ/1HVxx9LAvYKaRta+hC7YOoVgjz3TWoDlLlC9y51DG/5vl3LK/i4nzcDntYDp2l6Wwdaky2RKGtyUQn+ir70ql3ig/5Sjsg= 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: List-Subscribe: List-Unsubscribe: Add a new kernel command line to control the hugepage allocation policy for the internal shmem mount, ``transparent_hugepage_shmem``. The parameter is similar to ``transparent_hugepage`` and has the following format: transparent_hugepage_shmem= where ```` is one of the seven valid policies available for shmem. By configuring the default hugepage allocation policy for the internal shmem mount, applications that use shmem, such as the DRM GEM objects, can take advantage of mTHP before it's been configured through sysfs. Signed-off-by: Maíra Canal Reviewed-by: Baolin Wang Acked-by: David Hildenbrand --- .../admin-guide/kernel-parameters.txt | 7 ++ Documentation/admin-guide/mm/transhuge.rst | 6 ++ mm/shmem.c | 72 +++++++++++++------ 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 1666576acc0e..acabb04d0dd4 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6926,6 +6926,13 @@ See Documentation/admin-guide/mm/transhuge.rst for more details. + transparent_hugepage_shmem= [KNL] + Format: [always|within_size|advise|never|deny|force] + Can be used to control the hugepage allocation policy for + the internal shmem mount. + See Documentation/admin-guide/mm/transhuge.rst + for more details. + trusted.source= [KEYS] Format: This parameter identifies the trust source as a backend diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 745055c3dc09..9b5b02c4d1ab 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -326,6 +326,12 @@ PMD_ORDER THP policy will be overridden. If the policy for PMD_ORDER is not defined within a valid ``thp_anon``, its policy will default to ``never``. +Similarly to ``transparent_hugepage``, you can control the hugepage +allocation policy for the internal shmem mount by using the kernel parameter +``transparent_hugepage_shmem=``, where ```` is one of the +seven valid policies for shmem (``always``, ``within_size``, ``advise``, +``never``, ``deny``, and ``force``). + Hugepages in tmpfs/shmem ======================== diff --git a/mm/shmem.c b/mm/shmem.c index 275251abd596..dfcc88ec6e34 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -582,24 +582,39 @@ static bool shmem_huge_global_enabled(struct inode *inode, pgoff_t index, } } -#if defined(CONFIG_SYSFS) static int shmem_parse_huge(const char *str) { + int huge; + + if (!str) + return -EINVAL; + if (!strcmp(str, "never")) - return SHMEM_HUGE_NEVER; - if (!strcmp(str, "always")) - return SHMEM_HUGE_ALWAYS; - if (!strcmp(str, "within_size")) - return SHMEM_HUGE_WITHIN_SIZE; - if (!strcmp(str, "advise")) - return SHMEM_HUGE_ADVISE; - if (!strcmp(str, "deny")) - return SHMEM_HUGE_DENY; - if (!strcmp(str, "force")) - return SHMEM_HUGE_FORCE; - return -EINVAL; + huge = SHMEM_HUGE_NEVER; + else if (!strcmp(str, "always")) + huge = SHMEM_HUGE_ALWAYS; + else if (!strcmp(str, "within_size")) + huge = SHMEM_HUGE_WITHIN_SIZE; + else if (!strcmp(str, "advise")) + huge = SHMEM_HUGE_ADVISE; + else if (!strcmp(str, "deny")) + huge = SHMEM_HUGE_DENY; + else if (!strcmp(str, "force")) + huge = SHMEM_HUGE_FORCE; + else + return -EINVAL; + + if (!has_transparent_hugepage() && + huge != SHMEM_HUGE_NEVER && huge != SHMEM_HUGE_DENY) + return -EINVAL; + + /* Do not override huge allocation policy with non-PMD sized mTHP */ + if (huge == SHMEM_HUGE_FORCE && + huge_shmem_orders_inherit != BIT(HPAGE_PMD_ORDER)) + return -EINVAL; + + return huge; } -#endif #if defined(CONFIG_SYSFS) || defined(CONFIG_TMPFS) static const char *shmem_format_huge(int huge) @@ -5066,15 +5081,7 @@ static ssize_t shmem_enabled_store(struct kobject *kobj, huge = shmem_parse_huge(tmp); if (huge == -EINVAL) - return -EINVAL; - if (!has_transparent_hugepage() && - huge != SHMEM_HUGE_NEVER && huge != SHMEM_HUGE_DENY) - return -EINVAL; - - /* Do not override huge allocation policy with non-PMD sized mTHP */ - if (huge == SHMEM_HUGE_FORCE && - huge_shmem_orders_inherit != BIT(HPAGE_PMD_ORDER)) - return -EINVAL; + return huge; shmem_huge = huge; if (shmem_huge > SHMEM_HUGE_DENY) @@ -5171,6 +5178,25 @@ struct kobj_attribute thpsize_shmem_enabled_attr = __ATTR(shmem_enabled, 0644, thpsize_shmem_enabled_show, thpsize_shmem_enabled_store); #endif /* CONFIG_TRANSPARENT_HUGEPAGE && CONFIG_SYSFS */ +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) + +static int __init setup_transparent_hugepage_shmem(char *str) +{ + int huge; + + huge = shmem_parse_huge(str); + if (huge == -EINVAL) { + pr_warn("transparent_hugepage_shmem= cannot parse, ignored\n"); + return huge; + } + + shmem_huge = huge; + return 1; +} +__setup("transparent_hugepage_shmem=", setup_transparent_hugepage_shmem); + +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + #else /* !CONFIG_SHMEM */ /* From patchwork Wed Oct 30 12:58:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13856490 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 76438D5CCAA for ; Wed, 30 Oct 2024 13:04:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0CB8A6B0082; Wed, 30 Oct 2024 09:03:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02C116B0096; Wed, 30 Oct 2024 09:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE9096B00C4; Wed, 30 Oct 2024 09:03:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BF4EC6B0082 for ; Wed, 30 Oct 2024 09:03:58 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 73B58409A6 for ; Wed, 30 Oct 2024 13:03:58 +0000 (UTC) X-FDA: 82730285358.21.58EB6E8 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf06.hostedemail.com (Postfix) with ESMTP id 50676180011 for ; Wed, 30 Oct 2024 13:03:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=BW9uTa1p; spf=pass (imf06.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730293276; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Jtek6fKyThwdm08oQdbY7JhOEaPOoD9jVitbx9tAXxg=; b=nTDDEbnKrZZ1/jhOKdsfOOOh8m1J6ohbKNCdVLa8eRdumRaQ4ktYUt3LCj+KDJHKZiEtIp xAaIZ1TthYf8+oEQpbxXGVWqQQiaIeafmlc0byeTFw+YoseUWzGZ0ntPubXGMk7WjkCtD1 Gg9KojycCcM4aehzvI4obKYuP/ZZ1Hw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730293276; a=rsa-sha256; cv=none; b=vYuXEG5F7TMqSLCzLkcgIfWC29d+/Am7PIxwypAh3N4sKpEMfnYAC7eSXeHCKknXhhZkiS 3+sbXEr+48mkeDZDlNOS/jeuMk+DN7CgkEdq6gEEhifHLvYkQqnvtnq+JY2lu9TUT84qG7 ZTBVhZ5FcokBZjKS+szGzFyMTI0BB18= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=BW9uTa1p; spf=pass (imf06.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Jtek6fKyThwdm08oQdbY7JhOEaPOoD9jVitbx9tAXxg=; b=BW9uTa1pzhUhZZqbRwkIsyDC59 1Vq8aXhWnRUGP5lrQnw5L7p1Vw3ReEVgwhFAZ2xp22wBF5oaGWLGz9poI+qn3mFlP7o+cnWktvUk/ KCWRXISj+4FJGASbNU583nK9FN7wkCJN4R3rcUWMISmkh3J6wOL/o6HpCfVR38FwDJcZxfQxUdAPu rFgp38z4cxZT/UVT/5HwNnArqbcTd4I1KBGdQgrBF5lz1aS7f3FXuO7r3arhcs1Gl25VQoedCL0D0 BgDs9vVSFC6i7FA4L9xMwky7mIlwctV9KyDdf1h6d7DrDg5pQYE9LjUDfMcCCliiDh2unDt11jW1T jIYYyPYA==; Received: from [187.36.213.55] (helo=morissey..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t68MT-00H5h8-4T; Wed, 30 Oct 2024 14:03:45 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Jonathan Corbet , Andrew Morton , Hugh Dickins , Barry Song , David Hildenbrand , Ryan Roberts , Baolin Wang , Lance Yang Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= Subject: [PATCH v3 3/4] mm: shmem: override mTHP shmem default with a kernel parameter Date: Wed, 30 Oct 2024 09:58:57 -0300 Message-ID: <20241030130308.1066299-4-mcanal@igalia.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241030130308.1066299-1-mcanal@igalia.com> References: <20241030130308.1066299-1-mcanal@igalia.com> MIME-Version: 1.0 X-Stat-Signature: b3baeze1h9jho45k6izjtwrao16smqw6 X-Rspamd-Queue-Id: 50676180011 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1730293418-623095 X-HE-Meta: U2FsdGVkX19uG9/2pdmdf75W8kV800zJvLWECedTtap6QNtk07uIo7xaEqcI/JVQivczS2FvVut3e9/tWh2ZIEn1/nsoQXwZgqBlH7zT5iqTt62jf7edntxL6wj1OArMn27RWEP/XDPNDqEYT8/DdXWK8diZCHrl73rPFRE/Fyr6TFtsLdnC9g+U/2NSkkQ+VtIHeBRrgYa/YCFaYqvH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aLMKuGJErpMwxE= 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: List-Subscribe: List-Unsubscribe: Add the ``thp_shmem=`` kernel command line to allow specifying the default policy of each supported shmem hugepage size. The kernel parameter accepts the following format: thp_shmem=[KMG],[KMG]:;[KMG]-[KMG]: For example, thp_shmem=16K-64K:always;128K,512K:inherit;256K:advise;1M-2M:never;4M-8M:within_size By configuring the default policy of several shmem hugepages, the user can take advantage of mTHP before it's been configured through sysfs. Signed-off-by: Maíra Canal --- .../admin-guide/kernel-parameters.txt | 10 ++ Documentation/admin-guide/mm/transhuge.rst | 17 +++ mm/shmem.c | 109 +++++++++++++++++- 3 files changed, 135 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index acabb04d0dd4..b48d744d99b0 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6700,6 +6700,16 @@ Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD. + thp_shmem= [KNL] + Format: [KMG],[KMG]:;[KMG]-[KMG]: + Control the default policy of each hugepage size for the + internal shmem mount. is one of policies available + for the shmem mount ("always", "inherit", "never", "within_size", + and "advise"). + It can be used multiple times for multiple shmem THP sizes. + See Documentation/admin-guide/mm/transhuge.rst for more + details. + topology= [S390,EARLY] Format: {off | on} Specify if the kernel should make use of the cpu diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 9b5b02c4d1ab..47e7fc30e22d 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -332,6 +332,23 @@ allocation policy for the internal shmem mount by using the kernel parameter seven valid policies for shmem (``always``, ``within_size``, ``advise``, ``never``, ``deny``, and ``force``). +In the same manner as ``thp_anon`` controls each supported anonymous THP +size, ``thp_shmem`` controls each supported shmem THP size. ``thp_shmem`` +has the same format as ``thp_anon``, but also supports the policy +``within_size``. + +``thp_shmem=`` may be specified multiple times to configure all THP sizes +as required. If ``thp_shmem=`` is specified at least once, any shmem THP +sizes not explicitly configured on the command line are implicitly set to +``never``. + +``transparent_hugepage_shmem`` setting only affects the global toggle. If +``thp_shmem`` is not specified, PMD_ORDER hugepage will default to +``inherit``. However, if a valid ``thp_shmem`` setting is provided by the +user, the PMD_ORDER hugepage policy will be overridden. If the policy for +PMD_ORDER is not defined within a valid ``thp_shmem``, its policy will +default to ``never``. + Hugepages in tmpfs/shmem ======================== diff --git a/mm/shmem.c b/mm/shmem.c index dfcc88ec6e34..c2299fa0b345 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -136,6 +136,7 @@ static unsigned long huge_shmem_orders_always __read_mostly; static unsigned long huge_shmem_orders_madvise __read_mostly; static unsigned long huge_shmem_orders_inherit __read_mostly; static unsigned long huge_shmem_orders_within_size __read_mostly; +static bool shmem_orders_configured __initdata; #endif #ifdef CONFIG_TMPFS @@ -5027,7 +5028,8 @@ void __init shmem_init(void) * Default to setting PMD-sized THP to inherit the global setting and * disable all other multi-size THPs. */ - huge_shmem_orders_inherit = BIT(HPAGE_PMD_ORDER); + if (!shmem_orders_configured) + huge_shmem_orders_inherit = BIT(HPAGE_PMD_ORDER); #endif return; @@ -5180,6 +5182,26 @@ struct kobj_attribute thpsize_shmem_enabled_attr = #if defined(CONFIG_TRANSPARENT_HUGEPAGE) +static inline int get_order_from_str(const char *size_str) +{ + unsigned long size; + char *endptr; + int order; + + size = memparse(size_str, &endptr); + + if (!is_power_of_2(size)) + goto err; + order = get_order(size); + if (BIT(order) & ~THP_ORDERS_ALL_FILE_DEFAULT) + goto err; + + return order; +err: + pr_err("invalid size %s in thp_shmem boot parameter\n", size_str); + return -EINVAL; +} + static int __init setup_transparent_hugepage_shmem(char *str) { int huge; @@ -5195,6 +5217,91 @@ static int __init setup_transparent_hugepage_shmem(char *str) } __setup("transparent_hugepage_shmem=", setup_transparent_hugepage_shmem); +static char str_dup[PAGE_SIZE] __initdata; +static int __init setup_thp_shmem(char *str) +{ + char *token, *range, *policy, *subtoken; + unsigned long always, inherit, madvise, within_size; + char *start_size, *end_size; + int start, end, nr; + char *p; + + if (!str || strlen(str) + 1 > PAGE_SIZE) + goto err; + strscpy(str_dup, str); + + always = huge_shmem_orders_always; + inherit = huge_shmem_orders_inherit; + madvise = huge_shmem_orders_madvise; + within_size = huge_shmem_orders_within_size; + p = str_dup; + while ((token = strsep(&p, ";")) != NULL) { + range = strsep(&token, ":"); + policy = token; + + if (!policy) + goto err; + + while ((subtoken = strsep(&range, ",")) != NULL) { + if (strchr(subtoken, '-')) { + start_size = strsep(&subtoken, "-"); + end_size = subtoken; + + start = get_order_from_str(start_size); + end = get_order_from_str(end_size); + } else { + start = end = get_order_from_str(subtoken); + } + + if (start < 0 || end < 0 || start > end) + goto err; + + nr = end - start + 1; + if (!strcmp(policy, "always")) { + bitmap_set(&always, start, nr); + bitmap_clear(&inherit, start, nr); + bitmap_clear(&madvise, start, nr); + bitmap_clear(&within_size, start, nr); + } else if (!strcmp(policy, "advise")) { + bitmap_set(&madvise, start, nr); + bitmap_clear(&inherit, start, nr); + bitmap_clear(&always, start, nr); + bitmap_clear(&within_size, start, nr); + } else if (!strcmp(policy, "inherit")) { + bitmap_set(&inherit, start, nr); + bitmap_clear(&madvise, start, nr); + bitmap_clear(&always, start, nr); + bitmap_clear(&within_size, start, nr); + } else if (!strcmp(policy, "within_size")) { + bitmap_set(&within_size, start, nr); + bitmap_clear(&inherit, start, nr); + bitmap_clear(&madvise, start, nr); + bitmap_clear(&always, start, nr); + } else if (!strcmp(policy, "never")) { + bitmap_clear(&inherit, start, nr); + bitmap_clear(&madvise, start, nr); + bitmap_clear(&always, start, nr); + bitmap_clear(&within_size, start, nr); + } else { + pr_err("invalid policy %s in thp_shmem boot parameter\n", policy); + goto err; + } + } + } + + huge_shmem_orders_always = always; + huge_shmem_orders_madvise = madvise; + huge_shmem_orders_inherit = inherit; + huge_shmem_orders_within_size = within_size; + shmem_orders_configured = true; + return 1; + +err: + pr_warn("thp_shmem=%s: error parsing string, ignoring setting\n", str); + return 0; +} +__setup("thp_shmem=", setup_thp_shmem); + #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #else /* !CONFIG_SHMEM */ From patchwork Wed Oct 30 12:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13856491 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 2F43FD5CCA9 for ; Wed, 30 Oct 2024 13:04:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD8986B00C6; Wed, 30 Oct 2024 09:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C88C96B00C9; Wed, 30 Oct 2024 09:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B015B6B00CB; Wed, 30 Oct 2024 09:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E4546B00C6 for ; Wed, 30 Oct 2024 09:04:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 49FD44088F for ; Wed, 30 Oct 2024 13:04:03 +0000 (UTC) X-FDA: 82730285820.18.83B584C Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id 5B7D5A003F for ; Wed, 30 Oct 2024 13:03:35 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="AjeU/KsG"; spf=pass (imf15.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730293361; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/lH6a4L8gtRKOjPZ3v2254wh73VRSysBe4phJD9CDEs=; b=N2GqDigEc+trik+LdsKyZ782Op1a6YjTsaN8huE/XpNFPd2hJcN/Lb18AO7n6id1LhwXij 7sz0raAfj0svQXZKaMbX0hT4kXmJfkNJs8MHJ6tAPusKaqy41ZWp0pnVyjpCymGqeG8mFq rfnZAOV8+iH5hesbByJ4Wm0NueB4gxQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="AjeU/KsG"; spf=pass (imf15.hostedemail.com: domain of mcanal@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=mcanal@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730293361; a=rsa-sha256; cv=none; b=iMNaKKYrLHowZkl+hGPsn0ACcbhfRLr7rjnPQX2K7+EUU5g7XDvPCz9G98k6Nfv+551Bqu COMwEsDDgdzYrAuyser8DeMnB44Od9MayZrS/4/S2P+/JrbBhk4YPze08bMxmPDOEUzPRN Mzu9UOEw2aYqdyow1Ph4Oh14Hgt1o5s= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/lH6a4L8gtRKOjPZ3v2254wh73VRSysBe4phJD9CDEs=; b=AjeU/KsGJLU50JSiT7VnonXpVh xz162mpXuW5PYT8HVrkynl+V4L5bYQ6ExijZcA+EMXvKfT6YIV+MAjIQJ4gsHzbRp79rnDgZdjgsb upmm9Teb+VtHj3VcJHi4NtlEBRE+XnecY0G26vW2jhQrT4TW46nw65Ed5GVT1hZ9HKRRLCCsDEQ+r sG1XmQcd6BDGZj/lJXYm8hAt9NXjZDSs0ej2GO41/QQC6TAR+iUcAVhs1Tvrrpqfn0X1iC/EtyHWU /RRQGdXOMT6j6rTERDtWG7RAq5YMYsinIfXvvLRGEiuqPZf8FybhAvLw+F78ANejVw4Pj1uJ4n0LO l2zQmP5A==; Received: from [187.36.213.55] (helo=morissey..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t68MY-00H5h8-CM; Wed, 30 Oct 2024 14:03:50 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Jonathan Corbet , Andrew Morton , Hugh Dickins , Barry Song , David Hildenbrand , Ryan Roberts , Baolin Wang , Lance Yang Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Ma=C3=ADra_C?= =?utf-8?q?anal?= Subject: [PATCH v3 4/4] mm: huge_memory: Use strscpy() instead of strcpy() Date: Wed, 30 Oct 2024 09:58:58 -0300 Message-ID: <20241030130308.1066299-5-mcanal@igalia.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241030130308.1066299-1-mcanal@igalia.com> References: <20241030130308.1066299-1-mcanal@igalia.com> MIME-Version: 1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7EjtoA1/0rPcIem/g/luk3 fJd3r9yI voQOF8u3H4JhzsGRAlhIz0w78vlTtSZtrNLX2xQEv8gfG9WRrrRqdDLhwOG9hYu0YMGckYv95dUWqFMk9fCqoiDm+hX5YGqmrHjvPTmHEWDNx8HdkWlOwidb6SJGy+aoMwsIaahySHAWq9YdjIwCzRZLVNpzPQGis1w7VomdjRCQYXLVjFh1WprkUXNUGjbGu1zBucAo2q8Tedw2woq80RUJWYBKCoXU5VjYLSA4BlzHVOAFjRbFUI/HwbnfYSOVVEKBedrRRJoFDHlxLRh7CEn15/efBLNXod5SWlEyp5hXhKVysOf7fmQ4cPzLPx1QJGpjr3ulPugxRmWn8Ashwmym19mJr7NTWEW6ooKEHjgPmsmy/9/glX8OqBdM4tpNr3CH9GVovfSbZugsOBKnu1sHrXA== 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: List-Subscribe: List-Unsubscribe: Replace strcpy() with strscpy() in mm/huge_memory.c strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source. Link: https://github.com/KSPP/linux/issues/88 Signed-off-by: Maíra Canal Reviewed-by: Lance Yang --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f92068864469..8f41a694433c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -989,7 +989,7 @@ static int __init setup_thp_anon(char *str) if (!str || strlen(str) + 1 > PAGE_SIZE) goto err; - strcpy(str_dup, str); + strscpy(str_dup, str); always = huge_anon_orders_always; madvise = huge_anon_orders_madvise; @@ -4175,7 +4175,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf, tok = strsep(&buf, ","); if (tok) { - strcpy(file_path, tok); + strscpy(file_path, tok); } else { ret = -EINVAL; goto out;