From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5A75236F8F5 for ; Fri, 29 May 2026 04:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780027656; cv=none; b=mYxswWeBFr1C0tLvHatepHkhax0F5qe74jRDU4siAXqNCR7wVd3zL6+mVuwPee/YbKAjzXbMZVjCo3f7g5C5y9IMvynfl2qTQjVOuRHRk2xIqQm2bomw3oXI1nJkjnW1jY0JdxJsUePPGldsiOFwNeq2edEgQkUn7T3cz+9Q9TM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780027656; c=relaxed/simple; bh=oft9B5muXuaQ61517ZbvRpWxvo+AhN4eIoLBfZ2i50Y=; h=Date:To:From:Subject:Message-Id; b=K5ZHk0CUwi1spnMnL8Tok5Jrd6xQZPgB6Cuie7OtUhhn+WSJjQwBGaEMT+5fpOHMLMLIvB/vwFB71VOrOR78iRL0HAHBn0lyocySfeLPdpiMowRFZwUT/emEvPq77OYnJNcUymExDAGmFTC9RDZKYV/fg/O6/RQMWZP39uZj8+Q= 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=GiOtlrbm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="GiOtlrbm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D511B1F00893; Fri, 29 May 2026 04:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1780027654; bh=fxH/BEBPKx9qEUl6A1NGJ2c5sS+MTiN4zi0icuZ2qkM=; h=Date:To:From:Subject; b=GiOtlrbmYRkApC3n69VeXEUHjEDE4+mBhCcT/vVNJenr1bAWhXZQyXx+UblwcXbnw /YyTMw1vYjDlJWYNPlXoJtsEqBn+iUBYlRaDSpTOewpKIHr13joCOLba/5FZWSbFts 7nHR8UJepbOa33qchsw884ipwt96fM7Kb8J4jP5s= Date: Thu, 28 May 2026 21:07:34 -0700 To: mm-commits@vger.kernel.org,vbabka@kernel.org,surenb@google.com,shuah@kernel.org,rppt@kernel.org,mhocko@suse.com,ljs@kernel.org,liam@infradead.org,david@kernel.org,corbet@lwn.net,brendan.higgins@linux.dev,sj@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-damon-core-introduce-damon_ctx-paused.patch removed from -mm tree Message-Id: <20260529040734.D511B1F00893@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm/damon/core: introduce damon_ctx->paused has been removed from the -mm tree. Its filename was mm-damon-core-introduce-damon_ctx-paused.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: SeongJae Park Subject: mm/damon/core: introduce damon_ctx->paused Date: Mon, 27 Apr 2026 08:12:20 -0700 Patch series "mm/damon: let DAMON be paused and resumed", v2. DAMON utilizes a few mechanisms that enhance itself over time. Adaptive regions adjustment, goal-based DAMOS quota auto-tuning and monitoring intervals auto-tuning like self-training mechanisms are such examples. It also adds access frequency stability information (age) to the monitoring results, which makes it enhanced over time. Sometimes users have to stop DAMON. In this case, DAMON internal state that enhanced over the time of the last execution simply goes away. Restarted DAMON have to train itself and enhance its output from the scratch. This makes DAMON less useful in such cases. Introducing three such use cases below. Investigation of DAMON. It is best to do the investigation online, especially when it is a production environment. DAMON therefore provides features for such online investigations, including DAMOS stats, monitoring result snapshot exposure, and multiple tracepoints. When those are insufficient, and there are additional clues that could be interfered by DAMON, users have to temporarily stop DAMON to collect the additional clues. It is not very useful since many of DAMON internal clues are gone when DAMON is stopped. The loss of the monitoring results that improved over time is also problematic, especially in production environments. Monitoring of workloads that have different user-known phases. For example, in Android, applications are known to have very different access patterns and behaviors when they are running on the foreground and the background. It can therefore be useful to separate monitoring of apps based on whether they are running on the foreground and on the background. Having two DAMON threads per application that paused and resumed for the apps foreground/background switches can be useful for the purpose. But such pause/resume of the execution is not supported. Tests of DAMON. A few DAMON selftests are using drgn to dump the internal DAMON status. The tests show if the dumped status is the same as what the test code expected. Because DAMON keeps running and modifying its internal status, there are chances of data races that can cause false test results. Stopping DAMON can avoid the race. But, since the internal state of DAMON is dropped, the test coverage will be limited. Let DAMON execution be paused and resumed without loss of the internal state, to overhaul the limitations. For this, introduce a new DAMON context parameter, namely 'pause'. API callers can update it while the context is running, using the online parameters update functions (damon_commit_ctx() and damon_call()). Once it is set, kdamond_fn() main loop will do only limited works excluding the monitoring and DAMOS works, while sleeping sampling intervals per the work. The limited works include handling of the online parameters update. Hence users can unset the 'pause' parameter again. Once it is unset, kdamond_fn() main loop will do all the work again (resumed). Under the paused state, it also does stop condition checks and handling of it, so that paused DAMON can also be stopped if needed. Expose the feature to the user space via DAMON sysfs interface. Also, update existing drgn-based tests to test and use the feature. Tests ===== I confirmed the feature functionality using real time tracing ('perf trace' or 'trace-cmd stream') of damon:damon_aggregated DAMON tracepoint. By pausing and resuming the DAMON execution, I was able to see the trace stops and continued as expected. Note that the pause feature support is added to DAMON user-space tool (damo) after v3.1.9. Users can use '--pause_ctx' command line option of damo for that, and I actually used it for my test. The extended drgn-based selftests are also testing a part of the functionality. Patches Sequence ================ Patch 1 introduces the new core API for the pause feature. Patch 2 extend DAMON sysfs interface for the new parameter. Patches 3-5 update design, usage and ABI documents for the new sysfs file, respectively. The following five patches are for tests. Patch 6 implements a new kunit test for the pause parameter online commitment. Patches 7 and 8 extend DAMON selftest helpers to support the new feature. Patch 9 extends selftest to test the commitment of the feature. Finally, patch 10 updates existing selftest to be safe from the race condition using the pause/resume feature. This patch (of 10): DAMON supports only start and stop of the execution. When it is stopped, its internal data that it self-trained goes away. It will be useful if the execution can be paused and resumed with the previous self-trained data. Introduce per-context API parameter, 'paused', for the purpose. The parameter can be set and unset while DAMON is running and paused, using the online parameters commit helper functions (damon_commit_ctx() and damon_call()). Once 'paused' is set, the kdamond_fn() main loop does only limited works with sampling interval sleep during the works. The limited works include the handling of the online parameters update, so that users can unset the 'pause' and resume the execution when they want. It also keep checking DAMON stop conditions and handling of it, so that DAMON can be stopped while paused if needed. Link: https://lore.kernel.org/20260427151231.113429-1-sj@kernel.org Link: https://lore.kernel.org/20260427151231.113429-2-sj@kernel.org Signed-off-by: SeongJae Park Cc: Brendan Higgins Cc: David Hildenbrand Cc: Jonathan Corbet Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Michal Hocko Cc: Mike Rapoport Cc: Shuah Khan Cc: Suren Baghdasaryan Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- include/linux/damon.h | 2 ++ mm/damon/core.c | 9 +++++++++ 2 files changed, 11 insertions(+) --- a/include/linux/damon.h~mm-damon-core-introduce-damon_ctx-paused +++ a/include/linux/damon.h @@ -801,6 +801,7 @@ struct damon_attrs { * @ops: Set of monitoring operations for given use cases. * @addr_unit: Scale factor for core to ops address conversion. * @min_region_sz: Minimum region size. + * @pause: Pause kdamond main loop. * @adaptive_targets: Head of monitoring targets (&damon_target) list. * @schemes: Head of schemes (&damos) list. */ @@ -854,6 +855,7 @@ struct damon_ctx { struct damon_operations ops; unsigned long addr_unit; unsigned long min_region_sz; + bool pause; struct list_head adaptive_targets; struct list_head schemes; --- a/mm/damon/core.c~mm-damon-core-introduce-damon_ctx-paused +++ a/mm/damon/core.c @@ -1370,6 +1370,7 @@ int damon_commit_ctx(struct damon_ctx *d if (err) return err; } + dst->pause = src->pause; dst->ops = src->ops; dst->addr_unit = src->addr_unit; dst->min_region_sz = src->min_region_sz; @@ -3237,6 +3238,14 @@ static int kdamond_fn(void *data) kdamond_call(ctx, false); if (ctx->maybe_corrupted) break; + while (ctx->pause) { + damos_walk_cancel(ctx); + kdamond_usleep(ctx->attrs.sample_interval); + /* allow caller unset pause via damon_call() */ + kdamond_call(ctx, false); + if (kdamond_need_stop(ctx) || ctx->maybe_corrupted) + goto done; + } if (!list_empty(&ctx->schemes)) kdamond_apply_schemes(ctx); else _ Patches currently in -mm which might be from sj@kernel.org are mm-damon-ops-common-call-folio_test_lru-after-folio_get.patch mm-damon-reclaim-handle-ctx-allocation-failure.patch mm-damonn-lru_sort-handle-ctx-allocation-failure.patch mm-damon-core-introduce-struct-damon_probe.patch mm-damon-core-embed-damon_probe-objects-in-damon_ctx.patch mm-damon-core-introduce-damon_filter.patch mm-damon-core-commit-probes.patch mm-damon-core-introduce-damon_region-probe_hits.patch mm-damon-core-introduce-damon_ops-apply_probes.patch mm-damon-core-do-data-attributes-monitoring.patch mm-damon-paddr-support-data-attributes-monitoring.patch mm-damon-sysfs-implement-probes-dir.patch mm-damon-sysfs-implement-probe-dir.patch mm-damon-sysfs-implement-filters-directory.patch mm-damon-sysfs-implement-filter-dir.patch mm-damon-sysfs-implement-filter-dir-files.patch mm-damon-sysfs-setup-probes-on-damon-core-api-parameters.patch mm-damon-sysfs-schemes-implement-tried_regions-r-probes.patch mm-damon-sysfs-schemes-implement-probe-dir.patch mm-damon-sysfs-schemes-implement-probe-hits-file.patch mm-damon-trace-probe_hits.patch selftests-damon-sysfssh-test-probes-dir.patch docs-mm-damon-design-document-data-attributes-monitoring.patch docs-admin-guide-mm-damon-usage-document-data-attributes-monitoring.patch mm-damon-core-introduce-damon_filter_type_memcg.patch mm-damon-paddr-support-damon_filter_type_memcg.patch mm-damon-sysfs-add-filters-f-path-file.patch mm-damon-sysfs-schemes-move-memcg_path_to_id-to-sysfs-common.patch mm-damon-sysfs-setup-damon_filter-memcg_id-from-path.patch docs-mm-damon-design-update-for-memcg-damon-filter.patch docs-admin-guide-mm-damon-usage-update-for-memcg-damon-filter.patch mm-damon-core-safely-handle-no-region-case-in-damon_set_regions.patch mm-damon-core-do-not-use-region-out-of-a-loop-in-damon_set_regions.patch samples-damon-mtier-replace-damon_add_region-with-damon_set_regions.patch mm-damon-tests-vaddr-kunit-replace-damon_add_region-with-damon_set_regions.patch mm-damon-core-hide-damon_add_region.patch mm-damon-core-hide-damon_insert_region.patch mm-damon-core-hide-damon_destroy_region.patch mm-damon-core-add-kdamond_call-debug_sanity-check.patch mm-damon-core-remove-damon_verify_nr_regions.patch mm-damon-tests-core-kunit-add-damon_set_regions-test-cases.patch selftests-damon-sysfspy-stop-kdamonds-before-failing.patch selftests-damon-sysfssh-test-monitoring-intervals-goal-dir.patch selftests-damon-sysfssh-test-addr_unit-file-existence.patch selftests-damon-sysfssh-test-pause-file-existence.patch mm-damon-core-trace-esz-at-first-setup.patch