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 D416F3BBA0B for ; Thu, 15 Jan 2026 16:40:13 +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=1768495213; cv=none; b=cwOuRQVsAwvGsIvTdYOYZD4I1hi54frX8vfb7Azi+4SAoD9q3xexAadtorGnigeVDVMq19HfnKCKle04zJWNNC2UG/UAeamoR9ZueM3D71C5wbwShpuQG6xyLSZmmZT/Ef/JL7euvH8chvhXxJvUdwDyqk+IMT+/dMdrgzTb7UI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768495213; c=relaxed/simple; bh=CTc1327g9hE1ZjOQpVN2704bIazDl+LF/stpmm2fAss=; h=Date:To:From:Subject:Message-Id; b=azVPUM+gUbu1u1OcMfHmo5Ov6eBmXsmNNBWLb2ZWUPC+3UeMT2mDGeK/Mg+EiqGPr0rEOGxce8mZs577quKtt4uP9XOoJf5zPCgOnQvMdHm8US6Lvu1KJ7FIb9Q/Zv2/i4qxU3iJel1Zqsc7rnZApi8BiGMjglbLXaN1JzmF8hc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=C6ODMk8S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="C6ODMk8S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76854C19422; Thu, 15 Jan 2026 16:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1768495213; bh=CTc1327g9hE1ZjOQpVN2704bIazDl+LF/stpmm2fAss=; h=Date:To:From:Subject:From; b=C6ODMk8S0vmDJ7uIeOhsxHKAf6PUB0G3gqVItNv/XE4DcKJ4xPcQDaytSYnEdMHmM aWlVRDX+1fW+Lk6D9pwslr2LZMUBkG5j0/cdf7/oDLW8XxH8VEI6nTRS+xD81cXU+Y B+VqVDlCuR7hugViXrdOO45i4OYX7XgBQ5O0JyqA= Date: Thu, 15 Jan 2026 08:40:12 -0800 To: mm-commits@vger.kernel.org,sj@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-damon-core-implement-damon_kdamond_pid.patch added to mm-new branch Message-Id: <20260115164013.76854C19422@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/damon/core: implement damon_kdamond_pid() has been added to the -mm mm-new branch. Its filename is mm-damon-core-implement-damon_kdamond_pid.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-core-implement-damon_kdamond_pid.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: SeongJae Park Subject: mm/damon/core: implement damon_kdamond_pid() Date: Thu, 15 Jan 2026 07:20:41 -0800 Patch series "mm/damon: hide kdamond and kdamond_lock from API callers". 'kdamond' and 'kdamond_lock' fields initially exposed to DAMON API callers for flexible synchronization and use cases. As DAMON API became somewhat complicated compared to the early days, Keeping those exposed could only encourage the API callers to invent more creative but complicated and difficult-to-debug use cases. Fortunately DAMON API callers didn't invent that many creative use cases. There exist only two use cases of 'kdamond' and 'kdamond_lock'. Finding whether the kdamond is actively running, and getting the pid of the kdamond. For the first use case, a dedicated API function, namely 'damon_is_running()' is provided, and all DAMON API callers are using the function for the use case. Hence only the second use case is where the fields are directly being used by DAMON API callers. To prevent future invention of complicated and erroneous use cases of the fields, hide the fields from the API callers. For that, provide new dedicated DAMON API functions for the remaining use case, namely damon_kdamond_pid(), migrate DAMON API callers to use the new function, and mark the fields as private fields. This patch (of 5): 'kdamond' and 'kdamond_lock' are directly being used by DAMON API callers for getting the pid of the corresponding kdamond. To discourage invention of creative but complicated and erroneous new usages of the fields that require careful synchronization, implement a new API function that can simply be used without the manual synchronizations. Link: https://lkml.kernel.org/r/20260115152047.68415-1-sj@kernel.org Link: https://lkml.kernel.org/r/20260115152047.68415-2-sj@kernel.org Signed-off-by: SeongJae Park Signed-off-by: Andrew Morton --- include/linux/damon.h | 1 + mm/damon/core.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) --- a/include/linux/damon.h~mm-damon-core-implement-damon_kdamond_pid +++ a/include/linux/damon.h @@ -972,6 +972,7 @@ bool damon_initialized(void); int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive); int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); bool damon_is_running(struct damon_ctx *ctx); +int damon_kdamond_pid(struct damon_ctx *ctx); int damon_call(struct damon_ctx *ctx, struct damon_call_control *control); int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control); --- a/mm/damon/core.c~mm-damon-core-implement-damon_kdamond_pid +++ a/mm/damon/core.c @@ -1442,6 +1442,23 @@ bool damon_is_running(struct damon_ctx * return running; } +/** + * damon_kdamond_pid() - Return pid of a given DAMON context's worker thread. + * @ctx: The DAMON context of the question. + * + * Return: pid if @ctx is running, negative error code otherwise. + */ +int damon_kdamond_pid(struct damon_ctx *ctx) +{ + int pid = -EINVAL; + + mutex_lock(&ctx->kdamond_lock); + if (ctx->kdamond) + pid = ctx->kdamond->pid; + mutex_unlock(&ctx->kdamond_lock); + return pid; +} + /* * damon_call_handle_inactive_ctx() - handle DAMON call request that added to * an inactive context. _ Patches currently in -mm which might be from sj@kernel.org are mm-damon-core-introduce-nr_snapshots-damos-stat.patch mm-damon-sysfs-schemes-introduce-nr_snapshots-damos-stat-file.patch docs-mm-damon-design-update-for-nr_snapshots-damos-stat.patch docs-admin-guide-mm-damon-usage-update-for-nr_snapshots-damos-stat.patch docs-abi-damon-update-for-nr_snapshots-damos-stat.patch mm-damon-update-damos-kerneldoc-for-stat-field.patch mm-damon-core-implement-max_nr_snapshots.patch mm-damon-sysfs-schemes-implement-max_nr_snapshots-file.patch docs-mm-damon-design-update-for-max_nr_snapshots.patch docs-admin-guide-mm-damon-usage-update-for-max_nr_snapshots.patch docs-abi-damon-update-for-max_nr_snapshots.patch mm-damon-core-add-trace-point-for-damos-stat-per-apply-interval.patch mm-damon-tests-core-kunit-add-test-cases-for-multiple-regions-in-damon_test_split_regions_of-fix.patch mm-damon-core-introduce-active-memory-ratio-damos-quota-goal-metric.patch mm-damon-sysfs-schemes-support-damos_quota_active_mem_bp.patch docs-mm-damon-design-document-damos_quota_active_mem_bp.patch mm-damon-paddr-activate-damos_lru_prio-targets-instead-of-marking-accessed.patch mm-damon-lru_sort-consider-age-for-quota-prioritization.patch mm-damon-lru_sort-support-young-page-filters.patch docs-admin-guide-mm-damon-lru_sort-document-filter_young_pages.patch mm-damon-lru_sort-support-active-inactive-memory-ratio-based-auto-tuning.patch docs-admin-guide-mm-damon-lru_sort-document-active_mem_bp-parameter.patch mm-damon-lru_sort-add-monitoring-intervals-auto-tuning-parameter.patch docs-admin-guide-mm-damon-lru_sort-document-intervals-autotuning.patch mm-damon-core-implement-damon_kdamond_pid.patch mm-damon-sysfs-use-damon_kdamond_pid.patch mm-damon-lru_sort-use-damon_kdamond_pid.patch mm-damon-reclaim-use-damon_kdamond_pid.patch mm-damon-hide-kdamond-and-kdamond_lock-of-damon_ctx.patch