From mboxrd@z Thu Jan 1 00:00:00 1970 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 B0B2E397E99; Thu, 19 Mar 2026 05:22:07 +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=1773897727; cv=none; b=jDYSTbQvMtNUd98lObGIzyurVsrgAJGdKVDhqExqrN5o38lTmyGE6/Gn1DtkKB0DIfrfOHjbkJ+717gMpRhjoZ1l941ybH8AXk+Jnwky6CDmI8oxURUi9ASmzDdAJaQJWNitYRPIBhisyELJb1q73uHFcF7Fqqdkx1yzAuJZgAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773897727; c=relaxed/simple; bh=MqEq3gnpER/1i109FUnzNmYJCrHCG/6rdnfY8eFpkpg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H2vGwqnkqGa/nZ42hRLP9JhIFAsk4rboeoZHl/7w9UDFs/86qlJFc4DtoACjeIX62yONOnPs4j9dMCHQMnyzngXG34tlnVe6+fk2GpRFPR5lHQkBLtpwt91UehoN1OTcBIdvE3Ljh9HBh6yFUoeGjEh2Owt6F/I2/cYis3V5FzY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R3xmC6P6; 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="R3xmC6P6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 751ACC2BCB0; Thu, 19 Mar 2026 05:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773897727; bh=MqEq3gnpER/1i109FUnzNmYJCrHCG/6rdnfY8eFpkpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3xmC6P6OTHd+Fs+mCFy/jqh14jFnG3Fl4q5rjQ2c2rio5VNHnB87XL87/U51kLyb nFxYMDbfULAUqYw2HCA0U5ebdHOsRLEGimnW1d3dRsf0aQvqJKcmjXTsWzbyC0UdZL ldsFPoY6Vnvy4iSeU99JIFEyvIHPWWcNQFSR7Ggl5DrON5/LtpuxRE8s5isI+kj2O4 ev/yAh9ObnSHMXiFlOGBHnC7Byd1MmL4+Bad4KiO1KiR+tfqXBufseSbcauIon5KD5 yWruBU376m3NO9oWFKi5nzwtHZxkEll6vXNu65GvcUTYv6ZomuH5sqP1XCqr134E6l bUvoUggz7NKWg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 02/10] mm/damon/sysfs: add pause file under context dir Date: Wed, 18 Mar 2026 22:21:45 -0700 Message-ID: <20260319052157.99433-3-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260319052157.99433-1-sj@kernel.org> References: <20260319052157.99433-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 Add pause DAMON sysfs file under the context directory. It exposes the damon_ctx->pause API parameter to the users so that they can use the pause/resume feature. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 576d1ddd736bf..7bd42dd8c4a73 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -866,6 +866,7 @@ struct damon_sysfs_context { struct damon_sysfs_attrs *attrs; struct damon_sysfs_targets *targets; struct damon_sysfs_schemes *schemes; + bool pause; }; static struct damon_sysfs_context *damon_sysfs_context_alloc( @@ -878,6 +879,7 @@ static struct damon_sysfs_context *damon_sysfs_context_alloc( context->kobj = (struct kobject){}; context->ops_id = ops_id; context->addr_unit = 1; + context->pause = false; return context; } @@ -1053,6 +1055,30 @@ static ssize_t addr_unit_store(struct kobject *kobj, return count; } +static ssize_t pause_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct damon_sysfs_context *context = container_of(kobj, + struct damon_sysfs_context, kobj); + + return sysfs_emit(buf, "%c\n", context->pause ? 'Y' : 'N'); +} + +static ssize_t pause_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct damon_sysfs_context *context = container_of(kobj, + struct damon_sysfs_context, kobj); + bool pause; + int err = kstrtobool(buf, &pause); + + if (err) + return err; + context->pause = pause; + return count; +} + + static void damon_sysfs_context_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_context, kobj)); @@ -1067,10 +1093,14 @@ static struct kobj_attribute damon_sysfs_context_operations_attr = static struct kobj_attribute damon_sysfs_context_addr_unit_attr = __ATTR_RW_MODE(addr_unit, 0600); +static struct kobj_attribute damon_sysfs_context_pause_attr = + __ATTR_RW_MODE(pause, 0600); + static struct attribute *damon_sysfs_context_attrs[] = { &damon_sysfs_context_avail_operations_attr.attr, &damon_sysfs_context_operations_attr.attr, &damon_sysfs_context_addr_unit_attr.attr, + &damon_sysfs_context_pause_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_context); @@ -1470,6 +1500,7 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx, if (sys_ctx->ops_id == DAMON_OPS_PADDR) ctx->min_region_sz = max( DAMON_MIN_REGION_SZ / sys_ctx->addr_unit, 1); + ctx->pause = sys_ctx->pause; err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs); if (err) return err; -- 2.47.3