From nobody Thu Apr 9 14:56:47 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 29F5531E833; Sat, 7 Mar 2026 19:42:27 +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=1772912547; cv=none; b=QyR8OzRkPwZuCBsKAPdpBPRr0W1NPltr/fCZ0Mu6g5oWhDY2ylSFlQ6mx6yoj3NRKqoj+agB/2MqzrUscgqYOAkGH4Tbna9uTJ3JHOKLPgZFdjapkxHprmUop8yuWrJT9WUXf3qvpSq5poIsec5ZKBBk0v4oGBI8E6kiD6Z/Jz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772912547; c=relaxed/simple; bh=AJWquAe6BG8YHnrQ8aXuxdUfziQhpzCbJ1zdbrFuHTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=miePJ4+gfeFMNWS/RD87AX3rFWUxYRIBk1Y0CAiKAsAoqBj2NbnHHYPLO2TGEH/9C89DU+4TsOLPFjPK2ZkBfU0RJU3/JY5+gSWgM3AJDlqwkzteluRehgQLgyGgzOJ+Haamieh6AuSXFxhHnnvdQsR7DUjPHmYAHayfDWrp0u0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hHL0zZ0T; 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="hHL0zZ0T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B72E6C2BC87; Sat, 7 Mar 2026 19:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772912546; bh=AJWquAe6BG8YHnrQ8aXuxdUfziQhpzCbJ1zdbrFuHTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHL0zZ0TvAHNnHQ7Cx8FggEW9UvgVWE6BVsBXZwT60K2Z8O1FwYY3Pym8SbI1gYtu xdvlKOSPZRT6iZZrqinbtJZlAhWko57Z1GwX/inx0BJxQqSupQ+3mP7OzkILA7tW5p U472oBC98UgOEoKmsg5vxmtr/JI610fktLoLqtScM8MIof5ghrMqHdDlamRm8wJtuW qWizXPYVxtmj2Pt7AXmB5SKdWV+qzCi/cjBkkk45HJLUBdAxI70UerT0oxZI2ec9Bp 6CidYja03cW/p+ZsEsl4jWhFfkXg1bUexTzIXphxBZhgi7eFqfiWKLOkIiEsSt1XU9 Sa6TLm0CSKJTg== 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 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx() Date: Sat, 7 Mar 2026 11:42:20 -0800 Message-ID: <20260307194222.202075-2-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260307194222.202075-1-sj@kernel.org> References: <20260307194222.202075-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" Add a kunit test for confirming the change that is made on commit c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz") functions as expected. Signed-off-by: SeongJae Park --- mm/damon/tests/core-kunit.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 44a983fca9501..65181c6dac1b4 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -1060,6 +1060,27 @@ static void damon_test_commit_target_regions(struct = kunit *test) (unsigned long[][2]) {{3, 8}, {8, 10}}, 2); } =20 +static void damon_test_commit_ctx(struct kunit *test) +{ + struct damon_ctx *src, *dst; + + src =3D damon_new_ctx(); + if (!src) + kunit_skip(test, "src alloc fail"); + dst =3D damon_new_ctx(); + if (!dst) { + damon_destroy_ctx(src); + kunit_skip(test, "dst alloc fail"); + } + /* Only power of two min_region_sz is allowed. */ + src->min_region_sz =3D 4096; + KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), 0); + src->min_region_sz =3D 4095; + KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), -EINVAL); + damon_destroy_ctx(src); + damon_destroy_ctx(dst); +} + static void damos_test_filter_out(struct kunit *test) { struct damon_target *t; @@ -1316,6 +1337,7 @@ static struct kunit_case damon_test_cases[] =3D { KUNIT_CASE(damos_test_commit_pageout), KUNIT_CASE(damos_test_commit_migrate_hot), KUNIT_CASE(damon_test_commit_target_regions), + KUNIT_CASE(damon_test_commit_ctx), KUNIT_CASE(damos_test_filter_out), KUNIT_CASE(damon_test_feed_loop_next_input), KUNIT_CASE(damon_test_set_filters_default_reject), --=20 2.47.3 From nobody Thu Apr 9 14:56:47 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 768BA38F244; Sat, 7 Mar 2026 19:42:27 +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=1772912547; cv=none; b=U2bdQ7LE/gikXdB7wiz3NnZA1ODZZfhxuTS8c9T/tB7Gi6eru1R5e/8+DYBp5KEc2OKGk83XtD3Hfsf3yGXEMT51ePR73GHTlTUAGKEtU2AnRvW4y4FqakEuJR6kVRhpg2d3hyvsmU7pcmbJNDIpXwThPZLLtAY0rSh7L1JJKv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772912547; c=relaxed/simple; bh=hW/2ycay+HzENCaHwC79wBirLF865EtYyfXIYZ2Fx5U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q+1a6VaEOm8c8Q8BS/+R2fWYDN/7OCbEtbC5jqAGIlmZJtKrS4WmyCm4JR8cEC0ndHBWuF5DFSG5EdJ6fsDuZ/W9vwTc6GJq6US9k3SmyVphwwXbKotLYm7KeaS8h2ueX9E7Obv4mEoZNumXuIbhYN4RwwhiekAS6tPa44J4LVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cxcdUQH0; 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="cxcdUQH0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 115ABC19423; Sat, 7 Mar 2026 19:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772912547; bh=hW/2ycay+HzENCaHwC79wBirLF865EtYyfXIYZ2Fx5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cxcdUQH0a72LRUKSuKr2PQIYUV7QCuuqMbyh0lvh+rbp4NC15TkcqN7yqbsEiNNdW UyC3v6strUjJ6vR7fJFz+JmYgiXuyJ859bS4erZvLJ1Bc9SHn9Az3SutHOxiyAUiO/ 53e5x7bHFeoPboFbdotMv3aKrkbVBl5Igi6hJSb5nLKbc24BohDnqK28AO3dm2ZLSI nzLAtE7QgfWRFdIlqYQneMIB7cUyB93R/V1oWqKdIg6D07IoHfqGpzCoYSRKnMGsKp cFWDG5glsciRKnAnPBe7ZZM5dnVlT9Fzk7Zq+5UVpUQ9+lEh5zcfeWL3M2eY2QYL3k SbZHA3hgnOFKA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , "Liam R. Howlett" , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit Date: Sat, 7 Mar 2026 11:42:21 -0800 Message-ID: <20260307194222.202075-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260307194222.202075-1-sj@kernel.org> References: <20260307194222.202075-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" The min_region_sz is set as max(DAMON_MIN_REGION_SZ / addr_unit, 1). DAMON_MIN_REGION_SZ is the same to PAGE_SIZE, and addr_unit is what the user can arbitrarily set. Commit c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz") made min_region_sz to always be a power of two. Hence, addr_unit should be a power of two when it is smaller than PAGE_SIZE. While 'addr_unit' is a user-exposed parameter, the rule is not documented. This can confuse users. Specifically, if the user sets addr_unit as a value that is smaller than PAGE_SIZE and not a power of two, the setup will explicitly fail. Document the rule on the design document. Usage documents reference the design document for detail, so updating only the design document should suffice. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 28d932ceaf7ed..29fff20b3c2a9 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -150,6 +150,8 @@ address on the given address space. Support of ``addre= ss unit`` parameter is up to each operations set implementation. ``paddr`` is the only operation= s set implementation that supports the parameter. =20 +If the value is smaller than ``PAGE_SIZE``, only a power of two should be = used. + .. _damon_core_logic: =20 Core Logics --=20 2.47.3