From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 781821531C1 for ; Sat, 7 Mar 2026 16:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772899730; cv=none; b=Z5BWxCEFHfAAjENl8TsPuj56eTbsEXq/REg71EMSpfckX7mHcLJGfsaRdoEPDdBfqCCcmaNUVTlLeUDEJWfsToZYD+6FMpJjmhXlY+g5gXgsCZ7XGreXMEhWEbkFBgu80rTgMa0Mhe3n3UjMMl51KOYLDgnKpwbTZuDG5At+1aA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772899730; c=relaxed/simple; bh=AGgC5XZOt40eYEobmJCAuFdk3ct3NpfVKCtOGV6Ni4w=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=QxJv8UVbe4Ld8dxGRg/vdMYLYmMBklyrrqzSVi2CJkn27WE/rfVczEIGUYblbPZGrp4se+glS+7oDh+UKIOn0DNZE7q2LbVmyWUKzciIqfqfwiQSrvZo0gdm9uhqQMQ4vtCKF0/eHfQJ1HKeXDTBbnlXgzmtiYT7qWgQAs5evkI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=W9bTTcrx; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="W9bTTcrx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:From:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=R8iZ/PJn7DWvBICYADVRrswu3ZDl8IGSd5K+vwXeoRQ=; b=W9bTTcrxiwcCQzw/vvv6HPP1Ss d14FfXnuccCWPbER+hScTcktdhPMtAhjjx+zpIGxqNvUx/oxeiY+cn9TOwa9ok1clJzBzkwt2pjgw k+MvOzCspX4Mo7/Rwog7AYtByjgLnF2vP1AUSWzwmjUdH6s3XQ5T0spX487vFEieLYIt5hVRlpU2r snUuf+iW+N7J07rn1/EfpMEXUnqTUG/n/WvezrVwYh26Y7dOIdjB3NFQwWH3dwdfnKXDO/ASPdA+D OCYDUVI/I75OVAqz0jtCct2Rv1Ne5o7/FLYo8QmEpVVleT0JRCNjsd1Wuio9UTGXbkxEP36SJ+QVn 8bUhA1fg==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vyuCd-000nEX-3x; Sat, 07 Mar 2026 16:08:32 +0000 From: Breno Leitao Subject: [PATCH v3 0/4] mm: thp: reduce unnecessary start_stop_khugepaged() calls Date: Sat, 07 Mar 2026 08:08:04 -0800 Message-Id: <20260307-thp_logs-v3-0-a45d2c8f3685@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAGZNrGkC/1WN0Q6CIBhGX4X919IQhMSr3qO1BoJKa+LAWM357 g1byy6/7ZzzLRBtcDZCgxYINrno/AgNYgWCdlBjb7Ez0CCghArCCMPzMF3vvo+YcGmErkknjIA CwRRs555b6nz57PjQN9vO2c/E4OLsw2v7SmXmvtnql00lJphLwmpa1opydjJWOzUefOghdxPdm 3xnUkywFJopc5S8ltWfua7rG0eio3HtAAAA X-Change-ID: 20260303-thp_logs-059d6b80f6d6 To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Zi Yan , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, usamaarif642@gmail.com, kas@kernel.org, kernel-team@meta.com, "Lorenzo Stoakes (Oracle)" , Breno Leitao X-Mailer: b4 0.15-dev-363b9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2808; i=leitao@debian.org; h=from:subject:message-id; bh=AGgC5XZOt40eYEobmJCAuFdk3ct3NpfVKCtOGV6Ni4w=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBprE14Rfi4spc3AHwjUpHVYY7pPHuogMlliI8CS UWr60fZ/PmJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaaxNeAAKCRA1o5Of/Hh3 beChD/9HXUfZMyPFw4kvGDcPA+cvpMo7+3HkLY67rIliNLP3R15XX3Uz0dXXXKgjToSFJ6axmY2 b70ppciBtRZIy5A/ZodGO2+rBFSoYuv1SkWYSwxQZVKatpi8/KfTIlTPvViWJh6HMlwP0SYXpfq sFrOo6bnjDq1lgolf/HgbP/Fu4G3WNmfsUaMzBT/PbLUFzT3gwIF9KSVs4iww8YtHFsLbZ6rIRv H6+j3iLGbeuJ2YvQjyQ4om8i8dnX244ej72uKkOEaN0y0L2yODaomFFFMUsdFtTrkU2Nq20EIkC uK96E0xFxlotGl2IHAclbI3Ep/6TVrInKZkCKBcuVyQ58BEcfEuAzSEHkOP+1fHpACcvgt2t+RM HUWRa7BULRGMgzcH0+Z+wNZbfQt+ADXrJggejTmC6YQqUwDJt6yB1cFqGGg2oBlQDKGOi0AAOO/ znjc3x82mY/e685Dt1liyrJdXpOQhgQ3oz/mATvaWef0wXR9o2R6nn5nJ/Jo2CHze9s/W85JZY2 sTSpI3uxIGa77PnsTLiuoV7Uj94ktd65BE4Ka/Tg0SqZ8hHf07h7+pJHV39jLWO1O0yGXKfVThW yToy+nnr22vn5DahNBZSe2IO6/2lpigWpXGiiZKwVat9gBSWQQGwDh+eBxRc7ayW/LjY6v/LojK uyeHb7eUXiirqHA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Writing to /sys/kernel/mm/transparent_hugepage/enabled causes start_stop_khugepaged() called independent of any change. start_stop_khugepaged() SPAMs the printk ring buffer overflow with the exact same message, even when nothing changes. For instance, if you have a custom vm.min_free_kbytes, just touching /sys/kernel/mm/transparent_hugepage/enabled causes a printk message. Example: # sysctl -w vm.min_free_kbytes=112382 # for i in $(seq 100); do echo never > /sys/kernel/mm/transparent_hugepage/enabled ; done and you have 100 WARN messages like the following, which is pretty dull: khugepaged: min_free_kbytes is not updated to 112381 because user defined value 112382 is preferred A similar message shows up when setting thp to "always": # for i in $(seq 100); do # echo 1024 > /proc/sys/vm/min_free_kbytes # echo always > /sys/kernel/mm/transparent_hugepage/enabled # done And then, we have 100 messages like: khugepaged: raising min_free_kbytes from 1024 to 67584 to help transparent hugepage allocations This is more common when you have a configuration management system that writes the THP configuration without an extra read, assuming that nothing will happen if there is no change in the configuration, but it prints these annoying messages. For instance, at Meta's fleet, ~10K servers were producing 3.5M of these messages per day. Fix this by making the sysfs _store helpers easier to digest and ratelimiting the message. This version is heavily based on Lorenzo's suggestion on V1. --- Changes in v3: - Extra ratelimit patch. - Create two enums, one for anon and one for global. (Lorenzo) - Remove the `extern` from set_recommended_min_free_kbytes (Lorenzo) - Export set_recommended_min_free_kbytes() definition to mm/internal.h (Lorenzo) - Link to v2: https://patch.msgid.link/20260305-thp_logs-v2-0-96b3ad795894@debian.org Changes in v2: - V2 is heavily based on Lorenzo and Kiryl feedback on v1. - Link to v1: https://patch.msgid.link/20260304-thp_logs-v1-0-59038218a253@debian.org --- Breno Leitao (4): mm: khugepaged: export set_recommended_min_free_kbytes() mm: huge_memory: refactor anon_enabled_store() with change_anon_orders() mm: huge_memory: refactor enabled_store() with change_enabled() mm: ratelimit min_free_kbytes adjustment messages mm/huge_memory.c | 147 +++++++++++++++++++++++++++++++++++++------------------ mm/internal.h | 5 ++ mm/khugepaged.c | 6 +-- mm/page_alloc.c | 4 +- 4 files changed, 110 insertions(+), 52 deletions(-) --- base-commit: 9dd5012f78d699f7a6051583dc53adeb401e28f0 change-id: 20260303-thp_logs-059d6b80f6d6 Best regards, -- Breno Leitao