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: 203232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5407dyc; Mon, 19 Feb 2024 11:45:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+eOqSzjOXkqYdxnZkVlM4iVlKX0RM3m2H0qQVVip8kjG4CSyeS/91OQfOSfNn+DI7R4d5PW+LUYjb2laup6YVzwJaMg== X-Google-Smtp-Source: AGHT+IH6NVA1RGlqBDLNu1xyvPGy2uNNLIvRnCJLgA89pV8/xsuS6x13MWwSsEpvWN8dXfjP2r5v X-Received: by 2002:a17:906:27d4:b0:a3e:b0b4:a83d with SMTP id k20-20020a17090627d400b00a3eb0b4a83dmr1721635ejc.51.1708371946715; Mon, 19 Feb 2024 11:45:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371946; cv=pass; d=google.com; s=arc-20160816; b=KFLlY/ZAgRzQFYwMUhdcQKiQXWI7qVaK/KudWHX000NY0FGfKM51X44AtlKYPpZQz8 x+r/Uhw6oZO69xqfBWXT6JLY2Toa2+55YdN8A1Ipyocz6+J3GPitvocomQ9WsxapdAN1 0HV+39WWrdJNUNWdZU0x6owkaUvsvC8gE5NUJ1zV5ppu8mzqsqaoTNB6qEB+Nc8A9Hx8 ds4+8QrDI6hhdMTtQUCf8ZhLPzpoRhpBB1HWtNNg3nSU2PP6EaKqpKvhtHcOR4GEpyqq aCnu2g9aQZIuvJYNdKzlYygfv9EpQx51Ie4TMI9qVdD6QsCekDhVnRcyRXlE5XAegkXO hwQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=R/p8IGr4o4yj1mgg6arIdwYYqkZ5HnQP0B/yd4p0fUE=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=v/ZhxsH+v7MmmpDuTpjAlnAj40Hkr9FE5fHlnzNllI04G3t777MQK1zcUDcsRxd5o6 eJDWF0cV1jTtOR63ep3U7wHtd+/4CXawfr/ppB4tSLyIT+28EOed68t9tI9MHNdAnUmO N/nCkD8Mc4rLH97T7JauaTIZ61aWcP66Z3YcVR/z9AW+Ci1oXCdP353xw2i05xSpqD9l 6dZTkSBuGtEmwWQMfP4aZXbRVg+iQA6+fOyTHIWe+45eNcV49lpOeV+M+wRtNnXNbt5t vaR5+RAV+Ise3Y2htBvvcqCPJtnzNS1b8NyNZzw0om80cJ+C0tcPlLW69DcohdKFwy1r w+WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jw6EhW1Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gb33-20020a170907962100b00a3e5ad050a5si1857780ejc.983.2024.02.19.11.45.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jw6EhW1Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 578D21F22FC2 for ; Mon, 19 Feb 2024 19:45:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A00F54273; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jw6EhW1Z" 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 6C237524CF; Mon, 19 Feb 2024 19:44: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=1708371880; cv=none; b=H2Gp5wEj2wKf7Pd4CMrdwQr08Kqy/mNPuGtfINQh1kBTRx68NbaD1pFgceywlaEuYlsx8CmENpsZQ6rPEXKCAL7Kg0zDbZGGhMgKC5IySrjxoLUuiWvyu6CqRFOCr4wFzhkros2GUHoPAfAbIZxkzezerPANhUwP4pgqzmSFdfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371880; c=relaxed/simple; bh=D150sO/L6KppSwNTajXy1QJufbQ+UvH1B/ezhNJc/3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rd4cHi/khmHKf8BUDl7ZEkJGWeLEY+ZtJUbFkguoxa+M9FpOldshgvgSn9caTOF/9ftmIRP9JGk+C+V50qPFF4GlrJZ33g8nFWS5bO3tNbDenpVbRMoqF74M1MElTCp2Jtj8F6dlsIO2PgfvAm9YaRdK0tDJpQct7Mqpajk35UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jw6EhW1Z; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357822476346736 X-GMAIL-MSGID: 1791357822476346736 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);