Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1335103rdb; Mon, 19 Feb 2024 11:45:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqPfKzy4/owW74IoMbzMxP1ycj+3nZIcCuF94SqxGf6vs4GleMo04kkJzBitXKkXTM5LpY1B4COAP5C6APkTbjQVS32A4FUnP8yoUowQ== X-Google-Smtp-Source: AGHT+IE5SipXWVoJWqTmSkFQbNUzICbM6BO40qb554xDgzBdIg0ODL6aSc+UAZ3Z3HGRNJM3NW3W X-Received: by 2002:a05:6870:ac10:b0:21e:89bc:31a5 with SMTP id kw16-20020a056870ac1000b0021e89bc31a5mr6183636oab.16.1708371909745; Mon, 19 Feb 2024 11:45:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371909; cv=pass; d=google.com; s=arc-20160816; b=nSwGnWDZwLWizc0DD0mdN/WyR4zxAm48PFUQXVBYvMRT4jwcwOccYnm2gIrYAXSk8X Y1TbbNX9jZxF5DTBJH0Nl7v+/u244bXk6piZl7oU0s3Do9EHpsFhCuvGkgjX51CTU1+W nCNW3PR+idNSLURCuqRm4CXoemIRtV3/qsNLgvV2ZDSGyzfJUBYSh3MYZylO22jctXCU TjYzzHDGDTBRUFvHvPdvyVHu34AbKhQFtlKqAgOrNRlLc6YbiGVQ92+qr1Umi2K98nvz CjA98VU7SxWOoBdTMoc46HxodvM7OfgQRNLiewToH0pNrqwvmicJriMtLJYaJazaA9k8 /JaA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m15-20020a63f60f000000b005dcbb6a2cccsi4906982pgh.44.2024.02.19.11.45.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71883-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 42644281195 for ; Mon, 19 Feb 2024 19:45:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B32D535AA; Mon, 19 Feb 2024 19:44:41 +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 Content-Transfer-Encoding: 8bit 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); -- 2.39.2