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 DA3DB2F5313 for ; Mon, 6 Jul 2026 17:10:45 +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=1783357847; cv=none; b=ALfGp1Ul0/jsPmB+xEoPLYXbrd6LqmL1y2j0jgbf76x6tF3KSHxDSFOiFmHX2riUljyt3SE9ZDKe4phZzPL9VOdC9DYqjpf0uJLL6JjmHB2rDa4LYxTwTTt3F8f0knDUnKBI4CFUzdp8xlXeMj8UH6ln3m8XpbcfF2lG+07rfXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783357847; c=relaxed/simple; bh=wuP19amJpRklitX3pi7vh6VWbyY7amBoW8O9IilCSe8=; h=Date:To:From:Subject:Message-Id; b=hZxx0R4XpMxBORMFzHBEarIRwB57kGdl3ajfYD7Miv8uvDPTpDIUwQmvqF+/kPv2nvvWvy37MBTaWlVhQ6vfDlaoCrIzpbsQRw1r3RKZHaC2Ux2jMj/WgEJBnbdEOwXmMy8A/xbNU4N8k4zrQnHe/FEVDC5/fPICzKY59kRvuzA= 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=s4QW03pe; 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="s4QW03pe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 982901F00ACA; Mon, 6 Jul 2026 17:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1783357845; bh=e2l4UiibRmyNlmH79GaKz+iWZu8vf6qqweIt5i9DXcQ=; h=Date:To:From:Subject; b=s4QW03peODI0MbluWFEUgMNdDDMWIIH7Mk3U54WwzeQzlCl6vEJhGhyd810tWjoF3 qNII4/6xhleSuRQn/4zMoDcX5JRbzxoSENyt0IqRuRysdXcRKEbEhNUVTT9TWWHkO/ 6ggZmfzJsBSQiontGTGJyBSHDjgSp4zfIri0zE5Q= Date: Mon, 06 Jul 2026 10:10:45 -0700 To: mm-commits@vger.kernel.org,sj@kernel.org,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-damon-core-wait-ctx-stop-in-damon_call-before-reruning-an-error.patch added to mm-new branch Message-Id: <20260706171045.982901F00ACA@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: wait ctx stop in damon_call() before reruning an error has been added to the -mm mm-new branch. Its filename is mm-damon-core-wait-ctx-stop-in-damon_call-before-reruning-an-error.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-wait-ctx-stop-in-damon_call-before-reruning-an-error.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 If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is 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: SJ Park Subject: mm/damon/core: wait ctx stop in damon_call() before reruning an error Date: Mon, 6 Jul 2026 07:06:24 -0700 damon_call() failure means the DAMON context started its termination. The termination is asynchronously done in kdamond thread. The caller's error handling should handle the race, too. It is complicated and easy to make mistakes. Update damon_call() to ensure the context is stopped in the case, by waiting until the completion is confirmed. Link: https://lore.kernel.org/20260706140628.87414-10-sj@kernel.org Signed-off-by: SJ Park Signed-off-by: Andrew Morton --- mm/damon/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/mm/damon/core.c~mm-damon-core-wait-ctx-stop-in-damon_call-before-reruning-an-error +++ a/mm/damon/core.c @@ -2010,6 +2010,8 @@ int damon_kdamond_pid(struct damon_ctx * * @ctx has succeeded. Otherwise, this function could fall into an indefinite * wait. * + * When this function is failed, the @ctx is guaranteed to be stopped. + * * Return: 0 on success, negative error code otherwise. */ int damon_call(struct damon_ctx *ctx, struct damon_call_control *control) @@ -2022,7 +2024,7 @@ int damon_call(struct damon_ctx *ctx, st mutex_lock(&ctx->call_controls_lock); if (ctx->call_controls_obsolete) { mutex_unlock(&ctx->call_controls_lock); - return -ECANCELED; + goto canceled; } list_add_tail(&control->list, &ctx->call_controls); mutex_unlock(&ctx->call_controls_lock); @@ -2030,8 +2032,14 @@ int damon_call(struct damon_ctx *ctx, st return 0; wait_for_completion(&control->completion); if (control->canceled) - return -ECANCELED; + goto canceled; return 0; + +canceled: + while (damon_is_running(ctx)) + schedule_timeout_idle(msecs_to_jiffies(100)); + return -ECANCELED; + } /** _ Patches currently in -mm which might be from sj@kernel.org are maintainers-s-seongjae-sj.patch mm-damon-core-validate-ranges-in-damon_set_regions.patch mm-damon-core-disallow-overlapping-input-ranges-for-damon_set_regions.patch samples-damon-wsse-handle-damon_start-failure.patch samples-damon-prcl-handle-damon_start-failure.patch samples-damon-mtier-handle-damon_start-failure.patch samples-damon-mtier-handle-damon_stop-failure.patch samples-damon-wsse-stop-and-free-damon-ctx-when-damon_call-fails.patch samples-damon-prcl-stop-and-free-damon-ctx-when-damon_call-fails.patch mm-damon-sysfs-kobject_del-target-normal-context-and-kdamond-dirs.patch mm-damon-sysfs-kobject_del-region-and-target-error-dirs.patch mm-damon-sysfs-schemes-kobject_del-scheme-dirs.patch mm-damon-sysfs-schemes-kobject_del-scheme-region-dirs.patch mm-damon-sysfs-schemes-kobject_del-scheme-filter-dirs.patch mm-damon-sysfs-schemes-kobject_del-scheme-quota-goal-dirs.patch mm-damon-sysfs-schemes-kobject_del-scheme-action-destination-dirs.patch mm-damon-sysfs-kobject_del-probe-dirs.patch mm-damon-sysfs-kobject_del-probe-filter-dirs.patch mm-damon-sysfs-kobject_del-probe-dirs-in-probes_addd_dir-error-path.patch mm-damon-sysfs-schemes-kobject_del-region-for-populate_region-error.patch docs-mm-damon-design-update-for-damos_quota_node_eligible_mem_bp.patch docs-abi-damon-document-probe-files.patch mm-damon-tests-core-kunit-test-damon_rand.patch selftests-damon-sysfssh-test-multiple-probe-dirs-creation.patch selftests-damon-sysfssh-test-coreops_filters-directories.patch selftests-damon-sysfssh-test-dests-dir.patch selftests-damon-sysfssh-test-all-files-in-quota-goal-dir.patch mm-damon-core-reduce-range-setup-in-damon_commit_target_regions.patch mm-damon-sysfs-split-probe-setup-function-out.patch mm-damon-sysfs-split-out-filters-setup-function.patch mm-damon-sysfs-fix-typos-in-probe_addrm_dirs-s-attr-probe.patch mm-damon-core-introduce-damon_nr_accesses_mvsum.patch mm-damon-tests-core-kunit-test-damon_mvsum.patch mm-damon-core-always-update-last_nr_accesses-for-intervals-change.patch mm-damon-core-handle-unreset-nr_accesses-in-damon_nr_accesses_mvsum.patch mm-damon-core-use-damon_nr_accesses_mvsum-in-__damos_valid_target.patch mm-damon-core-use-damon_nr_accesses_mvsum-for-damos-region-tracing.patch mm-damon-sysfs-schemes-use-damon_nr_accesses_mvsum-for-damo-regions.patch mm-damon-core-remove-damon_warn_fix_nr_accesses_corruption.patch mm-damon-core-remove-damon_verify_reset_aggregated.patch mm-damon-core-remove-damon_verify_merge_regions_of.patch mm-damon-tests-core-kunit-remove-nr_accesses_bp-setup-and-tests.patch selftests-damon-drgn_dump_damon_status-do-not-dump-nr_accesses_bp.patch mm-damon-core-remove-nr_accesses_bp-setups-and-updates.patch mm-damon-core-remove-attrs-param-from-damon_update_region_access_rate.patch mm-damon-paddr-remove-attrs-param-from-__damon_pa_check_access.patch mm-damon-vaddr-remove-attrs-param-from-__damon_va_check_access.patch mm-damon-core-remove-damon_moving_sum-and-its-unit-test.patch mm-damon-core-remove-damon_region-nr_accesses_bp.patch mm-damon-add-damon_region-last_probe_hits.patch mm-damon-core-introduce-damon_probe_hits_mvsum.patch mm-damon-sysfs-schemes-set-probe-hits-as-pseudo-moving-sums.patch mm-damon-core-safely-validate-src-on-damon_commit_ctx.patch mm-damon-core-do-parameter-testing-commit-on-damon_start.patch mm-damon-sysfs-remove-duplicated-commit-input-validity-check.patch mm-damon-reclaim-remove-duplicated-min_region_sz-power-of-2-check.patch mm-damon-lru_sort-remove-duplicated-min_region_sz-power_of_2-check.patch mm-damon-document-region-size-validation-in-damon_set_regions.patch mm-damon-core-remove-start-end-check-in-damon_set_region_system_rams.patch mm-damon-sysfs-remove-region-size-validation.patch mm-damon-core-stop-ctxs-in-damon_start-before-returning-an-error.patch samples-damon-mtier-do-not-stop-first-context-for-damon_start-failure.patch mm-damon-core-make-damon_stop-never-fails.patch mm-damon-sysfs-ignore-damon_stop-return-value.patch mm-damon-reclaaim-ignore-damon_stop-return-value.patch mm-damon-lru_sort-ignore-damon_stop-return-value.patch mm-damon-core-change-damon_stop-return-type-to-void.patch samples-damon-mtier-stop-all-contexts-with-single-damon_stop-call.patch mm-damon-core-wait-ctx-stop-in-damon_call-before-reruning-an-error.patch samples-damon-wsse-do-not-stop-ctx-for-damon_call-failure.patch samples-damon-prcl-do-not-stop-damon-for-damon_call-failure.patch