From nobody Sat Feb 7 13:41:18 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 675CE257859; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; cv=none; b=Ya80YUzpk0dvgu2cllrKujrPxxU0A+qS4N2OV+tR1nLxNvji3ZVcvee29Qk+9m9SpKZVIRQJWuX/IO5ZBg1asGLql4uuG66x/WoFGZ3FQHzEAWGglgxkQIsBnORgVIHMGgqbGATpKnFqFaBiJ29VBd+J0EUIVHNkLzoWh4jKG0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; c=relaxed/simple; bh=m1g5uoH2P6wU5+w9MpROfiHCEcAhvKwueo5z8pV/iIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=esd7zllZRp7txuGN5lFwffyf/L9pjaajPoEM0Pjtm6qKZ+LLcXQqx4WHeoViH72tjKmGlq9Ow0SUYO/TAfVZareO0QKKvAikWnrtV+mfw1496E/zuuGe37hbG9xCJc5p1O8sgcejuIgCV1A65DsZqPbnUqwQHDTX58NHOylSyBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hv7oM6Fu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hv7oM6Fu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5334C16AAE; Thu, 25 Dec 2025 02:30:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766629848; bh=m1g5uoH2P6wU5+w9MpROfiHCEcAhvKwueo5z8pV/iIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hv7oM6FuFVBFimNiN0++SlKU0Babvo1q/s0diD8J21TRCQTPHl9iI0Ed1VuwpLcC6 VoizBokSE4cNvmfNPlU0YLNhEsw6kzOipsfotF71PzIYrVDrls9il1BUf7XZVtS961 6flx6XDCsDddpb9kuoKWiUoYIRB4mYSGVJbSYMSBmu0DY+y2HH5/FfKIpBh5m9I3Ct PenhSknzyZ5LgUnxheh3MdhASObRZkkqAqEPB9c2Va54t/4OfN/U9l8mqOMNI02fDb M+tOxuMuOfLrrEJN3e3si4WfbsISRy0vQWn/YigCyM+4UyhmOP7ik1FY9y5tC+2IEE fWGN8vwZPYB6A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 15 . x" , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/4] mm/damon/sysfs: cleanup intervals subdirs on attrs dir setup failure Date: Wed, 24 Dec 2025 18:30:34 -0800 Message-ID: <20251225023043.18579-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251225023043.18579-1-sj@kernel.org> References: <20251225023043.18579-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When attrs/ DAMON sysfs directory setup is failed after setup of intervals/ directory, intervals/intervals_goal/ directory is not cleaned up. As a result, DAMON sysfs interface is nearly broken until the system reboots, and the memory for the unremoved directory is leaked. Cleanup the directory under such failures. Fixes: 8fbbcbeaafeb ("mm/damon/sysfs: implement intervals tuning goal direc= tory") Cc: # 6.15.x Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index e2bd2d7becdd..a669de068770 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -792,7 +792,7 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysf= s_attrs *attrs) nr_regions_range =3D damon_sysfs_ul_range_alloc(10, 1000); if (!nr_regions_range) { err =3D -ENOMEM; - goto put_intervals_out; + goto rmdir_put_intervals_out; } =20 err =3D kobject_init_and_add(&nr_regions_range->kobj, @@ -806,6 +806,8 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysf= s_attrs *attrs) put_nr_regions_intervals_out: kobject_put(&nr_regions_range->kobj); attrs->nr_regions_range =3D NULL; +rmdir_put_intervals_out: + damon_sysfs_intervals_rm_dirs(intervals); put_intervals_out: kobject_put(&intervals->kobj); attrs->intervals =3D NULL; --=20 2.47.3 From nobody Sat Feb 7 13:41:18 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7C51D2638BC; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; cv=none; b=MWqXPTFnY2crm8DDHn/8ovXcZMtvex6Gjjx/bRDtTBXhhT+iMiwE1AhAwgEmFy1c4uYCDJll9e5Zcl0kkWJjj1TNWAd+sR0MS0eq9m+vmP/vYlCIj32FeJVhr8KAl2Q5YG/4bAEsdYXb4it8YVAl/Cw0U+OjGiYM5ZMavh3nwtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; c=relaxed/simple; bh=uCpoE/Jqb55vNr00kSEg/jQImas43u/CkKNXRFT/dX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K0AbrweoDmnV34l0PGa4jn87jqa+DaT6tYVuyDe9tInqtSB+IrkUvTLOdptmUEUQjbZP1oD91ls78vv5Mpqu0U24Sy4d9OYLYOi0YZnVUNg4312V7Wy0m1vkJu3KnQNuL/Dd3xwhnJieMuo26qJDr3DE0wPu1VYKpbjHBSo50rk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uEWInZVt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uEWInZVt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A3C5C19421; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766629849; bh=uCpoE/Jqb55vNr00kSEg/jQImas43u/CkKNXRFT/dX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uEWInZVtCJTE18Lw5f2GG6oaCBPdA36k9wlDxYkCYl6oTZ1U7jl40RyUuuDDyqxq+ 1DdTcRYUgw7Z4IadWoaPWX1Y08pe/S3fqM5sSMtrDPANa16QFdQi99SnWXe1LDlsHt g/Pi1B2px2xVjlI4z3nVxXzdsZrdIcxYqXTlnXtgQAx77BiYjjs9eRUDQerBpLo/M9 6NpCeIHIMlDPp4fv0iOapXuESM7xzNCVuXGaCORZ5+aR1PPGQWFqEh85iJNd+1ZLtp S1kpDAlx1GCQRSgntDCTz0Uh5VDZeEInV2cWvB1v19Htu5x2FRz1ScmubbkqE8s3UP hS9ARSMsVnfmQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 18 . x" , Jiapeng Chong , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] mm/damon/sysfs: cleanup attrs subdirs on context dir setup failure Date: Wed, 24 Dec 2025 18:30:35 -0800 Message-ID: <20251225023043.18579-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251225023043.18579-1-sj@kernel.org> References: <20251225023043.18579-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a context DAMON sysfs directory setup is failed after setup of attrs/ directory, subdirectories of attrs/ directory are not cleaned up. As a result, DAMON sysfs interface is nearly broken until the system reboots, and the memory for the unremoved directory is leaked. Cleanup the directories under such failures. Fixes: c951cd3b8901 ("mm/damon: implement a minimal stub for sysfs-based DA= MON interface") Cc: # 5.18.x Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index a669de068770..95fd9375a7d8 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -950,7 +950,7 @@ static int damon_sysfs_context_add_dirs(struct damon_sy= sfs_context *context) =20 err =3D damon_sysfs_context_set_targets(context); if (err) - goto put_attrs_out; + goto rmdir_put_attrs_out; =20 err =3D damon_sysfs_context_set_schemes(context); if (err) @@ -960,7 +960,8 @@ static int damon_sysfs_context_add_dirs(struct damon_sy= sfs_context *context) put_targets_attrs_out: kobject_put(&context->targets->kobj); context->targets =3D NULL; -put_attrs_out: +rmdir_put_attrs_out: + damon_sysfs_attrs_rm_dirs(context->attrs); kobject_put(&context->attrs->kobj); context->attrs =3D NULL; return err; --=20 2.47.3 From nobody Sat Feb 7 13:41:18 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B82F926AAAB; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; cv=none; b=ErMW9SzzPi9SIST/zOgP4pzosLl3PN/M717epVkDLxMgkUvLTjcuNMScOPCuA73dkXLrl3ZOyu0lffvW45faJe3J2xb9jTUpImt+MsFOuGpL4y5wHLrD9w9wtuaP0ESGCXWG6Qcv51ywTeaY0cs9ptU7HSYtMOB5WGgRdmnI2SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629849; c=relaxed/simple; bh=eAX9UEANbnhjK8d5CURObQKfqWquwN6z8606mMzlq4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZKXe0g7N+nzxtbEEhJ8/Qyq9FtQLV1HMD6cPF7upBjONwBQuLI8Vg1/TS8eKOyGLvjxMid+X5BSxEmep9VpZOqFu/+M4nGxASpku0uWvh8Uw3KUKJe5BNFfq+4hlOoRfu97Vs5CdmowwjRtjvE3JmVf75Iyu+qqzfbEHGgR5Tvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QnKOlKKP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QnKOlKKP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C8F5C19422; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766629849; bh=eAX9UEANbnhjK8d5CURObQKfqWquwN6z8606mMzlq4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QnKOlKKPM/iXDA0ZpwIGk0cmg3wxuxetRyiKSYiUvLjRqQ1nPgtsBsSSnC17hv0HL J+I9BF2EmigRhUqjDIoHO8sMY1R3TZGdK1/PeDFL6M3hmKKyQymrvDRXmdq2tyt/rg +CVgPId/WRYPM1M+97LwmgRF9O8IbaosT5lCq6/ZKwCpLJQfjtulVf7pu+nie3e1es VzgTQ26eoW7tbkbpAvtiv3isgZTUaFKmC8mYttzgip3DFLG1iZxmvsHXsoFTy+klS8 Xom+krn1o2Z9orbIIMg6AW5qwK9Wte89CX2mA7ewghLhwh7yAdRaxdM5PIZllA1ruZ Neg9rtHU60SxA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 18 . x" , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/4] mm/damon/sysfs-scheme: cleanup quotas subdirs on scheme dir setup failure Date: Wed, 24 Dec 2025 18:30:36 -0800 Message-ID: <20251225023043.18579-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251225023043.18579-1-sj@kernel.org> References: <20251225023043.18579-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a DAMOS-scheme DAMON sysfs directory setup fails after setup of quotas/ directory, subdirectories of quotas/ directory are not cleaned up. As a result, DAMON sysfs interface is nearly broken until the system reboots, and the memory for the unremoved directory is leaked. Cleanup the directories under such failures. Fixes: 1b32234ab087 ("mm/damon/sysfs: support DAMOS watermarks") Cc: # 5.18.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index e198234f0763..7f14e0d3e7a0 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2199,7 +2199,7 @@ static int damon_sysfs_scheme_add_dirs(struct damon_s= ysfs_scheme *scheme) goto put_dests_out; err =3D damon_sysfs_scheme_set_watermarks(scheme); if (err) - goto put_quotas_access_pattern_out; + goto rmdir_put_quotas_access_pattern_out; err =3D damos_sysfs_set_filter_dirs(scheme); if (err) goto put_watermarks_quotas_access_pattern_out; @@ -2224,7 +2224,8 @@ static int damon_sysfs_scheme_add_dirs(struct damon_s= ysfs_scheme *scheme) put_watermarks_quotas_access_pattern_out: kobject_put(&scheme->watermarks->kobj); scheme->watermarks =3D NULL; -put_quotas_access_pattern_out: +rmdir_put_quotas_access_pattern_out: + damon_sysfs_quotas_rm_dirs(scheme->quotas); kobject_put(&scheme->quotas->kobj); scheme->quotas =3D NULL; put_dests_out: --=20 2.47.3 From nobody Sat Feb 7 13:41:18 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EB28526ED41; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629850; cv=none; b=o1WbXQFiozthuLjmVHH76yREv5BDEP3j/8+28I4qyFZpcvAZ2xUuFVYkPdijm38X3BPl/Ctsl9WrqTXyeToWprrN3UdtpX8Ns8xBR52VbLia7TxRmzVYIqQ8ckzNQu7XZFSDOmZD4fldeIQTbdR4TwRW4yvHJ2/EozTRoxSJ94g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766629850; c=relaxed/simple; bh=Sx0CCPkN1ZKSx9TC6izh6KVTqV3LFSqvwNdLWbM+vgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nZR7ADE9Tta5F/niC9w3ue88VaCZ9b8yJNM5XYEH59q6Uke9OrRr8KXYSW1jbOZKQK2wYAYOtVndW1XQ0TvN8kVOeYuH5UteRE1mFdYGzY/9218tGlY6cnYZURmbsoQH+7iXQjraA9WkC2mZG1QPGBI1yfe1G8hEos9YT7VaMGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cRWk/C6B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cRWk/C6B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84BB6C116D0; Thu, 25 Dec 2025 02:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766629849; bh=Sx0CCPkN1ZKSx9TC6izh6KVTqV3LFSqvwNdLWbM+vgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRWk/C6BM9l8y9MbU7j9gAiyc2ySgM/NtdR6845qDKPmniln4UXdTR8njdowCh4ul 1CJGNmOkJ0pJUhEYrlWgt3BcpL50u2tgAhzR3gahZtafU2sDQ8luDSj0tUpjLPLCur 2H9nJPleBXgUQOnrdPFlQgt82kVj5cfKYKKbdSh1FrJbWPtlFwWB5mIFc6X1Ze2IGe X3zMlccmkKtz0acpwiqgQ1SUb0xjCM+867p6oZjrHi7XvFDkzoyokYWS4SMDapq0n7 syFda+EOT3rM+Dva8HDBypBVicEWurJLKYeUrsFsn0uJTXBxv0lqD6CcT9lCK+qSn5 ofxMjZNTvr2Pg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 18 . x" , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/4] mm/damon/sysfs-scheme: cleanup access_pattern subdirs on scheme dir setup failure Date: Wed, 24 Dec 2025 18:30:37 -0800 Message-ID: <20251225023043.18579-5-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251225023043.18579-1-sj@kernel.org> References: <20251225023043.18579-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a DAMOS-scheme DAMON sysfs directory setup fails after setup of access_pattern/ directory, subdirectories of access_pattern/ directory are not cleaned up. As a result, DAMON sysfs interface is nearly broken until the system reboots, and the memory for the unremoved directory is leaked. Cleanup the directories under such failures. Fixes: 9bbb820a5bd5 ("mm/damon/sysfs: support DAMOS quotas") Cc: # 5.18.x Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7f14e0d3e7a0..19bc2288cd68 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2193,7 +2193,7 @@ static int damon_sysfs_scheme_add_dirs(struct damon_s= ysfs_scheme *scheme) return err; err =3D damos_sysfs_set_dests(scheme); if (err) - goto put_access_pattern_out; + goto rmdir_put_access_pattern_out; err =3D damon_sysfs_scheme_set_quotas(scheme); if (err) goto put_dests_out; @@ -2231,7 +2231,8 @@ static int damon_sysfs_scheme_add_dirs(struct damon_s= ysfs_scheme *scheme) put_dests_out: kobject_put(&scheme->dests->kobj); scheme->dests =3D NULL; -put_access_pattern_out: +rmdir_put_access_pattern_out: + damon_sysfs_access_pattern_rm_dirs(scheme->access_pattern); kobject_put(&scheme->access_pattern->kobj); scheme->access_pattern =3D NULL; return err; --=20 2.47.3