From patchwork Mon Feb 19 19:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B14C48BC3 for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DA636B007D; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 229AD6B0080; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F0B56B0082; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02A586B007D for ; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CE435A0421 for ; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) X-FDA: 81809580804.23.680BCA0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 2A4B440010 for ; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jw6EhW1Z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371881; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=R/p8IGr4o4yj1mgg6arIdwYYqkZ5HnQP0B/yd4p0fUE=; b=mDltfjX49qQtsjNoyWtf9EENPjgsYXvAyTfFQ213yK5tF0mhP1Svq8+/5mrPcIQC5WKowp JurQPmhz1sl6G3RAS1CXHrrRr4toVcruE933ltfwMIGPtDVhslUOTjULZcgWswEUfyZ2Rd Dh4fpXN7IzTGj3snvODZ0vxgPcJb51s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jw6EhW1Z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371881; a=rsa-sha256; cv=none; b=KmShi6nUBQCD69Qb3TIHO4fgnUczzb5Swiuku2Lzg1FAGOkhIUlxdXdpbWPLD+fbfYHGif ima1XuelGAqsdswaUFM9s2WwnWaTTakgwilyKbpYARawgUMx/6wqEEjnOwro5YzZUu5YyC KCsftR3njuGKTkxYlu6Gfx9MR7ZHQeM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3DA3160F7D; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB99DC43330; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371880; bh=D150sO/L6KppSwNTajXy1QJufbQ+UvH1B/ezhNJc/3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jw6EhW1ZSt+p4B9o5bnE7L9Um41kTj5LlJ11v+SKB5Ded8ERmyZ6Uj6cNq6Pz24hc SSVGzfI+ODvl/iDjlDOa1b4q1K0xicVWz05XrBawu3mwE0yXj6ou25f7N3ILpAP6Dm P1dGWjAGGJXayQ0NbhOx6KJKELZjE/o1FfJduSffxHkiwCDPacNfPB4nORfSoODhNu p05pXuGzzwnuBHRXipFZXIfQ2nsJ208W4Jw+XfWueks3Es1fa2QlK9qHfGTLIEwhm4 iEafNu024SYNb9Lh7hz5l/4pa1BFxHUiyHicSjgD9rdIpsoB8/hWvwrcRhGXsXse17 ENhkkrCF6yh9A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/20] mm/damon/sysfs-schemes: implement quota effective_bytes file Date: Mon, 19 Feb 2024 11:44:13 -0800 Message-Id: <20240219194431.159606-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: g4u4nmskxeib9chp8po1fgfn47ga6gn1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A4B440010 X-HE-Tag: 1708371880-639385 X-HE-Meta: U2FsdGVkX18YeDOWuEV5xpABrC1m/cSkgGmAjHLwyVSLKgVNNBzQxVPmQerzFcrgFOcPqB5aYcBwyMkhFCHssWiTq1ZaB/zlp3ZLXejBT4HwiO7LX7w0oboNDzrcIuNWxbpA0KmHL8pyRgAgCPTdVs64Tme3OdJf7h41IjNo7MiB3jpLvfioFSantK4c+x890N/MclM/tOSCVH3L0901PEvg0gN8lDmr6/vAmxe5+DJfALYvjj0mD6ozir8L5xQFxG1LOVKgteWAPZzaHDOPOWs2k+13nu/PrrXmAB7sqKqDJL4ycPgpimmNSzn4pa4dRpTFEv6z8eqJFpXn+9nbN7sXpck3K/8tYhx3vEM0ZV+N/Azbbs+uuvkjGXiszGAVBBrKJBUpIrWBLDcK6lDglhrXDCyv/194nwfljMEYdPkDTyV3btfg9uV4dyt/0hgEawv03K3AO1Po0bHfx8YUZxEZ5D65FJqhuUgTxZsyw7px0HL4lS6jpUzIgJjwHpk2eQANyIFqI35GA5O70UvXPvs3KGyLwIVFloHVwMlCrFTftkqeA6ujLn4sNDB0Mm8qxwKsJOLPk6cgzLNbSV3dQeLsVHjKmvQd/mHZeJtQTtjp8AXzt4xmyB/uP2nTf00ubAo9BFVTDL2f7HPFNfupuYzaoNLcxmZLGJpFChpI23Cbg9sZKcQXcuPGgZqjpsNO05qCNOwgH0+WrxYoXM2rS4HztPuNdOt5KbYFdqeM+P7WjSEObm/+iNDo1QfY+xFwoxRytvH7w6BdR7TaOu67DWeBRG4YCxZpCU8/IeH0gRNS5ZUWAoL0aHI3pbnxjaw/Z+7a8cYYWaSHI/zJj8YwhxFdTvb2FQogYtL42jF0UP/lOkwJmctbDi+eYon9oqgxviTcysufNXP7Iz0kDIn9/654ZVjXpmVpUz6+pX6ZFgcn16MiqPQwrJRKXLMR8yiJnJvJWhG6sHhYvDrkkkR Jr33aNCQ zILrTkqz01wDGmmcQMCBHgdW4H3CvbPewCQs9It2xQBX2L4e0UklmxsO5FMksPdPH5sbSAyDS1kbPK8kLGso+tf73v+06z/KG34dyXctF5AVVhYoiv1CtAnyghVGexSVlW3UCYEVx/7jIaL9AXw4ZZjVIO5tBVcy/XZbDGOwAKdGGeTlqH5lGkOsv7uKw/UGkSwFNG+b24myQiWKaD/rJVh3jgNm/0jflpt8Fb5S42WCEGQ1hrd+m/La3s5BgjKdJmkuOyIrnFgENqT132nh5Bvk94JVCvBXDmifp X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: DAMON sysfs interface allows users to set two types of quotas, namely time quota and size quota. DAMOS converts time quota to a size quota and use smaller one among the resulting two size quotas. The resulting effective size quota can be helpful for debugging and analysis, but not exposed to the user. The recently added feedback-driven quota auto-tuning is making it even more mysterious. Implement a DAMON sysfs interface read-only empty file, namely 'effective_bytes', under the quota goal DAMON sysfs directory. It will be extended to expose the effective quota to the end user. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index f6c7f43f06cc..dd46b2db5455 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1139,6 +1139,7 @@ struct damon_sysfs_quotas { unsigned long ms; unsigned long sz; unsigned long reset_interval_ms; + unsigned long effective_sz; /* Effective size quota in bytes */ }; static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void) @@ -1252,6 +1253,15 @@ static ssize_t reset_interval_ms_store(struct kobject *kobj, return count; } +static ssize_t effective_bytes_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_quotas *quotas = container_of(kobj, + struct damon_sysfs_quotas, kobj); + + return sysfs_emit(buf, "%lu\n", quotas->effective_sz); +} + static void damon_sysfs_quotas_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_quotas, kobj)); @@ -1266,10 +1276,14 @@ static struct kobj_attribute damon_sysfs_quotas_sz_attr = static struct kobj_attribute damon_sysfs_quotas_reset_interval_ms_attr = __ATTR_RW_MODE(reset_interval_ms, 0600); +static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr = + __ATTR_RO_MODE(effective_bytes, 0400); + static struct attribute *damon_sysfs_quotas_attrs[] = { &damon_sysfs_quotas_ms_attr.attr, &damon_sysfs_quotas_sz_attr.attr, &damon_sysfs_quotas_reset_interval_ms_attr.attr, + &damon_sysfs_quotas_effective_bytes_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_quotas);