From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f42.google.com (mail-pj2-f42.google.com [74.125.227.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA2863DDAFB for ; Sun, 20 Sep 2026 12:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789907088; cv=none; b=lFOkEdA3A64PMBydZtCV+l+Gw17M4+ElrPxO7RbRflDMe/3GHXo2GGChwtjmap4DX1thoKU0zyUkTm7f3Azc2tbp/xVAr4h26GJQ7XO0HizkdEYbFhe4uvT1z2cWxHj9TiMBSrgCQKuEtR3iY3zkgx/J19pXRvBi4CoH49+8PCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789907088; c=relaxed/simple; bh=rmWR38P9oV+3YYhnLaf+Dq+xPZyqqx+mXZBXqMUox8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I2PszaIKwR9pjuhNERIItP2+8GtZYsV/gegQWr8gXLHJwyQnVbGIFnKQ29SxCUGKTxx7mpegyVtnWng7hGQwM61BPN6tnA66E2GKpbV2WI5Zffpnhu1jsApwTbn7ZT5FeCkbyxgL1DbG2SjAKUkk/+zQewbkjdSxR+0EBpQeIh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=llYkJpeP; arc=none smtp.client-ip=74.125.227.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="llYkJpeP" Received: by mail-pj2-f42.google.com with SMTP id 98e67ed59e1d1-398cb5615deso2536197a91.3 for ; Sun, 20 Sep 2026 05:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789907062; x=1790511862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NtyjzrgYhOa3bpnnzl8J/NBn02c098QytsBeznFYa9A=; b=llYkJpePvS4ewE5aDOXji8GvTCarYPh/amN+6WC6/bSQpPb0YBTyrSQydROM9K6sD4 3YO6utO0zMLERCV2qkwm1IPxYkwkr/YAqD54MmWxXEAqRvlPUjiPX5Fj/9WP1qr6/R8M MOlGLi7vbRgaxSIWpvXWsxlQXr+HWVgwcIMpusueZarJltjC+dzLce1F5uNc8EYNRHmL N9NiQ917hoDpGqSAWjNeKI3cWJXsEAStlp7FRy544Tc/46GdPWsYd3tGl+vVWROjieNn X8YFeUyh89qP2s7cCe5lgOD41jJbjyEn4eHWYM9NzmyxYLv4D1VBgn/pPqFZ8BuyJTJ3 WjIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789907062; x=1790511862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NtyjzrgYhOa3bpnnzl8J/NBn02c098QytsBeznFYa9A=; b=XDnWVG9/CN2dP6E439UOBZDEh+fXpNmZP+Roat0W2/kEgWi9PiVQjvRkN38hIr6KWl BYh44U0Sj9Q9rhTqadl9ZaPjc6auQDy+A8SeArf7YmuCF33wdRq1EAM1rfXm3zUTh1vZ cb1lYhynQND2GpGXTr2pMusSKBFTmfBcuUTBHqBJjl23oSMxl8TMC0nTziW2UqgpyNhK e1YmjeiOdemfcbnP6yNVyHIJP69zVpN8N7proT2pn5tKaaEVPdoIsPrHHmLtEkzt+vn4 +IWBuaKwS7/haLZThev6ga3Jcvu4YCYk7inuD+jPKS40g3oIKjOCn7id6ugb21gZOPW5 CrSQ== X-Forwarded-Encrypted: i=1; AKwUvBx1NxEkYkUowv0jRnpxS9Obj9G76YsdLAkukcSFotafU7yS2YnKIVqBbgShs9pMypFId+BxBT5XD27tfFg=@vger.kernel.org X-Gm-Message-State: AFuF++lHjPEXF4Q7V+/dwYI3DDM5HHy8ic+dS2gN1ArgXnp2V6Bjb0Mm 7AeDdBmZcaLz29IXtK93qN7lnyt/Z0VK/WAUiUNby7QiNTpaYamZiyU= X-Gm-Gg: AYBFou2lfAExDdRWxYxeSj72QOGEoVN4CT779Ke5rx/UTghBZDbfGu2g33Vkj8ZQVhV EK1TavWMMLWeWuTQntBnrXwgAlBhxl47Id/kQxMsL7BNwvaJKY1g0vOVKhzaK8tmVMxMiUs+bFA xy2D5uhvFEEE60YLegrVVWaPcni5j7NwqBKE2O27KAvFSUkGzZtFBce/824GRjvsjeZXRexhy+/ mQrwZHK3rDNaYfSMLKQyZUYrwl0pecSg14VPR7R9yrIASL32hZhwz7W/7vFCBZHRzWjVM6coUya eDvIXc9hqKfN3rB1DGsXi5a7i15MMGDO+QOG5C98zRor7KMaOtg8yvaGsjjCR+RbIxBCYGwao3A 9B5g2rkd0M1XXWj/iifZRvcYo2Ss0UFm4cO/+UoaQp+H+VUXoocuKS53RMsXjrJTjBKaYK4bKZB Uj4m8ryi5XATJOzw+whaJNsZyks6WvqaXyRlAIlEuxy4oLDdJGHs54qp32TRvFB0VNIcM81d92i sIB6lV/azDKWD0D1MmfP+GKR8U= X-Received: by 2002:a17:90b:3a81:b0:39e:6a82:afd9 with SMTP id 98e67ed59e1d1-39e6a82bbe2mr6880094a91.43.1789907062475; Sun, 20 Sep 2026 05:24:22 -0700 (PDT) Received: from ydg-Zenbook-14-UM3406GA ([2001:2d8:7f00:8c85:e0d6:4b87:c472:c9ae]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-39e6cae997csm8753943a91.11.2026.09.20.05.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2026 05:24:22 -0700 (PDT) From: Donggeun Yoo To: sj@kernel.org, akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, donggeunyoo.kernel@gmail.com Subject: [PATCH v3 2/2] mm/damon/tests/core-kunit: test the temporal tuner's size quota conversion Date: Sun, 20 Sep 2026 21:24:11 +0900 Message-ID: <20260920122411.610213-3-donggeunyoo.kernel@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260920122411.610213-1-donggeunyoo.kernel@gmail.com> References: <20260920122411.610213-1-donggeunyoo.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit damos_goal_tune_esz_bp_temporal() encodes the size quota in basis points, so the conversion is exact only up to ULONG_MAX / 10000. Pin the three sizes around that boundary: the largest one that fits, the first one that does not, and ULONG_MAX. Signed-off-by: Donggeun Yoo Reviewed-by: SJ Park --- mm/damon/tests/core-kunit.h | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h index 5ff0436c58441..a0604788bc638 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -1929,6 +1929,53 @@ static void damon_test_rand(struct kunit *test) } } +static void damos_test_esz_goal_temporal(struct kunit *test) +{ + struct damos_access_pattern pattern = {}; + struct damos_watermarks wmarks = {}; + struct damos_quota quota = { + .goal_tuner = DAMOS_QUOTA_GOAL_TUNER_TEMPORAL, + }; + struct damos_quota_goal *goal; + struct damon_ctx *ctx; + struct damos *s; + + ctx = damon_new_ctx(); + KUNIT_ASSERT_NOT_NULL(test, ctx); + + s = damon_new_scheme(&pattern, DAMOS_STAT, 0, "a, &wmarks, + NUMA_NO_NODE); + if (!s) { + damon_destroy_ctx(ctx); + kunit_skip(test, "scheme alloc fail"); + } + damon_add_scheme(ctx, s); + + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); + if (!goal) { + damon_destroy_ctx(ctx); + kunit_skip(test, "quota goal alloc fail"); + } + goal->current_value = 0; + damos_add_quota_goal(&s->quota, goal); + + /* The largest size quota the basis-point conversion can hold. */ + s->quota.sz = ULONG_MAX / 10000; + damos_set_effective_quota(ctx, s); + KUNIT_EXPECT_EQ(test, s->quota.esz, ULONG_MAX / 10000); + + /* Any larger one saturates instead of wrapping. */ + s->quota.sz = ULONG_MAX / 10000 + 1; + damos_set_effective_quota(ctx, s); + KUNIT_EXPECT_EQ(test, s->quota.esz, ULONG_MAX / 10000); + + s->quota.sz = ULONG_MAX; + damos_set_effective_quota(ctx, s); + KUNIT_EXPECT_EQ(test, s->quota.esz, ULONG_MAX / 10000); + + damon_destroy_ctx(ctx); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -1965,6 +2012,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_is_last_region), KUNIT_CASE(damon_test_walk_control_obsolete), KUNIT_CASE(damon_test_rand), + KUNIT_CASE(damos_test_esz_goal_temporal), {}, }; -- 2.53.0