From nobody Sun Feb 8 15:58:41 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 D30422FB620; Sat, 1 Nov 2025 18:20:36 +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=1762021237; cv=none; b=Pfm0tWoRbJF54vzqrcHMOzL2lgWq7jSK8j+Nrj75R3igpkn1ULNoB8gozUUujZzjUrBwx0J9fVaf2FvyT2FAKR/YoNwGpHaH+JbW846OPP2Eap9m5n7CTFbmpwVUL+5pOTmU305Sm2HpLwy0j0XmBf3LAjKVnNBv9QUklMQxwtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=LcoET9NixI9B2TvJ7D7SHN7zAnAoJR3IY93L52/J7TI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QeAvycqtA/3K9DIPxyCt8cS80tCbNRJgzNThUWeSkYjWWqCYqvOQm5DIxbGodesheT/BXTA28JpWoo0d+CsgXnlr2MB7jE4heS7I2ITnIgc4Gou49B4vOS4ZXVGUzxtEvd05Hu5qL6raJ1E7QD/zAOGZ8kaJ7vEaWUPlWR7I6mI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p+gwKDO0; 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="p+gwKDO0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32D3DC113D0; Sat, 1 Nov 2025 18:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021236; bh=LcoET9NixI9B2TvJ7D7SHN7zAnAoJR3IY93L52/J7TI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+gwKDO0ijHRuQy1R1itqxNm+fWJPJkcg/5tdoBhu/LO8YyfDY0i2qgW+/hhIxj69 9Rg3qKTNE4us2cqc+1a+DFYugOQhB7N2SRM7IdhqFTRs34R3g6qdn5WsG1g6xVImok 5iurUisrwIKPqPY65gaPTpPIasKBBnU+zO6jCcSZkDaG1bya6LYwX4QggkeFXYKNex aAgedJwYp5rbPFRxmt5Gg4UjK8i5ESF+JfDxIXKN+QV4LBfCUas5uxQqNsaImzNx4L LS7sW0uQ7/68s33NPWGKPlQl1IpS8C3pp2nuSJHEZ96inJdk45k4hbR5iZp5sQigHx fkluiQe984sww== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 16 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/22] mm/damon/tests/core-kunit: fix memory leak in damon_test_set_filters_default_reject() Date: Sat, 1 Nov 2025 11:19:55 -0700 Message-ID: <20251101182021.74868-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" Kunit test function for damos_set_filters_default_reject() allocates two 'struct damos_filter' objects and not deallocates those, so that the memory for the two objects are leaked for every time the test runs. Fix this by deallocating those objects at the end of the test code. Fixes: 094fb14913c7 ("mm/damon/tests/core-kunit: add a test for damos_set_f= ilters_default_reject()") Cc: # 6.16.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 51369e35298b..69ca44f9270b 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -598,6 +598,9 @@ static void damon_test_set_filters_default_reject(struc= t kunit *test) */ KUNIT_EXPECT_EQ(test, scheme.core_filters_default_reject, false); KUNIT_EXPECT_EQ(test, scheme.ops_filters_default_reject, true); + + damos_free_filter(anon_filter); + damos_free_filter(target_filter); } =20 static struct kunit_case damon_test_cases[] =3D { --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 304D92FB99B; Sat, 1 Nov 2025 18:20:36 +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=1762021237; cv=none; b=BxCoGBiaDGvKApQMQOrqvcCvWbA8HEHjXlZ7HzNJs1AahkIqSXkI03QJhitlaSxsLi31BOAjFJ611xrwzk8m9869NtTYe6NlrfDMcSp2fL3r2d5NtBgmMrw70+YGPUjnsZxzFHxTdLKSd4ut0hTwnF4iBmlkVha6nSP8qr7NkYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=ouIjUDY9hLvXA2FpIhXVT6nydcM4s8x+MSQlq+lUn6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tm6KWzgZSK9SUTgU8qSXRIhxmqA8nmC2mil18tFF2WhvMrtjgmiDmS+E+w/LniZ7ENunxyfjBnCBz1qfvjc0w//pnoA3nYBN6xjv7dpaT3xJdazN0Bb2hAJ9V5GfZU/9QiJwXd9hc//XXtlJ1x4ecqFuVlBiSSq+vx+h9/DyH4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QTwPfR0t; 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="QTwPfR0t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EE15C116D0; Sat, 1 Nov 2025 18:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021236; bh=ouIjUDY9hLvXA2FpIhXVT6nydcM4s8x+MSQlq+lUn6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTwPfR0tWlZ0xcg0bSAtUMV8xDBT9nY8XilWVFWUNCZHNu9tHdOoGMRwA9qgohWZI dSYyiLubnG1H6HR9e+bU10DycteR2XiegfvrDfa7hIH/BjSKAcrbFHWPolG6utILBT IIfYB2Lo7fpJnwwWqWfYU+o7KsFAdo79J3YdFlGAv6dhb30fH1yKH4NAWgM9DBSyAo g70JxduxlhMwOVe5dJcBi+f1dMV2lTtmY3PkAckdQzMrJIVNXr5R1/nzpUVANVa7EO Kz7RUnKtcTj+P+oo/wlfj2uqT1OM6yFZayxOldtxc0SdiygribF4CHq0u/pJUUVTwA JBGgM5PwTmfXg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/22] mm/damon/tests/core-kunit: handle allocation failures in damon_test_regions() Date: Sat, 1 Nov 2025 11:19:56 -0700 Message-ID: <20251101182021.74868-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_regions() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 69ca44f9270b..a2c9ee7a5de1 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -20,11 +20,17 @@ static void damon_test_regions(struct kunit *test) struct damon_target *t; =20 r =3D damon_new_region(1, 2); + if (!r) + kunit_skip(test, "region alloc fail"); KUNIT_EXPECT_EQ(test, 1ul, r->ar.start); KUNIT_EXPECT_EQ(test, 2ul, r->ar.end); KUNIT_EXPECT_EQ(test, 0u, r->nr_accesses); =20 t =3D damon_new_target(); + if (!t) { + damon_free_region(r); + kunit_skip(test, "target alloc fail"); + } KUNIT_EXPECT_EQ(test, 0u, damon_nr_regions(t)); =20 damon_add_region(r, t); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 94CC62FBE0F; Sat, 1 Nov 2025 18:20:37 +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=1762021237; cv=none; b=afV/V5NYEaO+KRTbQBHBBqEt+VYCLA9MVamfH5TreiwBLaqXcZRaJ8Ue9owC0LHWSSoCSzxgZHWBRrhSUn206kRrt9r0tks7PYL0N4arHJsLPkHqa2MKNDWDq5flIlGY3YEj3xN1cPpgmZ8AzoD8/gkHXcA0Jv40W3JWo821IFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=pDU2J5kjF0mDExz6cAUb5XwN43HUszp8OiQLnrE7vDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MyZNTTkdBtgrX+07OIaiLnvY4+aGBdIa9EPsKC17/tvkLtOQe78yMVPpCBl2Dl+gAuQGvdWtrgx7thjafO7KPX/YJSGqVDCzGSv798KdDup0IbV8kE+BdjYPqvBv0PyPrzTfMHb8SeUcOTtTr2pR4o0FnFhS4tua7uZvSMXvkRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tjfWg275; 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="tjfWg275" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC60C116B1; Sat, 1 Nov 2025 18:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021237; bh=pDU2J5kjF0mDExz6cAUb5XwN43HUszp8OiQLnrE7vDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tjfWg275qIcqCglMB1pNp6XR9Vg/I76R2wghTcpkgMjU+pMcG/oAyVN63rubsrOU4 66VxNV9bKKV6mHnxcLtqcLvMup9T8H8dBiYozR/dFWadBrMheQ3PgYeKZnFWWWlsMj YuwKb1XkEnqeir/aZOlPZx5tzin/yqHbgWNfYvN4SmccwSkJ2tUu0i5Z5dw5PSac5o XuSWP3jy54dQRj+vUcX7F/KL+0LgDoXvC8AAZsGrh9eB05XnpYevil+X/bXiw96yoK /siThDcrZxIidLTTVVuBC6F1N2MYjM4IyiOXvhSaXO8guTBxf9w2F/hC6qkKrmW31r OBUbclFw8Ehcg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/22] mm/damon/tests/core-kunit: handle memory failure from damon_test_target() Date: Sat, 1 Nov 2025 11:19:57 -0700 Message-ID: <20251101182021.74868-4-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_target() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index a2c9ee7a5de1..6e8a605277a3 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -58,7 +58,14 @@ static void damon_test_target(struct kunit *test) struct damon_ctx *c =3D damon_new_ctx(); struct damon_target *t; =20 + if (!c) + kunit_skip(test, "ctx alloc fail"); + t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(c); + kunit_skip(test, "target alloc fail"); + } KUNIT_EXPECT_EQ(test, 0u, nr_damon_targets(c)); =20 damon_add_target(c, t); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 B7F002FC005; Sat, 1 Nov 2025 18:20:37 +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=1762021237; cv=none; b=Zw/0DpXzDG4ELeD/VE8W2wrK2vOBzk8vz4UgdPjZ8dy7teX7TpFwliSwh/IriDRt1GyKXpVILlrgleG1P5VRUMjb99OY1sweL4V0EY2S7ItPFPB+kvQ7Rm8Uq51gqguT57884nwjQSddgHHNi4quXpWA5tAbSgJCoqKjU0uC2TY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=MAHj0zqutyRZpbO2i6YXcMC7MCCsz7KkFpvZC2OrxTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WiHGGPRNHs9mk6FwjBnKlLl6prd/y4CtSIZxCnhMs//mTpGApfok58sLYpje61lRNUs4O0C/2gL6ayOTZejjP+5qTpQzwZfIgks+ZrvpIuUbFiQJTzS53KivBofjwT/A4Qok9xjeSkhy7lKMct18++ruxMkysvibdgRCoGykYBY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vIzuvFW0; 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="vIzuvFW0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EDF6C113D0; Sat, 1 Nov 2025 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021237; bh=MAHj0zqutyRZpbO2i6YXcMC7MCCsz7KkFpvZC2OrxTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIzuvFW0beDimEA3rhSSda12ZcO/KMSATCqAyuGISaMV5hCauIF/+XqjyCAc+J2/T QaGsH0X+/Eoheu7F64I6YbtbMgHUhg+00l/5iLqqGfKKF6g/kH/zS8E2pCW7PQzJ88 F9Q8bGLFDNIQlsqbAReQHcU/UqZt+9oV1pFy6IbeX8kTD/96mcEBPwpVIoN00/awFB aeYYrqdLju9ixABzTjJUPAXFcwhvwoqCsu2mdsUafcxvTVM+HptBM0FrSLxI0DWGKP TZjUQwQU+sClOrLEBhUeR4FQlQd7uBvNR4XJZkx7EhenNkCuOSLwD10m7ZHzLFOu/S d7xrjSuiegTXA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/22] mm/damon/tests/core-kunit: handle memory alloc failure from damon_test_aggregate() Date: Sat, 1 Nov 2025 11:19:58 -0700 Message-ID: <20251101182021.74868-5-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_aggregate() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 6e8a605277a3..fd1e1ecaa2c9 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -97,8 +97,15 @@ static void damon_test_aggregate(struct kunit *test) struct damon_region *r; int it, ir; =20 + if (!ctx) + kunit_skip(test, "ctx alloc fail"); + for (it =3D 0; it < 3; it++) { t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(ctx); + kunit_skip(test, "target alloc fail"); + } damon_add_target(ctx, t); } =20 @@ -106,6 +113,10 @@ static void damon_test_aggregate(struct kunit *test) damon_for_each_target(t, ctx) { for (ir =3D 0; ir < 3; ir++) { r =3D damon_new_region(saddr[it][ir], eaddr[it][ir]); + if (!r) { + damon_destroy_ctx(ctx); + kunit_skip(test, "region alloc fail"); + } r->nr_accesses =3D accesses[it][ir]; r->nr_accesses_bp =3D accesses[it][ir] * 10000; damon_add_region(r, t); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 C0C142FC00D; Sat, 1 Nov 2025 18:20:37 +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=1762021237; cv=none; b=tJLbeIWxKntbPNGstCngdcTJ+zizs6I2dWjPUicS4ycSYkighlr04LRRsG9esGf9A1URyihF/i7bpv2VwJTBINXop3GrbwAr9YNHal4BEEYsu7qxDCQDwje5IrnGnotXWGKoJ+kVQD/s9YMj5qAX7E1HW7I2k+NM1sSnt+iGOXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021237; c=relaxed/simple; bh=PgfRRLXORijPzf0z5HMHsfa0ZrC+1SalbiD9xfUzyPs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QquVz9NslNSZy9aXYXhqM7Uxy5OzUPuY79qWajjtzHaAAvgQIDscRRC6BvMso70hkrCBYwyw86VHq6CdVZ2iQIiq/Q6ZDhPB0RFjGjGbylvNoHfS/uotCsKOrS4AFhODcuuh6SepRmR+3MxfsMZM7U31vi9yGXQbKcPbzlfLh4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KSxZleUw; 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="KSxZleUw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79FF5C116C6; Sat, 1 Nov 2025 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021237; bh=PgfRRLXORijPzf0z5HMHsfa0ZrC+1SalbiD9xfUzyPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KSxZleUwuqRprD4u24yaPwktHSggSvqqzUDoN8rJzDncwxTjEUJJuHvfliQ0s5DUn wBL2ZsLPWwes1sdWPSULDRT5AydRjEX3Ra23Ba2PpfmDFCVpMsDumVlLUdwKbErfTd lOLmWlM8/r9G36rhQeZqVp/wxkidFOr1LwTGxpkva3din3cYQCdbLuzNk33xsSns0l eEtpBxagoyNL8HrkMF/qEW4nq6IAOQN2NUWNG+FeFU1vmq7m/Aya1yYhOfzAgshoIQ xS0Ti5eDXbNn4h3MNHH37FtGXMUe16EH/wrUikcDqLQMSWGZiX7s/Ei1ES2zAKvNB1 jqveyzZCTd1gg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 05/22] mm/damon/tests/core-kunit: handle alloc failures on damon_test_split_at() Date: Sat, 1 Nov 2025 11:19:59 -0700 Message-ID: <20251101182021.74868-6-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_at() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index fd1e1ecaa2c9..f5f3152cb8df 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -148,8 +148,19 @@ static void damon_test_split_at(struct kunit *test) struct damon_target *t; struct damon_region *r, *r_new; =20 + if (!c) + kunit_skip(test, "ctx alloc fail"); t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(c); + kunit_skip(test, "target alloc fail"); + } r =3D damon_new_region(0, 100); + if (!r) { + damon_destroy_ctx(c); + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } r->nr_accesses_bp =3D 420000; r->nr_accesses =3D 42; r->last_nr_accesses =3D 15; --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 780652FD670; Sat, 1 Nov 2025 18:20:38 +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=1762021238; cv=none; b=oZaA+pGD7s4T2vwar/l/v4kBeYdtmV8VhE242LFAia0S2GXrAiyUZC/9Uu5w8WZjGOChczqOO5WlLd5PkUHcihdSOCaNGrCERAkwJWpvAkLUHrx4vbYambzc+AVkdtPTsv/sHgTtLpTB/KoEM8atQahWE1ZgaNtmFYSF3x4bZCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021238; c=relaxed/simple; bh=mFKvW58Z/A1OQcFHyE0QlO67VUd7WnWfCLTNsVL0kBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lidZu+IqmS326d1l2jRM/SwYR2/y0AinJmfuUs6Nx9/rugbjvG9XMmVBJp1m3/SoqvvhG59Yb9VSECiQflwnBdaiN9yHiUWXDYNZdxHL2nR00Rclew5HUXraN74iJBghao8H5rcVrdEXzGJLCsSRcSz8Kl0fzCf11TPJkEoRYCQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FjPZlaB2; 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="FjPZlaB2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52F1C116B1; Sat, 1 Nov 2025 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021238; bh=mFKvW58Z/A1OQcFHyE0QlO67VUd7WnWfCLTNsVL0kBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FjPZlaB2TObb4T2dW5PMEVnsKEXDA50bpKODTpc5GgHl21/G21jLbAlvsxq1boR+W CulmNGBY0zT4Qdo93ckIV9xSsmlHG83/iM830OiMVCpjKGhBzKnvOkDGgUe+WA2Saz tVK18LGeQljsGtziSPkVv3pdUfs+XN9b4cCzYKEEsMLMUu6/rBnkY6Z8esXKw7TUEw oSNQgKIZ118ViGn/X/6d9PNyfXjcc6WSfgC5K4ww2ldfPdu9lwzLTQxl2M+XeZQEYY 3m4lkLAbyu5oEe8PmIxKJOHVqVjHAzYc1Dab5HJDXXDZGybbkCIoLvSw4MuIGEctzC 6QVQNiET8g+Vw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/22] mm/damon/tests/core-kunit: handle alloc failures on damon_test_merge_two() Date: Sat, 1 Nov 2025 11:20:00 -0700 Message-ID: <20251101182021.74868-7-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_merge_two() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index f5f3152cb8df..e8219fd23318 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -188,11 +188,21 @@ static void damon_test_merge_two(struct kunit *test) int i; =20 t =3D damon_new_target(); + if (!t) + kunit_skip(test, "target alloc fail"); r =3D damon_new_region(0, 100); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } r->nr_accesses =3D 10; r->nr_accesses_bp =3D 100000; damon_add_region(r, t); r2 =3D damon_new_region(100, 300); + if (!r2) { + damon_free_target(t); + kunit_skip(test, "second region alloc fail"); + } r2->nr_accesses =3D 20; r2->nr_accesses_bp =3D 200000; damon_add_region(r2, t); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 C209E2FD7A0; Sat, 1 Nov 2025 18:20:38 +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=1762021238; cv=none; b=YibwUKYOXSkikfUux2YIvbtJp02ChbxikD5CdXr312D1xAiSdEmhpeDF1MvdolPUbz1xuQMUUkP2+HfERSuPk1XghYiGRwkivPqCa8CCXRO/LbQzKhYzyvIkvUUpcp9fKiWZrZwWrBCMht7vn3aGcxsiqzripstTsEvsICLWeK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021238; c=relaxed/simple; bh=N0sjlEOjAoI+Rw+maQxTDR5r9ce2wPbMV20M9TtSgUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KxqOuwCXLXgYoevMyvF4F7MqOGfihiBUWgD740OHDMryIWJMp5Sc+GJoFY76Q+3pLpIGhumT1pWW+0r2XtU+XhAv7Ms70Yt3dbCQbSitGm5Gleipev5qXf66x50zqamIHxP1B2An8mnLkn+6MHhFmx4eXk9krD7YTgA6i3DA2Y8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lnytKmMm; 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="lnytKmMm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D2FCC4CEF1; Sat, 1 Nov 2025 18:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021238; bh=N0sjlEOjAoI+Rw+maQxTDR5r9ce2wPbMV20M9TtSgUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnytKmMmhwH7ctE3pW95SaD8GKebhnNqUSr+FWjzJEvCgLZooM6anHIe2iE2OmJ0b ZYGxHaWCOZHC8K/p0IOyOAyJV/Gazga2XGl3QWnCSTKFxUXCOdKi2GjVwbckAaCxDb /G2XmsKfz4DVQdHmEmq2skYgeRKlTZ7iSBZDKXQCEI6g2Azi8JUvFGLLqVh6EgQ1jc W/Tbmtj1811G8oaN7zrZaVyCO8WXnEI7w24HmS7ZuLDY1kE5OF/ceXBZD/X+/3d4wt bou/2a25glhCCPZ6snb5bm++oAmwyVnN6S60rW6wUzIMfsRKo37V4JeLvocWNaOZRS bsfRTKt1mo57A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 07/22] mm/damon/tests/core-kunit: handle alloc failures on dasmon_test_merge_regions_of() Date: Sat, 1 Nov 2025 11:20:01 -0700 Message-ID: <20251101182021.74868-8-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_merge_regions_of() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index e8219fd23318..98f2a3de7cea 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -248,8 +248,14 @@ static void damon_test_merge_regions_of(struct kunit *= test) int i; =20 t =3D damon_new_target(); + if (!t) + kunit_skip(test, "target alloc fail"); for (i =3D 0; i < ARRAY_SIZE(sa); i++) { r =3D damon_new_region(sa[i], ea[i]); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } r->nr_accesses =3D nrs[i]; r->nr_accesses_bp =3D nrs[i] * 10000; damon_add_region(r, t); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 B17162FD692; Sat, 1 Nov 2025 18:20:38 +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=1762021238; cv=none; b=ZyedktS7doQ5OeovLWKcSeVDtioUG20TzvSNFrdM91+k1LKSVtjY+Peo3ka0m2C7pIvA3BdJDNMtpNB4TXAZNvMUCSwVk7YwgfFt1v0XJBklDZdi944V600EgftXovuMQv60/Rx/lGdTppgI9ohn7KZicFX1ri/Ef7V8uM5TYK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021238; c=relaxed/simple; bh=xEepEI/9EWPjrFmW0+GI6DwgedFIowTo82PSpqc2yR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=modqingTg9dsJxwnUT6rJ30SLMfgF7c3ho6mUszaZgsmA4mNXjhcNmE+M1O3AyTXvvY+GV1MTa4tGrdhNuQY7XBPTO/zZmsvAZHrIn5ySNBLrMcGmZhCjKb9Ojr5JrW39fpXf0TU2i0arETo/myUAvot8gZdpgMZ7/XpN7IvIhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hN3fiNJJ; 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="hN3fiNJJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69578C113D0; Sat, 1 Nov 2025 18:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021238; bh=xEepEI/9EWPjrFmW0+GI6DwgedFIowTo82PSpqc2yR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hN3fiNJJRo0pvY442J+Yl1LisLZv1Nv6XgkcnFaM5wTHfwFoEBaMR6N0dHOloSFOk 6Ta978Kg2+ckOqj6eAzdq1b1VybHv8iRogTFKwZTelDx9TllrklStkaekQVt+XZqgs jIwNBZIBB7sVuU8N4t/7L8/sP7nBp9CsA9MYkWOsD0zLpBhpbDvSEgSRryFUM9L99r qUuvOCF4MTT4YUaJmr1syRo4PevEFj/iwXBvdoTWS/dEEcC8IX1RJUwOmZHL6MMx4V GcbOX59ebc5c5HQaBVGu3E3vnLO4bwJqp3mWmbUrQsg43s5EiYwmLm4KdFbz+mAK2s cPLHV1NWBCE0A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/22] mm/damon/tests/core-kunit: handle alloc failures on damon_test_split_regions_of() Date: Sat, 1 Nov 2025 11:20:02 -0700 Message-ID: <20251101182021.74868-9-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_regions_of() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 98f2a3de7cea..10618cdd188e 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -278,15 +278,35 @@ static void damon_test_split_regions_of(struct kunit = *test) struct damon_target *t; struct damon_region *r; =20 + if (!c) + kunit_skip("ctx alloc fail"); t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(c); + kunit_skip(test, "target alloc fail"); + } r =3D damon_new_region(0, 22); + if (!r) { + damon_destroy_ctx(c); + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } damon_add_region(r, t); damon_split_regions_of(t, 2, DAMON_MIN_REGION); KUNIT_EXPECT_LE(test, damon_nr_regions(t), 2u); damon_free_target(t); =20 t =3D damon_new_target(); + if (!t) { + damon_destroy_ctx(c); + kunit_skip(test, "second target alloc fail"); + } r =3D damon_new_region(0, 220); + if (!r) { + damon_destroy_ctx(c); + damon_free_target(t); + kunit_skip(test, "second region alloc fail"); + } damon_add_region(r, t); damon_split_regions_of(t, 4, DAMON_MIN_REGION); KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 74C312FE573; Sat, 1 Nov 2025 18:20:39 +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=1762021239; cv=none; b=GYPiYSAsNEihR2snnLGuWF6Bn9MnNvheFKo4NJ39n5FqoaCs+wuIocZDZfe6Md+/p9p/ZMSqV18uDPE96ynvfAHNh/bLtj5QHlxXLm4ZOa/Ycc8OjDXRoHuYDvgkOHrhFKPN/L5QCQWLx5fW9yms/3Gzdefut+z7MRjfwlaZjFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021239; c=relaxed/simple; bh=57kC+8zBcKudPnCnx3LGmauWpC85FOLpVi+rp5j0Qcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZLioVINTm6EOawfybV3CJOA2qqIdTh+FPLBkFLZmelMa3uAwirmnAieJQjj4acF4WcCkQ53TD2NudFIzscE5B6eEmttptbGP2QR3Z60VvTsAHP+q284rLo0E98BBUzeLT8lI+qNXg769XGXta2bV5V5p116nZv8UmD+HTLuDhKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q0pNGtMs; 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="Q0pNGtMs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5C2AC116C6; Sat, 1 Nov 2025 18:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021238; bh=57kC+8zBcKudPnCnx3LGmauWpC85FOLpVi+rp5j0Qcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q0pNGtMsrufRK+kEJFJrtki3V3cJOp38O3M0vlm+UIv8hX31367RJuWecM0108LCc v7XKC9Q62+gQVFmuxewnLt87M1IhTLf1nPSXBs1V5/QGIvm4u04sgxjysm1aQc2noh LWyVKFH+7KvlCR8eZUWDkUzAakj+7QxSDvz6KtNjG11xXaxD/PMCNqApWPFB2BBkwM Ga7qs2fUk3Lnsx5Qx/Am3lZkB2WM3nesVH/yZNeDCZhmouO4a/JIpKdsLA3U1sFgyZ 8iWbxO588pd6OoDf+OwoZHuIq9iq5K65b2C5Fki6kavJ493+CEKGwLhkrHCndTlUHW OOZUbfIik8afg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 19 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 09/22] mm/damon/tests/core-kunit: handle alloc failures in damon_test_ops_registration() Date: Sat, 1 Nov 2025 11:20:03 -0700 Message-ID: <20251101182021.74868-10-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_ops_registration() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 4f540f5ab4f2 ("mm/damon/core-test: add a kunit test case for ops reg= istration") Cc: # 5.19.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 10618cdd188e..96c8f1269f44 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -320,6 +320,9 @@ static void damon_test_ops_registration(struct kunit *t= est) struct damon_operations ops =3D {.id =3D DAMON_OPS_VADDR}, bak; bool need_cleanup =3D false; =20 + if (!c) + kunit_skip(test, "ctx alloc fail"); + /* DAMON_OPS_VADDR is registered only if CONFIG_DAMON_VADDR is set */ if (!damon_is_registered_ops(DAMON_OPS_VADDR)) { bak.id =3D DAMON_OPS_VADDR; --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 61EC12FE563; Sat, 1 Nov 2025 18:20:39 +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=1762021239; cv=none; b=LEWhZ5iHmmW8aSDWeu12HPjn90Sc4i/OZh1el+8JIcX9aBSLJZzBBPGRDO3frjQHQIZ3O2kAUNXb5DEgkjlw+zRga96q7+60x8Hqhnb4KkZNxZuCug/2C/88VEOfvs7BtnDzZ5vVS1FurgbCA/eX1jujLIslEH91F3fDi9v2cp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021239; c=relaxed/simple; bh=7jFvaJGAP1Q4wk1944apRFLq0yQCQ9xbNJKdqchcXTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cInH78zx3Rq3d1O+ePaXOLeFAachopGoI54/KJxXoBZ6k3wOrG6dpfeh8VRUzazwCPBq5ivYjxA67k2rEhWhW3g3cNIzkY4m5DbuRgtWj4s5hfQy7IFq+V/By3AkgHFxpVn2Ln7c9AOWkwFaOdSBHX6WTkN/qUMVriYEkC45R/I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fzx1oqvX; 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="fzx1oqvX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EFD7C113D0; Sat, 1 Nov 2025 18:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021239; bh=7jFvaJGAP1Q4wk1944apRFLq0yQCQ9xbNJKdqchcXTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fzx1oqvXMfUViV2BMqJZfpb2KQUo0kC6CUqYBP0FLxcaGA0B1YdoM+vM/lR9jXdkQ qucFe3ffLdcRsidGlwfI2JPBgfhilaS7lDoaq+Ypdutd6XFBKLk8+qh46IQRv0RtKZ DUkCvOoDwFpjzVk/PELeY0IqCbcWoeppyIBMHVXAgxbuxoQzAIgjM+owg5Lp0mGzc9 7qOzWsP/orm51MAae9p1o3z7PhJbKG9OlXIa0VolWBEymS/OTdUCDuDfr/3tI1NvWm qXjGK8v1MFiB+uahqGHPzfoWkCUnFpwdZx/KwgpEBGqOc/fFkpZp0IUPleZcXSJWh2 Kg2xrmTnJwrZA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 1 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/22] mm/damon/tests/core-kunit: handle alloc failures in damon_test_set_regions() Date: Sat, 1 Nov 2025 11:20:04 -0700 Message-ID: <20251101182021.74868-11-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_set_regions() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 62f409560eb2 ("mm/damon/core-test: test damon_set_regions") Cc: # 6.1.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 96c8f1269f44..e38c95f86a68 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -368,13 +368,26 @@ static void damon_test_ops_registration(struct kunit = *test) static void damon_test_set_regions(struct kunit *test) { struct damon_target *t =3D damon_new_target(); - struct damon_region *r1 =3D damon_new_region(4, 16); - struct damon_region *r2 =3D damon_new_region(24, 32); + struct damon_region *r1, *r2; struct damon_addr_range range =3D {.start =3D 8, .end =3D 28}; unsigned long expects[] =3D {8, 16, 16, 24, 24, 28}; int expect_idx =3D 0; struct damon_region *r; =20 + if (!t) + kunit_skip(test, "target alloc fail"); + r1 =3D damon_new_region(4, 16); + if (!r1) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } + r2 =3D damon_new_region(24, 32); + if (!r2) { + damon_free_target(t); + damon_free_region(r1); + kunit_skip(test, "second region alloc fail"); + } + damon_add_region(r1, t); damon_add_region(r2, t); damon_set_regions(t, &range, 1, DAMON_MIN_REGION); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 C22572FF641; Sat, 1 Nov 2025 18:20:39 +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=1762021239; cv=none; b=G62u4SeFDglLPwjYPnLYNDuttHTUfEMHaCkjaEkgvHLcfTkt+Ab9QcrS7iDBzKtTf5/cKbIjxyTJjeCYA6l0ky0xyK6Sd7sFNNt9bzlV9UULa8a6URcX7ySlaqkyZOKPV01smlmkxtR6WPjyqooKNY8g+1u4afHglV7rf4Cd/Vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021239; c=relaxed/simple; bh=oHkIjcA8qu06VIriuctGm/Bl5usqrU/VIxGOhoxmkJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SQQSisXmlem4k59L3Huiv/d/WIPKHzuYmEpobNhDwD759vFWH3HzcvMcFtUFFH86TuApq0ruyZRhGASXROOErBFYLR3HHJLI7CugGS6iPSFMjjIZjU6QPkg6ewwlNzy/lsScM95qgUIgkS/5psIuxtnzatGH7Ax4OFMJTbIpMUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kVlar5I+; 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="kVlar5I+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61AC2C19424; Sat, 1 Nov 2025 18:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021239; bh=oHkIjcA8qu06VIriuctGm/Bl5usqrU/VIxGOhoxmkJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kVlar5I+77xLhdhlMqli0zqKISxDQR3PpChs2MikS2WxH/2uyinmBsbauj612EoNj C8OL+5Xy/Cxfqhusr8xL7TjP+9PSq3bTiYIwRF+k/+ffUroFfgo2kCLqr83007Uf81 6z8/swOvObW2pChaUmpj+/JwA9YLy97/EeyBMw0H8UH4MrrfVKX3z1mduQ+47OBuTX QbTHYq6Fk3O39yYp0+879I5R4zEB6n5rMTlzK/BkFOEXRfCh3W6BsZFHRSMSjffyXA KtdQiGk+SQ673mbnyPMruQ0jUBC1AtNdG89NwgiODKTbylUasjPnZ8nEtzrGkJu87S 0grc33RzWwU4Q== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 3 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/22] mm/damon/tests/core-kunit: handle alloc failures in damon_test_update_monitoring_result() Date: Sat, 1 Nov 2025 11:20:05 -0700 Message-ID: <20251101182021.74868-12-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_update_monitoring_result() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: f4c978b6594b ("mm/damon/core-test: add a test for damon_update_monit= oring_results()") Cc: # 6.3.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index e38c95f86a68..10c9953581ee 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -429,6 +429,9 @@ static void damon_test_update_monitoring_result(struct = kunit *test) struct damon_attrs new_attrs; struct damon_region *r =3D damon_new_region(3, 7); =20 + if (!r) + kunit_skip(test, "region alloc fail"); + r->nr_accesses =3D 15; r->nr_accesses_bp =3D 150000; r->age =3D 20; --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 571583009ED; Sat, 1 Nov 2025 18:20:40 +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=1762021240; cv=none; b=ucdgLPi9fYy/TdU0Fkvy0qTZHs9VyCGqFVCfruDF+xTgCnnNqc/+G30+Hu3TxfAwb+Ne4RWJe7MEUTg2dzV+GDURt9hDdalEJIQucAm8Ye6fZZeoh9WmBE9xCGoKWJmHxu15Pv6G6mlIFm3GPxi+MxAzpeg7jJKyK7hOgZwMEqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021240; c=relaxed/simple; bh=dtnr1Fqk2FrpK5TYhb0W5JzpIRDJYhJ9Lxh+9EtnNZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxCXZYgMojzFL2O8/x4y7Qo80m6usOjcCXfmGjmo8K9uJLp/S+avZ0AqXq8pWP7yI6o5njp542QnVALEn95e7IV51aMfn64Urf0ZOJTVxkYSlv4kqP6ddRp+EgKlgMvlbu77u07GSmJlQUSY/0CpHbQvlmZGKR4KlCt0Rz9+jos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LODRtFEU; 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="LODRtFEU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEC2C4CEF1; Sat, 1 Nov 2025 18:20:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021239; bh=dtnr1Fqk2FrpK5TYhb0W5JzpIRDJYhJ9Lxh+9EtnNZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LODRtFEU84yycbBjTVcs78D6I+NelipVPJ4hhUP33InVXZ6/uAU0nQ/Q0e5tCEB9c k52lYLaQ5R/WxIefPw1cyESyibMiqPAm+gCsrnPejUKnsVcvA3PyNC8dQC7a7P8BNs I0capoajcgS+ARJN2vZE0ycBCidUElL7NcVZnjOwEKsxi4KIyTl7pNBoTLk17WMVTT CtSFlKdgOHKfAoJmNsb/m+ijl0/KmyxTvn/YVgQaPDPdxt2HPH+m9UXxpVng28frPX UdhLUrzoTHjz0azZU87aVvssUSjOlT7/6GRDN4aL7ztWCCo0EXHS/4eQDVpMVnIaYE DPdy5Wx86MtUQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 5 . x" , Brendan Higgins , David Gow , Kefeng Wang , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 12/22] mm/damon/tests/core-kunit: handle alloc failure on damon_test_set_attrs() Date: Sat, 1 Nov 2025 11:20:06 -0700 Message-ID: <20251101182021.74868-13-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_set_attrs() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: aa13779be6b7 ("mm/damon/core-test: add a test for damon_set_attrs()") Cc: # 6.5.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 10c9953581ee..b9bd69a57e62 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -465,6 +465,9 @@ static void damon_test_set_attrs(struct kunit *test) .sample_interval =3D 5000, .aggr_interval =3D 100000,}; struct damon_attrs invalid_attrs; =20 + if (!c) + kunit_skip(test, "ctx alloc fail"); + KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &valid_attrs), 0); =20 invalid_attrs =3D valid_attrs; --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 B629E30148B; Sat, 1 Nov 2025 18:20:40 +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=1762021240; cv=none; b=W9PAM7tTJw7MHQkvyLwm4PGBrsaNzbA2PqNv/ydG+UZ+acq9DvwVPaPC1bTSSG+gX7/gYFgiin/SYTGamPAueZUN4PoTmplONNj9NCQzm/eJ4OaehsgaXWBbBn6u5mjdy0fELzk1xZrfFYUhHCQ/JEkaRrSKO15kzg1XDS+WLxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021240; c=relaxed/simple; bh=aL/KESmFEPfvW+PugHkjq38nxTmwTmF3JMfeWbPs6P8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jF42e4AqpqyQO/aO7f0OP3v1ulN7YtYNLtPz7cK6999TWJFU1CPzdIrfGWklVFGN67zkdvU7EwiwMk5JRR07cQUUjCmvdNOFGC9BRZhUiWhUQ9YYN+chyE+e8X3nfVxlt1oZdVLMq2Es1DS4PEzR9ITSsJZCHk1sbcPQHSqyb7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p55R7JFT; 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="p55R7JFT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 109F6C113D0; Sat, 1 Nov 2025 18:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021240; bh=aL/KESmFEPfvW+PugHkjq38nxTmwTmF3JMfeWbPs6P8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p55R7JFTxkg/I9BBaVkwXTv2pes8Vjux58YMHOKp3lMhyu7/gdCsDsR1qfujtGGO/ 463oNbe4vlLVpBLDse+CTlABK1OKgjJQH4w0hpj5rts961V61Ed3u/JSleneL/UmwB 7d0FO0j67wS83+q/hyeveCIZ7nfdWVRBCV5OLnPG5kC86fx+tv46AG97vK1o3yfBeV RYfNa7CpCyVo+jp0fPhzUYx/OYWh4+OmC83YU6M1tr76KithJk1Gf306JjqCbOwh0/ T8RzYxGEtD2y7JfX1UQQB29Ey3EOSdntbcZ7k2FBeXs2tU8K2OeqPYhufJGUcCjBWw iNk+Yq9qZbQ2A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 6 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/22] mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter() Date: Sat, 1 Nov 2025 11:20:07 -0700 Message-ID: <20251101182021.74868-14-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_new_filter() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 2a158e956b98 ("mm/damon/core-test: add a test for damos_new_filter()= ") Cc: # 6.6.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index b9bd69a57e62..03c7ac31db5c 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -505,6 +505,8 @@ static void damos_test_new_filter(struct kunit *test) struct damos_filter *filter; =20 filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); + if (!filter) + kunit_skip(test, "filter alloc fail"); KUNIT_EXPECT_EQ(test, filter->type, DAMOS_FILTER_TYPE_ANON); KUNIT_EXPECT_EQ(test, filter->matching, true); KUNIT_EXPECT_PTR_EQ(test, filter->list.prev, &filter->list); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 11B6130171A; Sat, 1 Nov 2025 18:20:40 +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=1762021241; cv=none; b=sjYC+Mefz8zTMzCu0o7Z05eO9Pbmz+sKfp+0o9RJc7TiuFijdqcLCC0dzqgoL+DK0xw15SsQcoJM5TW8tih7I8+aoUUBLSZaKcS6ngiN/lv3a7p2k4Q/nREonQlylE7aMIwkpr/N92nU060dALCCY9eReaxeTBcUlgbd9Kgc7SM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021241; c=relaxed/simple; bh=nowG8T+x+dG/UTataXUmNzsTvJgJYwTbgZ7j9/viwz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nkTJWoGIOhKPutA6RYcp1pa8/AFaeNtAI/2BgQGSOJj9UUAxD7j9wJjG5vl93J5iDd/g6EhUt481tXt/Nk6iRbAmdQQJTL/8vCH0Q0GSfJne00AHwKPr0UblA8IbAGD8bBGcgKHZPpEhjmIpv5zlY8m4nQXWJb8L2HY7mrgpxQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pTnX92eA; 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="pTnX92eA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63B98C19422; Sat, 1 Nov 2025 18:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021240; bh=nowG8T+x+dG/UTataXUmNzsTvJgJYwTbgZ7j9/viwz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTnX92eAX8Tf+fp/lAUwcaxrEGjrHeadsPJpIZsbEqqDPrwZrqVp38LCtAZhEyl0l fI/K64ycIzy/WXv1deyCvaZzD/ej/px2Ws/JvoMxo/BQz6DH4SCLO7OQt5PZ/emXh+ RErI/36eXxKdf1UAr4x9unOEWvp/1XboK1x+d4TaUpNX8JNnFk/v8KhbltiMHEA00c HftovZWEBLEsB6ThgrTXJEWApG9I7yabjYikWW0a/nAnVqPtDN1QGKx8WlaXCcF7PU bc9YLEoIj7Nr/hkeEaZIf74U2CtQEhFMohiQGqcoQG0X9pNkABBDigatEpVU1s/SmL rVQwbBT//EPtA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 18 . x" , Brendan Higgins , David Gow , Sang-Heon Jeon , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 14/22] mm/damon/tests/core-kunit: handle alloc failure on damos_test_commit_filter() Date: Sat, 1 Nov 2025 11:20:08 -0700 Message-ID: <20251101182021.74868-15-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_commit_filter() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: f6a4a150f1ec ("mm/damon/tests/core-kunit: add damos_commit_filter te= st") Cc: # 6.18.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 03c7ac31db5c..5af8275ffd7d 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -516,11 +516,16 @@ static void damos_test_new_filter(struct kunit *test) =20 static void damos_test_commit_filter(struct kunit *test) { - struct damos_filter *src_filter =3D damos_new_filter( - DAMOS_FILTER_TYPE_ANON, true, true); - struct damos_filter *dst_filter =3D damos_new_filter( - DAMOS_FILTER_TYPE_ACTIVE, false, false); - + struct damos_filter *src_filter, *dst_filter; + + src_filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, true); + if (!src_filter) + kunit_skip(test, "src filter alloc fail"); + dst_filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ACTIVE, false, false); + if (!dst_filter) { + damos_destroy_filter(src_filter); + kunit_skip(test, "dst filter alloc fail"); + } damos_commit_filter(dst_filter, src_filter); KUNIT_EXPECT_EQ(test, dst_filter->type, src_filter->type); KUNIT_EXPECT_EQ(test, dst_filter->matching, src_filter->matching); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 426423016EF; Sat, 1 Nov 2025 18:20:41 +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=1762021241; cv=none; b=mYn1F5HPmA2g7BtivwPx9Dq/78ibR2LH24Okv0I7cbqtFnk1SCYcgaptI5irr5VBiI4Il7lvsRtd5JWBd7n/0PLx1GDaXbGwxUd2zPBjHUoZF53CUXI6jJ22B8DCkjnTvbscaghRZohtx0SpD8mj64LLCEGLUgbuNuIwFwIzD2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021241; c=relaxed/simple; bh=XQHOX0L3vnaITOpKzT4V1ps8fyI4g/lGuTAfNYAXwxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=helZKSsAzQ93utEu5b16ThRHDYU6KBAJdkkyzi45PFSdnDCx9ZlJA4eH660GmCdnlm7bkKHHUhkbU1Vf3nl6x1YtbNHmYCoqtHAK46mnU6pa9c6fZbEs1kfKE2S2udS3Rg2mcVADTH8XFEZmdgEJ1OzJw16rp+/6weQcLu+z2Dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Imjr3I8O; 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="Imjr3I8O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6BC1C16AAE; Sat, 1 Nov 2025 18:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021240; bh=XQHOX0L3vnaITOpKzT4V1ps8fyI4g/lGuTAfNYAXwxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Imjr3I8OuNTg5Jna92aip8rzDvyfRpHauqHGpTvTfxPPVWB7HZ559aZLEngl7yTsL WsQiSy3lb7MATQaG5cMCagUHftewHz9Y7Rc3BznXFp44lPsX7g88xMa1DAT47Sb7Dg 7T2ssgB81oACG+Qqi0V4dA3RDcK3h/YHX1ZPjYXjtNBcH6rTgCOOdbbTF8ef6UsCOV 8GCbXS9gvGeHCvToxcmwmaQnSFzIM0SyybVQH6TtD5ImHuIC7V/QiWVG3dbdIVybH0 7f3ipUat6vqcfFBbr2X9bfPdHnqDTygrcF3vn60OK17js1A1vg99ZmijOZB0xHfTe2 w1Jd+dwaikcGw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 6 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/22] mm/damon/tests/core-kunit: handle alloc failures on damos_test_filter_out() Date: Sat, 1 Nov 2025 11:20:09 -0700 Message-ID: <20251101182021.74868-16-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_filter_out() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 26713c890875 ("mm/damon/core-test: add a unit test for __damos_filte= r_out()") Cc: # 6.6.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 5af8275ffd7d..a03ae9ddd88a 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -542,11 +542,22 @@ static void damos_test_filter_out(struct kunit *test) struct damos_filter *f; =20 f =3D damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false); + if (!f) + kunit_skip(test, "filter alloc fail"); f->addr_range =3D (struct damon_addr_range){ .start =3D DAMON_MIN_REGION * 2, .end =3D DAMON_MIN_REGION * 6}; =20 t =3D damon_new_target(); + if (!t) { + damos_destroy_filter(f); + kunit_skip(test, "target alloc fail"); + } r =3D damon_new_region(DAMON_MIN_REGION * 3, DAMON_MIN_REGION * 5); + if (!r) { + damos_destroy_filter(f); + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } damon_add_region(r, t); =20 /* region in the range */ --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 61301302169; Sat, 1 Nov 2025 18:20:41 +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=1762021241; cv=none; b=CRGgu02PSHasijm/zCZH69QRxnp2Pjt7v0SngDd1n2F8MS4TtSXy07qEdZ4SLkieP5nV75QSyu3s7QuOcCYup6pqJH797bc0WXS/x8X2Dz5k6T/xtlIOYGczzxoatTc3X7kgvtUzxGxgXWjaKWblnif9m1F2VuPNExhqKpCUDUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021241; c=relaxed/simple; bh=dn7Te6QsD/vqr21yqQqDCBMBy4CNhY/OvT08906eNi0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=REheMsoAOcIq3qy14aRJojJLu6mkRVulWC1u62DnpjkB4OubuifJn80a/VAHEyprI2RSeB8JJk9gykff2uOXsLvYNYWggIBCpu83An1nmEXBomKrRU0sKCyXOnZXfXh4ym+QZOvDsP3crvJE/MWVnk0XMx6uv/fEUQaNjrDAyRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dd5Ed5BV; 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="dd5Ed5BV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12B07C113D0; Sat, 1 Nov 2025 18:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021241; bh=dn7Te6QsD/vqr21yqQqDCBMBy4CNhY/OvT08906eNi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dd5Ed5BVesnLrVSQvAtYBMZfXXw32oZl1EOX5c3pKiV3gC7DlIlyUGCM58LPxLqam NWGqb58KNK4zc3zJPipj+r6qXsyPwLvRNLAYpvpXFlV7OCkQ/vysBBcMzhptz2dkem UXZOYypCXYYyuCx4tJyJHI7EI98sSFYWnPMtJvH/URMGgwKtMXjMus8cEXk40LEy0H A9AA2U7idxN3Duzxc0GhiI3JaTZNtqcx/b4FGJMDwnys85e/N6IYgDepoqf8xdC56A Sgls6IeIucaNB6roBKnKHeaCc8uG6JfjEsQziDoiGiCqe1XmtrLHRdq/le0K6LorwT sGAGvw+0CqNAg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 16 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 16/22] mm/damon/tests/core-kunit: handle alloc failures on damon_test_set_filters_default_reject() Date: Sat, 1 Nov 2025 11:20:10 -0700 Message-ID: <20251101182021.74868-17-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_set_filters_default_reject() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 094fb14913c7 ("mm/damon/tests/core-kunit: add a test for damos_set_f= ilters_default_reject()") Cc: # 6.16.x Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index a03ae9ddd88a..a91d798caa70 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -659,6 +659,8 @@ static void damon_test_set_filters_default_reject(struc= t kunit *test) KUNIT_EXPECT_EQ(test, scheme.ops_filters_default_reject, false); =20 target_filter =3D damos_new_filter(DAMOS_FILTER_TYPE_TARGET, true, true); + if (!target_filter) + kunit_skip(test, "filter alloc fail"); damos_add_filter(&scheme, target_filter); damos_set_filters_default_reject(&scheme); /* @@ -684,6 +686,10 @@ static void damon_test_set_filters_default_reject(stru= ct kunit *test) KUNIT_EXPECT_EQ(test, scheme.ops_filters_default_reject, false); =20 anon_filter =3D damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, true); + if (!anon_filter) { + damos_free_filter(target_filter); + kunit_skip(test, "anon_filter alloc fail"); + } damos_add_filter(&scheme, anon_filter); =20 damos_set_filters_default_reject(&scheme); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 B71C1303A34; Sat, 1 Nov 2025 18:20:41 +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=1762021241; cv=none; b=Ro2eSEYxleyeFVFB5kDIQH7BsAmlYd/RYlZc2VRZ+pGhwpffhlpmayjq7lKKChhrWmiqbWyT3c4WXLwGCM6qsqpjPh/sakQa0PvW3SdNT/PytPdbBix5nCytLrDvtkOHwNiHzGNnPfqwu66CGe58cI4kzkkF7j3+IyOwp7pBCl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021241; c=relaxed/simple; bh=rTI/a9CS5rBMyRZ+VKSmerz3wZX4dc/X6jh4k0lkn/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ESVBHKtoL0+/vpUJdow58Sh5xhSYmYIFB9jxcckl+9UgQxwxbq2YUhlAmUF4k59amtIy13SYjD1O5bMm9Gm1zIg4cih44d+hAIdJwgn6VpZWsZY2r1QLZjiQ8jJFaNO8oX9xolKRtBC3OFctkV7vTzzoSZ0CIBphNYQku/J1m1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VWBnC0IS; 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="VWBnC0IS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64A9CC19422; Sat, 1 Nov 2025 18:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021241; bh=rTI/a9CS5rBMyRZ+VKSmerz3wZX4dc/X6jh4k0lkn/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWBnC0ISE0B1RTenw+hmlIwbxoWWP1X0IWWsO8ttUS+7VTzsHuapAIIN103WKdPEd v/qrdO11LEOa1TK55su6gBeYsPG9OtP+PcINpY8h7PT1YJ6uV/LSPvjMpyNB9ElR/o bBTaRMOEf39uh6OR7qUy7csJcHryjca23v+pxfj2vbZ4bil7yvN2kPzGVCauAcEy5U RbNdvzY10Nla27CkGcssDBB6shJtbHx4sszd1VTAE0bskQHWAORyYHKNGuUGKtgleB bbsja4C5YAhRUXzrFLvrCcmXsBSkypaW0Ii407YasC8hA88pFsCbzYNv7vtyFu9WqQ AKC2B35af2Gmw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 17/22] mm/damon/tests/vaddr-kunit: handle alloc failures on damon_do_test_apply_three_regions() Date: Sat, 1 Nov 2025 11:20:11 -0700 Message-ID: <20251101182021.74868-18-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_do_test_apply_three_regions() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/vaddr-kunit.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index fce38dd53cf8..484223f19545 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -136,8 +136,14 @@ static void damon_do_test_apply_three_regions(struct k= unit *test, int i; =20 t =3D damon_new_target(); + if (!t) + kunit_skip(test, "target alloc fail"); for (i =3D 0; i < nr_regions / 2; i++) { r =3D damon_new_region(regions[i * 2], regions[i * 2 + 1]); + if (!r) { + damon_destroy_target(t, NULL); + kunit_skip(test, "region alloc fail"); + } damon_add_region(r, t); } =20 --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 11A7230498D; Sat, 1 Nov 2025 18:20:42 +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=1762021242; cv=none; b=FynJomiYusUwV2f0JN5ZLT5LDauNEo2MHfUTxT8veunpOewNaPLLfioQxA0oiLzV876biq14gCYF3k8hUY5mbFtAaXbQabXtWCTfT1KnjDRZs4/W9wO/tIwXDvHEmtiURTHoR8uriGq2DNcBO2qf9E95PfybqObjixu2HAb8q6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021242; c=relaxed/simple; bh=4mW1l163HEBJlF7jgeTLtvFXIHv4JgpHKouvNhyCopM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YAnUv6iWgV0pTlgkGqUc7z+YxQMVqEQxWmw6tMkcg1DmMuK8uyEuagAxyFGBK2X6WaM0TmwwTonbTHukYMZEN5pcjQ5bxgRqc5ZVaoXQSOwIRxR4rVbe8fwt3Ed4TPR3Ht8GvwaEvyRC37fzZDn2TB6mb1aPEKFV+L0WIUcVd9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KmC7pbG3; 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="KmC7pbG3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D57C116C6; Sat, 1 Nov 2025 18:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021241; bh=4mW1l163HEBJlF7jgeTLtvFXIHv4JgpHKouvNhyCopM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KmC7pbG3YkOMd+7g918cdD2BpOI7oFdF9qnxui4hsUok0+bmX4TQNx2xAn5m2S4Nn yB+XGNZpcNY3qD/0jz8c1PuFnU1/LBikJ8pBFdOAsdxM3Vlds9dLZ86Sh+2sCK3KpS 6GWOO1GI2JW805fbb2WbpIewsPcpabhvN7rmD/4zDwKqkZbS8odntB1+IotOKxj30Q Z8l9oPUDZsHJaceCN/AFGIIF6RmQdtMgTpoPMbmU/p7PmTqJPmKjw84h6oa7allm8c arhvyipfJC7GaPUhWm5o3sQuBb+GgrKujoaYcenSKnLoKv4Rab50MYJhdQy6k968TM ND6VLOxB6s1Ag== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 18/22] mm/damon/tests/vaddr-kunit: handle alloc failures in damon_test_split_evenly_fail() Date: Sat, 1 Nov 2025 11:20:12 -0700 Message-ID: <20251101182021.74868-19-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_evenly_fail() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/vaddr-kunit.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index 484223f19545..1b0f21c2e376 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -256,7 +256,16 @@ static void damon_test_split_evenly_fail(struct kunit = *test, unsigned long start, unsigned long end, unsigned int nr_pieces) { struct damon_target *t =3D damon_new_target(); - struct damon_region *r =3D damon_new_region(start, end); + struct damon_region *r; + + if (!t) + kunit_skip(test, "target alloc fail"); + + r =3D damon_new_region(start, end); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } =20 damon_add_region(r, t); KUNIT_EXPECT_EQ(test, --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 B4D6C30648A; Sat, 1 Nov 2025 18:20:42 +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=1762021242; cv=none; b=rCWydrA3ZQlSJfXZjYeG/+ZS4kQrlKSCOUV6zZr37rjCt4TyL0tVuTAGxTECuGXwaMiZg6sIY0KYk0oApBpOEb5pVg+UrHGkPjZCLH8AQD+3yAf0NWg+AsGBJbOA7L63frDmvgt2BP7owXZTBL8kbvliz0pjy8TCZ8Jvn71oeJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021242; c=relaxed/simple; bh=PLzxcHsoSe+0yVejn7B0A/LGthJsGhvzYk8OEsuxAOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YXasbcxF3IZKG7fPakosD5ql3VJVc6uzPn2sPEMWYytgDs0LNyh17MUS/WX0UM7GCwhXxnKimAFCWKGhnFxIMCPjwpir0166iRHve3XLZamBOfkdcGaDe6RgUfoa1kRSJYpHqV0gSVjS7YqW2JbxAPqwaeDGgsoSqgddUvJCizc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hk8oZQyt; 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="hk8oZQyt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10B93C4CEF1; Sat, 1 Nov 2025 18:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021242; bh=PLzxcHsoSe+0yVejn7B0A/LGthJsGhvzYk8OEsuxAOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hk8oZQytRHvD4yY1GTSmSR5xdnrFQaYLz0Neg46BHv9DIcvoXZdYDUeepzqOKkRGA PQdMwmnMSndNRmiV6tEnV7K4EfSB9+2onrnhkjywAkSRC89hu097m8uH1DBSOaUEnt QcxZhCZ0+e4MYhaAlAXRjP5D+1Lu/cM+QyXRWq6yL0OWM/3MzNwW2Q9OTGtFERMY+b okP80u3h6S+YiBXPPzoxNpKy2T+CyEy3C/323OTjtzJ4rpIoRDknBu95SpbnHJ9eQv ELqNdB/w1R6hmLmm7ZrdEC8pqQEkyG82IoWq2U+dAHxzHkZHRgObgmwwTMNOj4ZsLw /6ovLKarDPWhA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 5 . 15 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 19/22] mm/damon/tests/vaddr-kunit: handle alloc failures on damon_test_split_evenly_succ() Date: Sat, 1 Nov 2025 11:20:13 -0700 Message-ID: <20251101182021.74868-20-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_evenly_succ() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: 17ccae8bb5c9 ("mm/damon: add kunit tests") Cc: # 5.15.x Signed-off-by: SeongJae Park --- mm/damon/tests/vaddr-kunit.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h index 1b0f21c2e376..30dc5459f1d2 100644 --- a/mm/damon/tests/vaddr-kunit.h +++ b/mm/damon/tests/vaddr-kunit.h @@ -284,10 +284,17 @@ static void damon_test_split_evenly_succ(struct kunit= *test, unsigned long start, unsigned long end, unsigned int nr_pieces) { struct damon_target *t =3D damon_new_target(); - struct damon_region *r =3D damon_new_region(start, end); + struct damon_region *r; unsigned long expected_width =3D (end - start) / nr_pieces; unsigned long i =3D 0; =20 + if (!t) + kunit_skip(test, "target alloc fail"); + r =3D damon_new_region(start, end); + if (!r) { + damon_free_target(t); + kunit_skip(test, "region alloc fail"); + } damon_add_region(r, t); KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(t, r, nr_pieces), 0); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 DC481306B1A; Sat, 1 Nov 2025 18:20:42 +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=1762021243; cv=none; b=FDOXsr58CzrNzBmgBuqvBFB/zl6VMNA30/DWYnsZ8IG3VGC5L5aOO1A7osLpYmhRFuH9Du8pSsFNnHkCbJJ86iVEhe6mgbZmbjQveOq/sju25RyYChF2hQhSg2WyYsnDaFQ66qTxf2kmkY/dmtKwTD6i9UNACyUJz0KIMIZX9wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021243; c=relaxed/simple; bh=YKKetXWckUNAeNivss353X8s+7x7z2c2pZKrb6m5Vqg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WDGanlAre56GzLFzq8URz3w61DbZroDIsgdxjBzi2uC29ijjNSC27wdJVI4ibteRv/pplPu3w+shxBhOwKpr/xGbyz/zB86JMoZxBBCe/ozVHEfiII7shm05VAXR48qwTOk6kBDSEqtbpTmXUyQ8MhtbXcOS24MvoVb8p9VfH1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PBKwpse/; 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="PBKwpse/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ED08C116D0; Sat, 1 Nov 2025 18:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021242; bh=YKKetXWckUNAeNivss353X8s+7x7z2c2pZKrb6m5Vqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBKwpse/W69Y85fbiyxFTe0Yhn0KF55DLJUWj7U/1BQmCjOjs9/sk7MwkKx2qt5yP 20MSUTKtBNCNfZ+lOjrSwRis54URs5b/7mg+Kfw/rH2hL826ghikSzuGKIirCe+yUp 5+rnCF4THr0Xs0PD50d5TjYTJOlFqPoAkE6A4VEvydg8RtPh+3iIdfpkhfn17Zc5I/ W8DJnV3+sPWBnDxWk59G2mnuEWQCVFbXX/OgS/4mf2k6xoWM0lsFwIjJaQxcxIx7oe em/lD1X9cfs54/iwlOuEo+LAbbcR0j7L/VS1b51U2kaDhOYzX1zWkaJSkcuyXzUEjf UGN5MC4ojfWgA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "# 6 . 7 . x" , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 20/22] mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets() Date: Sat, 1 Nov 2025 11:20:14 -0700 Message-ID: <20251101182021.74868-21-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_sysfs_test_add_targets() is assuming all dynamic memory allocation in it will succeed. Those are indeed likely in the real use cases since those allocations are too small to fail, but theoretically those could fail. In the case, inappropriate memory access can happen. Fix it by appropriately cleanup pre-allocated memory and skip the execution of the remaining tests in the failure cases. Fixes: b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_= set_targets()") Cc: # 6.7.x Signed-off-by: SeongJae Park --- mm/damon/tests/sysfs-kunit.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/damon/tests/sysfs-kunit.h b/mm/damon/tests/sysfs-kunit.h index 7b5c7b307da9..ce7218469f20 100644 --- a/mm/damon/tests/sysfs-kunit.h +++ b/mm/damon/tests/sysfs-kunit.h @@ -45,16 +45,41 @@ static void damon_sysfs_test_add_targets(struct kunit *= test) struct damon_ctx *ctx; =20 sysfs_targets =3D damon_sysfs_targets_alloc(); + if (!sysfs_targets) + kunit_skip(test, "sysfs_targets alloc fail"); sysfs_targets->nr =3D 1; sysfs_targets->targets_arr =3D kmalloc_array(1, sizeof(*sysfs_targets->targets_arr), GFP_KERNEL); + if (!sysfs_targets->targets_arr) { + kfree(sysfs_targets); + kunit_skip(test, "targets_arr alloc fail"); + } =20 sysfs_target =3D damon_sysfs_target_alloc(); + if (!sysfs_target) { + kfree(sysfs_targets->targets_arr); + kfree(sysfs_targets); + kunit_skip(test, "sysfs_target alloc fail"); + } sysfs_target->pid =3D __damon_sysfs_test_get_any_pid(12, 100); sysfs_target->regions =3D damon_sysfs_regions_alloc(); + if (!sysfs_target->regions) { + kfree(sysfs_targets->targets_arr); + kfree(sysfs_targets); + kfree(sysfs_target); + kunit_skip(test, "sysfs_regions alloc fail"); + } + sysfs_targets->targets_arr[0] =3D sysfs_target; =20 ctx =3D damon_new_ctx(); + if (!ctx) { + kfree(sysfs_targets->targets_arr); + kfree(sysfs_targets); + kfree(sysfs_target); + kfree(sysfs_target->regions); + kunit_skip(test, "ctx alloc fail"); + } =20 damon_sysfs_add_targets(ctx, sysfs_targets); KUNIT_EXPECT_EQ(test, 1u, nr_damon_targets(ctx)); --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 F090F2FF655; Sat, 1 Nov 2025 18:20:42 +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=1762021243; cv=none; b=rKiS5QzL8uywTBZoHNhpe3ECrGfAxKCoEdMy15aYTBaVuF6IPhWsIlqD4gcT2SNKTGQEaze1hDAq3QtQ/yTQfPBwZrBs/JP83lKRUj1JWzKB/gK1pWHOIXbDpdf+en/NjnEv+LztI4yw2B+fiZ3I1+yrNyfDbOQ1BDcw4hoGSEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021243; c=relaxed/simple; bh=7DGmc3I+5nR3iT/IUWCpGRBq8NOcMAe9aK8+QNZZPkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uVu5LNtjeLUFhmhCZroczLEX+uQk4nekT6xsCrKlZvBUNydJjetaJtyRs6/aEcS53/U2N4weljkDD/FOXbTw2tMeGplSoFKO3oTGIp/IOfEZZfAsJChO8BDadg6hBKGS+PHChdsdp1bYafr1ty1KFl9YAGkG4JnZNBY+VcD1rk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i9Qs0SVq; 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="i9Qs0SVq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD677C116C6; Sat, 1 Nov 2025 18:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021242; bh=7DGmc3I+5nR3iT/IUWCpGRBq8NOcMAe9aK8+QNZZPkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i9Qs0SVqVhQ+cgTpUUlxG5QlAQukPmjmxt6eZXHcyaU3l9KUJtW09FWDRDcfT0Rr6 9+CFFebpcb2rwBWvOGieJzSUGdHSJOwYvDvyFcqoZOzLTX2qNFaBgTXoR+jkAD15MN r1SNi9xKeePBufxbAMqfuFxfzKTWCtScyMfK6ee6Jo++FdHxttENFVYZa/3JXtdYSf iZzlr3E+xOnNca6wscC0ot5/Mk2SinVlANgjDOIGUwnUlBcNwebF17q9mVUXnBv02b S0j9Gwh+W48r/aC9lIi1VLYMz9MYluQoYZYCfs2q81gx7Vu+rIBFGrruYT8/Tn6mS/ 09N3b7/ZLMuyg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 21/22] mm/damon/tests/core-kunit: remove unnecessary damon_ctx variable on damon_test_split_at() Date: Sat, 1 Nov 2025 11:20:15 -0700 Message-ID: <20251101182021.74868-22-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_at() dynamically allocates a 'struct damon_ctx' object, but it is not really being used in the code other than handling the allocation failure and deallocating it at the end of the function. Remove the unnecessary allocation and deallocation of the object. Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index a91d798caa70..726f593930e7 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -144,20 +144,14 @@ static void damon_test_aggregate(struct kunit *test) =20 static void damon_test_split_at(struct kunit *test) { - struct damon_ctx *c =3D damon_new_ctx(); struct damon_target *t; struct damon_region *r, *r_new; =20 - if (!c) - kunit_skip(test, "ctx alloc fail"); t =3D damon_new_target(); - if (!t) { - damon_destroy_ctx(c); + if (!t) kunit_skip(test, "target alloc fail"); - } r =3D damon_new_region(0, 100); if (!r) { - damon_destroy_ctx(c); damon_free_target(t); kunit_skip(test, "region alloc fail"); } @@ -178,7 +172,6 @@ static void damon_test_split_at(struct kunit *test) KUNIT_EXPECT_EQ(test, r->last_nr_accesses, r_new->last_nr_accesses); =20 damon_free_target(t); - damon_destroy_ctx(c); } =20 static void damon_test_merge_two(struct kunit *test) --=20 2.47.3 From nobody Sun Feb 8 15:58:41 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 91F593090FE; Sat, 1 Nov 2025 18:20:43 +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=1762021243; cv=none; b=geL6ISFVdqpznwZ+kbhEPvlIPxGNKiI7OmVN7Jhp8mI8k3dh/AfTIP/BhZnSTO2WwjoVCFXcrX2V0tseF/wEmmKKwqWZspKu4qAGp+PmjxNU2zeMjbNKtceAO0wc1WeXJlnsIL/XpNurv1mduCr0mISgiJKvqvAn2Hj+aAFh2kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762021243; c=relaxed/simple; bh=tPpDN39ZJmNW8xL/EnZ9l/LC9JHHUFC5Pgu2gGvkODE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=USivZbzIXCC4aiTxK+RbO0/1YoHqKjTeIMwiCWS+SKr2wzAwyCszLRN5+p8K6z22mdTL9SZCHx16Xa+dzwI1BUKmSEcdH/v1xdj56Oy2TFsweQw0snPbmJXKvFVw4U34Lxffz9AQAVoQQzSbdwZMEKPIoxYWF4Ic80PJOEURoc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S9873RHW; 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="S9873RHW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02EF4C4CEFB; Sat, 1 Nov 2025 18:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762021243; bh=tPpDN39ZJmNW8xL/EnZ9l/LC9JHHUFC5Pgu2gGvkODE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S9873RHWW7uv7XCyR9LzUDjbqDMeEfGYpvU15+SUHHYroxynxEdpPSD5v09jmvz3j aYhlJTfu++ETY8+P+/u3etiwe0zaiuDfKD7yjZ8yq/fYP1w20RnuNt0nCArm1cYu0c xf4+3fBTXG5yuUWlrG8j9K7h4CdwGu2cd/8oEBuHfPaQMAj+dPDiYons/irjRS9KSC FOD62F5D6A7WbHAWYYlQlmp63QoAeUWdF/TS1b5C88qOTDI81+Ix5Ou2Ukj0ExOHtd d7pmx+GCnHLlxdMMGxldqSxAZK2VW0XAjYU66qmAcR90/oVla+yuPKlmWJtTbeMy6S p3DBsuqAREXdw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 22/22] mm/damon/tests/core-kunit: remove unused ctx in damon_test_split_regions_of() Date: Sat, 1 Nov 2025 11:20:16 -0700 Message-ID: <20251101182021.74868-23-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251101182021.74868-1-sj@kernel.org> References: <20251101182021.74868-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" damon_test_split_regions_of() dynamically allocates a 'struct damon_ctx' object, but it is not really being used in the code other than handling the allocation failure and deallocating it at the end of the function. Remove the unnecessary allocation and deallocation of the object. Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 726f593930e7..96a4cd489b39 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -267,20 +267,14 @@ static void damon_test_merge_regions_of(struct kunit = *test) =20 static void damon_test_split_regions_of(struct kunit *test) { - struct damon_ctx *c =3D damon_new_ctx(); struct damon_target *t; struct damon_region *r; =20 - if (!c) - kunit_skip("ctx alloc fail"); t =3D damon_new_target(); - if (!t) { - damon_destroy_ctx(c); + if (!t) kunit_skip(test, "target alloc fail"); - } r =3D damon_new_region(0, 22); if (!r) { - damon_destroy_ctx(c); damon_free_target(t); kunit_skip(test, "region alloc fail"); } @@ -290,13 +284,10 @@ static void damon_test_split_regions_of(struct kunit = *test) damon_free_target(t); =20 t =3D damon_new_target(); - if (!t) { - damon_destroy_ctx(c); + if (!t) kunit_skip(test, "second target alloc fail"); - } r =3D damon_new_region(0, 220); if (!r) { - damon_destroy_ctx(c); damon_free_target(t); kunit_skip(test, "second region alloc fail"); } @@ -304,7 +295,6 @@ static void damon_test_split_regions_of(struct kunit *t= est) damon_split_regions_of(t, 4, DAMON_MIN_REGION); KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u); damon_free_target(t); - damon_destroy_ctx(c); } =20 static void damon_test_ops_registration(struct kunit *test) --=20 2.47.3