From patchwork Tue Apr 1 09:08:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakie Kim X-Patchwork-Id: 14034518 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 7901EC36018 for ; Tue, 1 Apr 2025 09:10:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 784F7280002; Tue, 1 Apr 2025 05:10:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70B3C280001; Tue, 1 Apr 2025 05:10:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DE9D280002; Tue, 1 Apr 2025 05:10:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3B797280001 for ; Tue, 1 Apr 2025 05:10:36 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F2C3E5A389 for ; Tue, 1 Apr 2025 09:10:35 +0000 (UTC) X-FDA: 83284904430.28.B5FCDB7 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf06.hostedemail.com (Postfix) with ESMTP id 768B318000A for ; Tue, 1 Apr 2025 09:10:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of rakie.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=rakie.kim@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743498634; 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; bh=R7AK0MJUvcA7pOqucUjfmaFbi4RlE2QQ4WCom2rLULE=; b=iKq54pI2BqCmlndldPJUrqQPts99KePhAUrZ63qh0dyqbZA4YpUMmOiih4DpslxNNgCOxz U7fTQvFwJHQ9xDbKtbkhvBKCpYVB3pievqiVld2qrhA/fILpEr3mvYG7hampPuMuouSN+X B98y6fsAgDF4BpTGtrDK/FWqpGNKR9w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743498634; a=rsa-sha256; cv=none; b=8hlAu8ufkpaPa+ATViIzjAggXn7BCBGY0JcUOu/uwMNGj0zCzDMbcx1Ilrk7826ojKw+Ha 5UlsT8r9Tczwc5WqoB7UY+1OeIRxStY87+7RoF+ciVOmvINTaPORYVTAuIhYPv4mofWXgI 6gm/2ItnLfnWQ0x20jdNuTYJ1JIRESg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of rakie.kim@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=rakie.kim@sk.com; dmarc=none X-AuditID: a67dfc5b-669ff7000002311f-2d-67ebad85c490 From: Rakie Kim To: gourry@gourry.net Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, joshua.hahnjy@gmail.com, dan.j.williams@intel.com, ying.huang@linux.alibaba.com, david@redhat.com, Jonathan.Cameron@huawei.com, kernel_team@skhynix.com, honggyu.kim@sk.com, yunjeong.mun@sk.com, rakie.kim@sk.com Subject: [PATCH v4 0/3] Enhance sysfs handling for memory hotplug in weighted interleave Date: Tue, 1 Apr 2025 18:08:56 +0900 Message-ID: <20250401090901.1050-1-rakie.kim@sk.com> X-Mailer: git-send-email 2.48.1.windows.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBLMWRmVeSWpSXmKPExsXC9ZZ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lHZ7N0MXJxMAtcY5I48PkmC0hCWCBCYu3VVewg9SwC qhLdv21AwrxAYxbd2c8OMVJTouHSPSaIuKDEyZlPwFqZBeQlmrfOZp7AyDULSWoWktQCRqZV jCKZeWW5iZk5pnrF2RmVeZkVesn5uZsYgSG7rPbPxB2MXy67H2IU4GBU4uHdUPoqXYg1say4 MvcQowQHs5IIb8TXl+lCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeb3CUxOEBNITS1KzU1MLUotg skwcnFINjHl5rUYXXObpiE0rXBTsNvXiOmvP6gfrvCv5e0VW7hcoL1ZKXKqkXKV3ZYZE7o6X u81zpqmt7Wq6cq/7jc3s9g6Zfk4NEZWdrfq1/VoPwuZ4yyb+iyzrr13/VHXRpsQqt1bD8j+p 8z1zZrLv+u9y9mbv/fNXEo1S9zn3BHAf+9J7517JvtOBSizFGYmGWsxFxYkAfEhAf1UCAAA= X-CFilter-Loop: Reflected X-Stat-Signature: afob86pdp3tfk1c8guscjjzkoq36ikxf X-Rspam-User: X-Rspamd-Queue-Id: 768B318000A X-Rspamd-Server: rspam08 X-HE-Tag: 1743498633-327125 X-HE-Meta: U2FsdGVkX18bIDpOmjko2MT5mLECHnpwh7BllZYsRxpYJZJhXOmmW+22cLd4mHoMuHAW+jJ+L7MC+RstRWt4dpYqk0T7Ln2o3U7Gz6gIcANyJUVqovnL395180l08urb1FXuszTduAzRS8rFBVGKGSPiq5IeFwXYX3oItNm9FcXDQd4p1RW0HXO6KA5QALfifEWnD/VFH7LDQC0I2csDb+QXruIyBRh33TcbRLodt3KaZbDv4F8C0ge5mj+TJ36W1bh3K73a/vxoeOHDnmWD2MdpFOFHvlXUfSJzwqWIoIfOa5m9OONgZzTNxol80scv5MBq6qeIk5UYCMBlCnnrRXIvJkkUdb6YGxmPc+8H6hlnNxxf/gEzcsYdrZrK+UXZ4669rQjtyp4soTT1jxf8L0jvAjebBpv1hsLkqYS+bj69G5fRxWasnbJyQ09LFzd2pOx5G969zzkYNwxEt2KOaLRpDMVIwoklq/Sp7fshtjj33ZcrUc0QzLrwwN+7zzvEFVxJNBMMjtz4JAAtiut932P+E/c6HGl5HxSoa9v6vI1fDoG8+FfmpvtRk0jjSNdeztuHZGv7F+BzsaTosE0KNDP+/rsFKO3HfG7Ul8T0eLupnqCW0do8mKGoPu/yrIrlClNHkTevISC4xPgF+mJUBfo4mgAkn5t3nsayDNDrRSjM8YcGdnDPYxQrt1Kz05MTkiBGT5C3Oy99t0VjP7E/r8uqGkdHzlvZsz7Nh8FPTyo4a809X/uVp2yAanfXyAL4LKiQo2coyG5TGR7tF+PfKReBJiYeg9xKWc4RqSnuIf+jFYxfb8xKe66x+P82Jwyo14RII/XJd3db6o1zf2JYRo+N9wU1HC/MJ4N4l6PoNpNCZ4SA34WnQIFpgZ4FI++1bvVhhoJkLzFsrcPHbyeRlJz17tQX5/JBBBukDW+EwVSzggJ7IGHd5deaFrYVQallpgBLdabQR5AMiRXll97 4i1cQnyf GOzbaR/f97j0YNvMXuxMma3N+/QL4VBE9sRrptZ85i3qHasg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The following patch series enhances the weighted interleave policy in the memory management subsystem by improving sysfs handling, fixing memory leaks, and introducing dynamic sysfs updates for memory hotplug support. ### Background The weighted interleave policy distributes memory allocations across multiple NUMA nodes based on their performance weight, thereby optimizing memory bandwidth utilization. The weight values are configured through sysfs. Previously, sysfs entries for weighted interleave were managed statically at initialization. This led to several issues: - Memory Leaks: Improper `kobject` deallocation caused memory leaks when initialization failed or when nodes were removed. - Lack of Dynamic Updates: Sysfs attributes were created only during initialization, preventing nodes added at runtime from being recognized. - Handling of Unusable Nodes: Sysfs entries were generated for all possible nodes (`N_POSSIBLE`), including memoryless or unavailable nodes, leading to sysfs entries for unusable nodes and potential misconfigurations. ### Patch Overview 1. [PATCH 1/3] Fix memory leaks in weighted interleave sysfs - Ensures proper cleanup of `kobject` allocations. - Replaces unnecessary `kfree()` calls with `kobject_put()`, preventing memory leaks and improving system stability. 2. [PATCH 2/3] Enable dynamic updates for weighted interleave sysfs - Restructures sysfs handling to allow runtime updates. - The sysfs attributes are now globally accessible, enabling external modules to manage interleave settings dynamically. 3. [PATCH 3/3] Support memory hotplug in weighted interleave - Modifies sysfs creation logic to restrict entries to nodes that are online and have memory, excluding unusable nodes. - Introduces a memory hotplug mechanism to dynamically add and remove sysfs attributes when nodes transition into or out of the `N_MEMORY` set. - Ensures that sysfs attributes are properly removed when nodes go offline, preventing stale or redundant entries from persisting. These patches have been tested under CXL-based memory configurations, including hotplug scenarios, to ensure proper behavior and stability. mm/mempolicy.c | 195 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 127 insertions(+), 68 deletions(-) base-commit: 38fec10eb60d687e30c8c6b5420d86e8149f7557