From nobody Wed Oct 8 10:00:00 2025 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 F2E3623958D; Sun, 29 Jun 2025 20:14:47 +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=1751228088; cv=none; b=U0Rvjq8kXsT0kuLcUGCLQ4e/QBB8aw/l/+b2Di8ADTmsWCdXg5Zi4c0uGnn/qwOJvbnmOLnvpuiPt3C+ebyfSmUAQpAkFaaAz1wyzwJfGOBO4EiO9hRWrbnm+XD8A8lzXz0tMId/13vho0cZ5gnpkzJM0RN1u+6oHCAox7DKxbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228088; c=relaxed/simple; bh=MU2ihuhRbcRf1fDg3XPwZVg/5ZSe+hiAlUpj1S6bhJ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WrrGV03a1RuXaq/UZLMT54I5RPYTz/d2apP7MW+L47sOAHMzMYgq4nYqe8gcx/0FYcN1l96vRzgcPBxlYNwx4YDJtlL9pUbRCQA1hcWizxN42sYP4JsuLOd0OyVYhvg0Ec4cra1Wa1idLJqN07JWQljnLMpHLNSH/S3KrEFDE70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lXMIQhz8; 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="lXMIQhz8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64CF6C4CEEB; Sun, 29 Jun 2025 20:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228087; bh=MU2ihuhRbcRf1fDg3XPwZVg/5ZSe+hiAlUpj1S6bhJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXMIQhz8xwv2iKYzuyO6NqQHPvp3tlMkOsUXw5R/QGyqAl2iAlN4JIEMU8GMeQMJY ukicEefMFlMqdhHowBFKTGzsRhv6b9txOfBsp77unrsIcLL61fr/kqVpumaHJtqoty eMJdXnWCWlU+zQzgFZv2p+F0ysPLTtkTvLprxaUFP/oILF0yh1kpHnISwpQAYL/1xw GBj0GDJBc3fGIwDLtin/lM6WY1pHk+Dpa+6CvqRWc0ERxRTbPYUItmy6YwBllqvIcy Q/9jRrVCdODH6O4+2AVo0WZSMKuDWsmCPAYGzntR4o5SrG/caK/0QYt4eGY9uMHIRl cZYKJmA7wSRFw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 1/6] mm/damon/core: introduce damon_report_access() Date: Sun, 29 Jun 2025 13:14:38 -0700 Message-Id: <20250629201443.52569-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" DAMON core layer asks operations set layer about past access information, on core layer's schedule. In other words, core layer "pulls" the information from the operations set layer. This is problematic for a case that the operations set layer have no time and space to save the information until the core layer queries. Add a new DAMON API function for reporting identified data accesses to DAMON, on the identifiers' schedule. In other words, it lets the operations set layer to "push" the information to the core layer. The function internally uses mutex, so reporting kernel code should be safe to sleep. Signed-off-by: SeongJae Park --- include/linux/damon.h | 21 +++++++++++++++++++++ mm/damon/core.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 6370cf44486f..a2198909c903 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -104,6 +104,25 @@ struct damon_target { struct list_head list; }; =20 +/** + * struct damon_access_report - Represent single acces report information. + * @pid: The PID of the virtual address space of the address. + * NULL if it is of the physical address. + * @addr: The start address of the reporting region. + * @size: The size of the reporting region. + * @nr_accesses: Number of detected accesses to the region. + * + * @pid could be stale, and hence shouldn't be de-referenced. + */ +struct damon_access_report { + struct pid *pid; + unsigned long addr; + unsigned long size; + int nr_accesses; +/* private: */ + unsigned long report_jiffies; /* when this report is made */ +}; + /** * enum damos_action - Represents an action of a Data Access Monitoring-ba= sed * Operation Scheme. @@ -961,6 +980,8 @@ int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); int damon_call(struct damon_ctx *ctx, struct damon_call_control *control); int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control); =20 +void damon_report_access(struct damon_access_report *report); + int damon_set_region_biggest_system_ram_default(struct damon_target *t, unsigned long *start, unsigned long *end); =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index ea2a17b2dee7..b54ed91f2dce 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -24,6 +24,8 @@ #define DAMON_MIN_REGION 1 #endif =20 +#define DAMON_ACCESS_REPORTS_CAP 1000 + static DEFINE_MUTEX(damon_lock); static int nr_running_ctxs; static bool running_exclusive_ctxs; @@ -33,6 +35,11 @@ static struct damon_operations damon_registered_ops[NR_D= AMON_OPS]; =20 static struct kmem_cache *damon_region_cache __ro_after_init; =20 +static DEFINE_MUTEX(damon_access_reports_lock); +static struct damon_access_report damon_access_reports[ + DAMON_ACCESS_REPORTS_CAP]; +static int damon_access_reports_len; + /* Should be called under damon_ops_lock with id smaller than NR_DAMON_OPS= */ static bool __damon_is_registered_ops(enum damon_ops_id id) { @@ -1403,6 +1410,34 @@ int damos_walk(struct damon_ctx *ctx, struct damos_w= alk_control *control) return 0; } =20 +/** + * damon_report_access() - Report identified access events to DAMON. + * @report: The reporting access information. + * + * Report access events to DAMON. + * + * Context: May sleep. + * + * NOTE: we may be able to implement this as a lockless queue, and allow a= ny + * context. As the overhead is unknown, and region-based DAMON logics wou= ld + * guarantee the reports would be not made that frequently, let's start wi= th + * this simple implementation, though. + */ +void damon_report_access(struct damon_access_report *report) +{ + struct damon_access_report *dst; + + /* silently fail for races */ + if (!mutex_trylock(&damon_access_reports_lock)) + return; + dst =3D &damon_access_reports[damon_access_reports_len++]; + if (damon_access_reports_len =3D=3D DAMON_ACCESS_REPORTS_CAP) + damon_access_reports_len =3D 0; + *dst =3D *report; + dst->report_jiffies =3D jiffies; + mutex_unlock(&damon_access_reports_lock); +} + /* * Warn and fix corrupted ->nr_accesses[_bp] for investigations and preven= ting * the problem being propagated. --=20 2.39.5 From nobody Wed Oct 8 10:00:00 2025 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 BB60123B627; Sun, 29 Jun 2025 20:14:48 +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=1751228088; cv=none; b=cLFZsIOLP2iS8MMTlvEZon3NRVbalJ4XWyqamOGSX66nNkOnqoIAB9H5nlCEyrxziXWs9F5P3bRyoGpfaHxZoCmXiGRAbMAj7sPtYWnmtqAYpBYsZdDB2KcY1vX+aaT7OZsFgd+2BcSPEwa4PCGvkfWDZOTbB3J+0alul4bRsUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228088; c=relaxed/simple; bh=WPdxO+e8ILol8xOVqVupBv8sHR3wPOu1sMz1xt3HWIM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l+pLdS3pEwRKs2FJ5cwBwX5IZqODKqDLR1eglFCgmoS/MW3NgQ+6BEAxNoTxAcEXAJBBoGCzrldITa+PJ6TTMCx7xis4dIhD7dIaGbYWLUUx4BV3Cs5nRu7grnOqLIlwl0NFxbeI85K9hfXVJaoJDgwZtMm/BemsyGmfpKXeeVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=th3ve3rG; 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="th3ve3rG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71BF5C4CEEB; Sun, 29 Jun 2025 20:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228088; bh=WPdxO+e8ILol8xOVqVupBv8sHR3wPOu1sMz1xt3HWIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=th3ve3rGsg71OhvNGnagGF2Jf6YZzJOTamWxjviSTICoVOZ0I31Z02ityymlMSnbc IqVYAHRn1PeWkuYx2S+WgZ6bwNfv9VAPcpLcWDgqu/lYGS5FYAtpPk9VtzDY80xEZX USoM89llEEnEG4DcJtZVV03901ObkOcaAlg/tuMLrmJhmTyA5VI4H4f8WyPcn3P0ef 7F6pvuzotOUHqyLC8Q9GnbegMBSz0cmKlcuJ8WsLxKy6AgiM3wkR4vqTErDoea6Td6 OAMmgDQIr+fsg0hvykFrtvdr8TpP95lZSuBfc2VUyR9h2tl/u22aEY5r7SR2uIAcmt alNXieidk3mgg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 2/6] mm/damon/core: add eliglble_report() ops callback Date: Sun, 29 Jun 2025 13:14:39 -0700 Message-Id: <20250629201443.52569-3-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" Not every reported access information will be eligible for all DAMON ops and target. For example, virtual address access report will be not eligible for 'padr' ops, or monitoring targets for a process that different from the process for the repor. If it is for monitoring accesses from specific CPU or write, reports from other CPUs or reads should be ignored. Add operations set callback for this report eligibility checking. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index a2198909c903..9ec40ce7dde0 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -592,6 +592,7 @@ enum damon_ops_id { * @update: Update operations-related data structures. * @prepare_access_checks: Prepare next access check of target regions. * @check_accesses: Check the accesses to target regions. + * @eligible_report: Verify an access report for a target. * @get_scheme_score: Get the score of a region for a scheme. * @apply_scheme: Apply a DAMON-based operation scheme. * @target_valid: Determine if the target is valid. @@ -618,6 +619,8 @@ enum damon_ops_id { * last preparation and update the number of observed accesses of each reg= ion. * It should also return max number of observed accesses that made as a re= sult * of its update. The value will be used for regions adjustment threshold. + * @eligible_report should check if the given access report is eligible to= be + * used by this operations set for the given target. * @get_scheme_score should return the priority score of a region for a sc= heme * as an integer in [0, &DAMOS_MAX_SCORE]. * @apply_scheme is called from @kdamond when a region for user provided @@ -635,6 +638,8 @@ struct damon_operations { void (*update)(struct damon_ctx *context); void (*prepare_access_checks)(struct damon_ctx *context); unsigned int (*check_accesses)(struct damon_ctx *context); + bool (*eligible_report)(struct damon_access_report *report, + struct damon_target *t); int (*get_scheme_score)(struct damon_ctx *context, struct damon_target *t, struct damon_region *r, struct damos *scheme); --=20 2.39.5 From nobody Wed Oct 8 10:00:00 2025 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 3894923C51B; Sun, 29 Jun 2025 20:14:49 +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=1751228090; cv=none; b=lIybYEUa5UyZhXdNC85L8fKrxTVI3NrkslBiETNIh7MyJAyzFW5k8M2kDGDAu3w4f4g901EZ6gQlq9wzQRFgRMPYU5PH1wfPrXgguEf6f3Df0TrnDsJto6lvKp9bL6vgsIg7Rs1Ia5eHmq1C2MzPxdWTI40MSPxW9ZM0cnwvf74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228090; c=relaxed/simple; bh=mDWuVxXJ4aMqmgAerywNkRA8beEUvDecOP2ZcDOEVbE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f3pVSgLRTleav7BLbeFB+YpWw2rKlS0P2cVANAA6MAhfgBdolVYhKaQp6DHUtFX+CehNzm8LViLd2Ha1kD571TlqBcG+rrjMHrzfMlLFDvCSPw04X9uOEuaikqt7JBsiarlgcqdxTuFuQPeJ0OkiMwUmpy/RsA168FEdDGKuOy8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YgwmRQ4o; 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="YgwmRQ4o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89743C4CEEB; Sun, 29 Jun 2025 20:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228089; bh=mDWuVxXJ4aMqmgAerywNkRA8beEUvDecOP2ZcDOEVbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YgwmRQ4oNhfzfFDiJHFGVTzyKosuM3x0W/IzFPslQOBcdymUZyOKMnETQXHZBBMOv MWIsy882JWriU8dYfMmmkTnHKS2dakwp85zzx8NzngbzFhLPsKFZbw9jmX+ZuXAi4Y eUAO1KRXBdxyIHO00lYNrH2QHe6GORMPDO/E/6Lv5gZmlxwQzrUcB1PmtZAs3OWXle K+7GFOsnsmD3dPz6ceT51X/PXt1F/qVAFvDu/ZOdEsVxdE/jBSnuxaVLfGB7WajabW USrDR6tV6+B46HLFblzgwFrZVjLBKhOQyLKs+EsSzoPmTt6gjToN7gTpjyGj43cagt 4oSdTIbRSTo8w== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 3/6] mm/damon/core: check received access reports Date: Sun, 29 Jun 2025 13:14:40 -0700 Message-Id: <20250629201443.52569-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" Reported access information is only saved in the core layer's internal data structure. Those are not really being used for final monitoring results. Update core layer access information (DAMON regions) using the reported access information. Signed-off-by: SeongJae Park --- mm/damon/core.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index b54ed91f2dce..59567d79af99 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2472,6 +2472,46 @@ static void kdamond_init_ctx(struct damon_ctx *ctx) } } =20 +static void kdamond_apply_access_report(struct damon_access_report *report, + struct damon_target *t, struct damon_ctx *ctx) +{ + struct damon_region *r; + + if (ctx->ops.eligible_report && !ctx->ops.eligible_report(report, t)) + return; + + /* todo: make search faster, e.g., binary search? */ + damon_for_each_region(r, t) { + if (report->addr < r->ar.start) + continue; + if (r->ar.end < report->addr + report->size) + continue; + r->nr_accesses +=3D report->nr_accesses; + } +} + +static void kdamond_check_reported_accesses(struct damon_ctx *ctx) +{ + int i; + struct damon_access_report *report; + struct damon_target *t; + + mutex_lock(&damon_access_reports_lock); + for (i =3D 0; i < damon_access_reports_len; i++) { + report =3D &damon_access_reports[i]; + if (time_before(report->report_jiffies, + jiffies - + usecs_to_jiffies( + ctx->attrs.sample_interval))) + continue; + if (report->pid && !damon_target_has_pid(ctx)) + continue; + damon_for_each_target(t, ctx) + kdamond_apply_access_report(report, t, ctx); + } + mutex_unlock(&damon_access_reports_lock); +} + /* * The monitoring daemon that runs as a kernel thread */ @@ -2518,6 +2558,7 @@ static int kdamond_fn(void *data) kdamond_usleep(sample_interval); ctx->passed_sample_intervals++; =20 + kdamond_check_reported_accesses(ctx); if (ctx->ops.check_accesses) max_nr_accesses =3D ctx->ops.check_accesses(ctx); =20 --=20 2.39.5 From nobody Wed Oct 8 10:00:00 2025 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 246B023D2BB; Sun, 29 Jun 2025 20:14:50 +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=1751228091; cv=none; b=hzxQq6GVSP/UxszuIz3vz5vhkstEvIo5XPWnHNaumJEodLowWhhWAwQf86HXzeJhgVrBLtgKheNS9ai59vgY73IptLy+u4XG/rwgAeYw98NL3pHjjzdv2r5Zeucw00WSfGb5CXhrgCS9JJJfqesCTD8J2vRYYHidc9FaIANiX2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228091; c=relaxed/simple; bh=ChHDm1fhhH9qTucGJ/qQGn2czoRDZDNS8D5pXkMCn7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oFpgAQYtctzcGLMcLzq3LeXl4b6TxFpy0oJLBziO1DOlHGvu4J5cmgunTEa74eNefZ9z3Ym32lqgL4ybMQsKcsaUqHDiiR1uPrH/6q1rS9z8ZgJk9XcJ4tr3Ais7E/NtBFt4g8cIy+q0ySs0U0PS6SMGK8AAnS5Hto9+nTuKicI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZqjPXFTW; 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="ZqjPXFTW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98A9DC4CEEB; Sun, 29 Jun 2025 20:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228090; bh=ChHDm1fhhH9qTucGJ/qQGn2czoRDZDNS8D5pXkMCn7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqjPXFTWPDbcblMOIE6Sgw4srJbWNmKY2Il9NivI2Tb8cpHUU4kevV6PPYG2gZXZj iKnY3I38jvznAq/K6WkB1KEKsGwiSFiSe3afTclE7IUa6Xz/YZhgs/U/kRCY5zSKYw 3xz7vbdJFcrJNJaGLo/Y9/KmUP/ScbI5gmqcwGWjSiaXvBG3N7vjnFSXiR8HYoyu9I f4ar1rWG5ov/UaTQCKlFQyjXXN6z5ND98qheqQZdJ9WlCpVqkt+gyRpB38RWWEPq01 Zj0FDQfsAaohsspYSZBq7cH5BCZQgwHChxCihwRLqVJr1yCUCDQc6+UGN42Nq7tI6x mm/0Ys99QncmQ== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 4/6] mm/damon/vaddr: impleement eligible_report() callback Date: Sun, 29 Jun 2025 13:14:41 -0700 Message-Id: <20250629201443.52569-5-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" For [f]vaddr DAMON ops, access reports for virtual address space of a process that different from that for a given DAMON target shouldn't be used. Implement an eligible_report() callback for [f]vaddr that does the check. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 46554e49a478..9970f95585ed 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -610,6 +610,12 @@ static unsigned int damon_va_check_accesses(struct dam= on_ctx *ctx) return max_nr_accesses; } =20 +static bool damon_va_eligible_report(struct damon_access_report *report, + struct damon_target *t) +{ + return report->pid =3D=3D t->pid; +} + /* * Functions for the target validity check and cleanup */ @@ -710,6 +716,7 @@ static int __init damon_va_initcall(void) .update =3D damon_va_update, .prepare_access_checks =3D damon_va_prepare_access_checks, .check_accesses =3D damon_va_check_accesses, + .eligible_report =3D damon_va_eligible_report, .target_valid =3D damon_va_target_valid, .cleanup =3D NULL, .apply_scheme =3D damon_va_apply_scheme, --=20 2.39.5 From nobody Wed Oct 8 10:00:00 2025 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 396E923ED63; Sun, 29 Jun 2025 20:14:51 +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=1751228092; cv=none; b=tlD+gD3i/AyTNZTBI70yVHlHh/yOEicfJRtUjBliAmwZmIuqa2Vmyii/LWz2ff7y9JPkxttoRGVzuXRqaxjwmJRxEkDvQNPyjHVBQAgmsDtGL3BOAmJ6/HEhe4XyC3Pz6GmiOSw6hPvi2vxnSIC4NmgN7QokZVzt7L5hgsVyjVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228092; c=relaxed/simple; bh=abx9lNh1gFvopZEIiGDT9OF9wCpwby92bKkdaKzWw20=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qQJP1xEXCM5sXE2dV5/hKJ10PP1Pu6YEi4VFtM2rpwTqrPZ2uKaVIb7KS9B5s9wkuU5qfE0+2MSfYwMrSUv3IsXJAziD2bLz7UoHu1FiaRlv1OsgTBVMzoq/PmJi9ttO3wT5IrClB2M/tsth+llfICuEF7rFpSvT5FzbONeRz0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HLLQiMTr; 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="HLLQiMTr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B152C4CEEF; Sun, 29 Jun 2025 20:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228091; bh=abx9lNh1gFvopZEIiGDT9OF9wCpwby92bKkdaKzWw20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HLLQiMTrdkfWG+0QJKZwk4tKX4x0i/eeK7i54O+f1YTLiM8iw6R9wxZHpKZzkUBUW QYnHWqhzUKFCWlxwH8p4XuqoK/OrUko8ZLePedEcjY6CXWBvPGLCFcCibjBKrU+WRi Cc4MkK3NqYP23pz70I+YBKgTyC3SPdDoW+u13sVelRJ8Y6Yqx2PlNYXRKjFGoP1w4N YwIgBIZuR7P1uH+X2BQXuvZfgOglPsDfqupH0nUC3sdYAEZWTgBlpDhXfRQL0g2cjk tZYH/4erPvfDEvxlQOQ2eL77aPwKZMayofNWR++bW9XG8CKJH9sSqQeFq7LDGpktlV zLyP4ch46bMGQ== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 5/6] mm/damon: add node_id to damon_access_report Date: Sun, 29 Jun 2025 13:14:42 -0700 Message-Id: <20250629201443.52569-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" In future, per-CPU or per-NUMA node monitoring might be required. We can add the information in damon_access_report and implement the damon_report_access() callers filling the information. And the new operations set implementation for the per-CPU or per-NUMA node access monitoring can show and ignore unnecessary reports via damon_operations->eligible_report() callback. This commit is for showing the first part of the idea. Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 9ec40ce7dde0..29223fea710f 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -111,6 +111,7 @@ struct damon_target { * @addr: The start address of the reporting region. * @size: The size of the reporting region. * @nr_accesses: Number of detected accesses to the region. + * @node_id: NUMA node that made the access. * * @pid could be stale, and hence shouldn't be de-referenced. */ @@ -119,6 +120,7 @@ struct damon_access_report { unsigned long addr; unsigned long size; int nr_accesses; + int node_id; /* private: */ unsigned long report_jiffies; /* when this report is made */ }; --=20 2.39.5 From nobody Wed Oct 8 10:00:00 2025 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 0336E23F434; Sun, 29 Jun 2025 20:14:52 +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=1751228093; cv=none; b=m+aSwdRlFuXy0n6BsyODJkV0aMBrkt9SJQocSqtnG/3kEpZ9ReSgk+R+UVy8tSXq/8SSG/WPO2uEHPpb34oqZ3BfdjS/xhLxfxstsz/B8KsUvQqDelHBO3e4F+uYCIWJqjJpi6jtYwEjFr738+/bm1i5CiIE+PyPGVyychvqJoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751228093; c=relaxed/simple; bh=+xY45ARCwqOrqcwUKSao5lMG0pp6ebXpZJN+oBjPmsA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EvJGjGztP+Psw0AP3PKTNKsRH81A7z0P+e7pM03/5HxNS+sZWmytLzd8DAgK9CjKbCk2Gy/U0D/DJhLR5LFZioOuSmuv71k+2N4M95k4xlCb+VuF4vCphR2CEDb9XZUiI6MCl42fhtJ2lZOf9HcFQmYBFB24ubzrmpxsuzFenPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DDScZksg; 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="DDScZksg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9EFAC4CEEF; Sun, 29 Jun 2025 20:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1751228092; bh=+xY45ARCwqOrqcwUKSao5lMG0pp6ebXpZJN+oBjPmsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDScZksg15rxir5Ww+HYRRdG+O7S6h/fAfriR9yeBLWKpn4QdQMtWmvu6DH+HI+O4 OkjGWlFBRGjdTA3wICFeOTXrtpCtheKGnk/STJZ1+tF1yOWtbv2iw9lJWjtdRS+Vxs O6Tsez+l1cu6NnRir8S+87ZZov6mmA+LmQmSrTN2D9gAfHmTmfPwm09PYPTu+PfdTm AUwq4nPWthRiceIezjrEVg72nuXe8W9A6sKvzzCY/6oMz86r2H4FYkbyuAxWQOn3QA X0vxeYlWCxv8LOqYFx6dR9zTQXOQkR7lG35a/1MvzbHdZOSEsntGiikkiU4p+tVCU7 K8XLF4kEVrjSQ== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 6/6] mm/damon: add write field to damon_access_report Date: Sun, 29 Jun 2025 13:14:43 -0700 Message-Id: <20250629201443.52569-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250629201443.52569-1-sj@kernel.org> References: <20250629201443.52569-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: quoted-printable Content-Type: text/plain; charset="utf-8" This commit is for showing the first part of the idea for implementing write-only access monitoring. Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 29223fea710f..bd5e3287f6f2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -112,6 +112,7 @@ struct damon_target { * @size: The size of the reporting region. * @nr_accesses: Number of detected accesses to the region. * @node_id: NUMA node that made the access. + * @write: Whether the access is write. * * @pid could be stale, and hence shouldn't be de-referenced. */ @@ -121,6 +122,7 @@ struct damon_access_report { unsigned long size; int nr_accesses; int node_id; + bool write; /* private: */ unsigned long report_jiffies; /* when this report is made */ }; --=20 2.39.5