From patchwork Fri Nov 8 07:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Ge X-Patchwork-Id: 13867699 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 5892DD5E145 for ; Fri, 8 Nov 2024 07:50:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DAEB76B00A2; Fri, 8 Nov 2024 02:50:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5EFC6B00A8; Fri, 8 Nov 2024 02:50:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C26F96B00A9; Fri, 8 Nov 2024 02:50:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A2BA96B00A2 for ; Fri, 8 Nov 2024 02:50:50 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1DE2E140A25 for ; Fri, 8 Nov 2024 07:50:50 +0000 (UTC) X-FDA: 82762155504.18.EFF38B3 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) by imf16.hostedemail.com (Postfix) with ESMTP id 0752118000B for ; Fri, 8 Nov 2024 07:50:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="ZXbg/zx9"; spf=pass (imf16.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731052080; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=lUvCn2yrrfm8AzUVnUrwIJ/DyEBVwLRQoeLNZi8hUx4=; b=d/X5t/ItCHKCkjUeOqh02Oh/Cm/TR4syagDHwLnl9JY6tMzOkTM8lsMneHn/YHQyXsLy54 V0/qLf0dsvPLi+O/Lz5z7dU+fJbCmIuM0n0c7qwSDXO20UrTSyL2A40d6CPZc5iz6vCWZe xyEZvr7nK13EgPxp6VPitzyJpGYwAgo= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="ZXbg/zx9"; spf=pass (imf16.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731052080; a=rsa-sha256; cv=none; b=JIFiB6t/6KHbYEKqjMKxPQXn4jJcCIv+EqB3gJLTaYelyWIJxJK/3Ajyx5yxd2Qx/1iEyY Bzf3nZgtMFxXDTtmhJYbNgwVjjgPelsNPk1WTp0OKXy+UwLi946M8Yu6Pezo4AaFXZqtqm kZLVRqkG8Tw22E1ZN3soFuf5WOuigqI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1731052246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lUvCn2yrrfm8AzUVnUrwIJ/DyEBVwLRQoeLNZi8hUx4=; b=ZXbg/zx9eILoNJVRb9TG5+ghUGg+6oeeRnwEQ0QKIMY2gQNY2dirJcVskavAYA1RQMWYiL qsOUIHJZp/XBkWgJkWlLlA7RQSvD37oZT/JIFWFiE6PxsiZcgkVxOTa/R7V4WFM4H2sTW8 0aPxJn0SN1tH6hAt5yyc1M0ALVQ2yCY= From: Hao Ge To: akpm@linux-foundation.org, surenb@google.com, kent.overstreet@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hao.ge@linux.dev, Hao Ge Subject: [PATCH] lib/alloc_tag: Remove the sysctl configuration to prevent users from disabling it at runtime Date: Fri, 8 Nov 2024 15:50:04 +0800 Message-Id: <20241108075004.131911-1-hao.ge@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0752118000B X-Stat-Signature: wb3n8517psi4ihttmwifmsgwxh3zyzog X-Rspam-User: X-HE-Tag: 1731052211-417703 X-HE-Meta: U2FsdGVkX1+fT2KxLouZbcIkM/gZhRY/60fV5gaX2+WYW0maq3D/hNvQjk1Mip1epxwWlvLaOLBs65fwLJi7bu5/BGKTIx+y1XcZA+xfHJSKyf7nbuv9uCwBHjuJN6xG7qi8dQex37XjeU1h4uQkZ3ul5NLMfMVGg6yCLpcq8EqM5ul2Uj+R0Vh8P/ryCBTQtu8LquLqiZvZp5Ed7nGGArguzVcEo2wCcJwCZKqDGSQ2f+lZLcfKbJ0Wz7uoJl4hV8kj22bM8VmFjAP/wqKxkpQKbjfhtTOKFjPFJecYTFx5EAAwiO3jjMyaZYCMM9STdBN0R9hSTNjZauZ0TKr9aarLV8WgPySdI3ZDBbY+1NdtTNmBKTdo24l50MANKrBt3WTjZe7PMs/WiBV9qDifmyhMVdv327Chs5Q9S+8tZ6Fz21f4RyWijRXaxldoH/bBUqpO/ffqquqI3cSskN0uD10uqdJwbbMMx7SY+5D4WkRb57EnhaiqgPB0npt0Y2oppFKwEu81bfj8emcgIYi6tv20rUDCdUGjPcZu4cIJv+oE92m681rfjWi8QgV3h3wFpX91oComccJ3DHIXX6B3VuBQciiW0dA1NidaKh4drIrDf/KREJStZE3tv0UaBAWh43i/c27pOuFD6yHPFXtDtoEMlabZcS4xFxy879R045zQo5Ul03809fZ9k4u7kZbr2s4qrq6Oli3jgbuehXCXQfTAskmmD9iqpvgudjBsA6UUBBxwOKmkFTlpWsX/lRYJYh1Epq/OcgC7JZTkrgcAQXCG3KwvWFx1jsTZUZ0YROjLyowJz3D6PDdxLanht/TI+XfhmZUIBWUUZSU0cBWhjLApNTrO0XewpDrDx6xrUshQyk6ftdadNz4GnD9qaQ7z+tMQyAF1gIfsMTjSciQ6Ilko4F9pCJ9965M6CNEUgKiUOBCIql9cf4R4GOSbbFrZfKhv4XtoWirtK5goo0O gink+yMu HJnE2GwptcFaXBRB3rAFEx/ilOC7Djy5sVqRtTzeBsSRaLWvkFjWU+gTzHc0vf9EAC16HUVLr4K2oWRi5kIdNBRziBonxqEzy/0pVZlSgcBv2QUSsIHw7FNwh8PbNpZ+vO9HhYhi5Q9LGskteeA0qERsIW+QS/xvT6jPW8jnLRYMs6QDRgNH8uBvGDA== 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: From: Hao Ge After much consideration,I have decided to remove the "mem_profiling" sysctl interface to prevent users from dynamically enabling or disabling the MEMORY ALLOCATION PROFILING feature at runtime. I have taken the following actions: I set CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y to enable memory allocation profiling by default, and then made adjustments to mem_profiling dynamically during runtime. When I ran the OOM test program, I obtained useful information that was indeed very helpful for debugging. [ 1023.065402] Memory allocations: [ 1023.065407] 12.8 GiB 6546 mm/huge_memory.c:1328 func:do_huge_pmd_anonymous_page [ 1023.065412] 873 MiB 229985 arch/arm64/mm/fault.c:986 func:vma_alloc_zeroed_movable_folio [ 1023.065415] 187 MiB 29732 mm/slub.c:2412 func:alloc_slab_page [ 1023.065418] 99.8 MiB 25560 mm/memory.c:1065 func:folio_prealloc [ 1023.065421] 47.2 MiB 3189 mm/readahead.c:434 func:ra_alloc_folio [ 1023.065424] 30.0 MiB 15 mm/khugepaged.c:1072 func:alloc_charge_folio [ 1023.065428] 28.6 MiB 514 mm/compaction.c:1880 func:compaction_alloc [ 1023.065430] 25.8 MiB 6592 mm/page_ext.c:271 func:alloc_page_ext [ 1023.065433] 25.6 MiB 6546 mm/huge_memory.c:1161 func:__do_huge_pmd_anonymous_page [ 1023.065436] 23.5 MiB 6017 mm/shmem.c:1771 func:shmem_alloc_folio After running echo 0 > /proc/sys/vm/mem_profiling and then executing the same test program, I obtained the following results [ 1156.509699] Memory allocations: [ 1156.509703] 187 MiB 29645 mm/slub.c:2412 func:alloc_slab_page [ 1156.509707] 142 MiB 9357 mm/readahead.c:434 func:ra_alloc_folio [ 1156.509710] 136 MiB 41325 arch/arm64/mm/fault.c:986 func:vma_alloc_zeroed_movable_folio [ 1156.509713] 99.7 MiB 25531 mm/memory.c:1065 func:folio_prealloc [ 1156.509716] 56.0 MiB 28 mm/huge_memory.c:1328 func:do_huge_pmd_anonymous_page [ 1156.509719] 30.0 MiB 15 mm/khugepaged.c:1072 func:alloc_charge_folio [ 1156.509723] 28.6 MiB 514 mm/compaction.c:1880 func:compaction_alloc [ 1156.509725] 26.3 MiB 7460 mm/readahead.c:264 func:page_cache_ra_unbounded [ 1156.509728] 25.8 MiB 6592 mm/page_ext.c:271 func:alloc_page_ext [ 1156.509730] 23.5 MiB 6016 mm/shmem.c:1771 func:shmem_alloc_folio Because mem_profiling was disabled by executing echo 0 > /proc/sys/vm/mem_profiling,we are unable to record memory allocation information after the disablement. These output logs can mislead users. And similarly, the same applies to alloc_info. We already have boot parameters that allow users to choose whether to enable or disable. In order to maintain the accuracy of memory allocation information,I have decided to remove the runtime switch. Signed-off-by: Hao Ge --- lib/alloc_tag.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 81e5f9a70f22..47fa969c23f3 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -227,31 +227,6 @@ struct page_ext_operations page_alloc_tagging_ops = { }; EXPORT_SYMBOL(page_alloc_tagging_ops); -#ifdef CONFIG_SYSCTL -static struct ctl_table memory_allocation_profiling_sysctls[] = { - { - .procname = "mem_profiling", - .data = &mem_alloc_profiling_key, -#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG - .mode = 0444, -#else - .mode = 0644, -#endif - .proc_handler = proc_do_static_key, - }, -}; - -static void __init sysctl_init(void) -{ - if (!mem_profiling_support) - memory_allocation_profiling_sysctls[0].mode = 0444; - - register_sysctl_init("vm", memory_allocation_profiling_sysctls); -} -#else /* CONFIG_SYSCTL */ -static inline void sysctl_init(void) {} -#endif /* CONFIG_SYSCTL */ - static int __init alloc_tag_init(void) { const struct codetag_type_desc desc = { @@ -264,7 +239,6 @@ static int __init alloc_tag_init(void) if (IS_ERR(alloc_tag_cttype)) return PTR_ERR(alloc_tag_cttype); - sysctl_init(); procfs_init(); return 0;