Re: [RFC PATCH v3 04/37] mm/damon/core: implement damon_report_page_fault()

JaeJoon Jung
2025-12-13T00:31:35Z

On Sat, 13 Dec 2025 at 07:47, SeongJae Park <sj@kernel.org> wrote:
>
> On Fri, 12 Dec 2025 21:46:03 +0900 JaeJoon Jung <rgbi3307@gmail.com> wrote:
>
> > On Mon, 8 Dec 2025 at 15:33, SeongJae Park <sj@kernel.org> wrote:
> > >
> > > Implement a DAMON core API for reporting page fault events to DAMON. It
> > > is a wrapper of damon_report_access().
> > >
> > > This is a temporal hack. In future versions that will have no RFC tag,
> > > only damon_report_access() may be used.
> >
> > It's a minor, but git am throws an error when applying the [RFC PATCH v3 04/37]
> > patch file.
>
> Interesting. I can do 'git am' this patch without error on mm-new branch. Are
> you using something other than mm-new as your baseline?
>
> > I am testing it by modifying it as follows.
> > damon_report_access() is
> > called by damon_report_page_fault(), so they depend on each other.
> >
> > #ifdef CONFIG_MMU
> > void damon_report_access(struct damon_access_report *report);
> > void damon_report_page_fault(struct vm_fault *vmf, bool huge_pmd);
> > #else
> > static inline void damon_report_access(struct damon_access_report *report)
> > {
> > }
> > static inline void damon_report_page_fault(struct vm_fault *vmf, bool huge_pmd)
> > {
> > }
> > #endif
>
> Seems this is not for fixing a 'git am' error but build error...? Can you
> share what error exactly you are seeing?

You have been deploying RFC PATCH v1, v2, and v3 starting from 2025-06-29.
I am currently working with the latest version v6.18.1 (as of 2025-12-13).

$ head Makefile
# SPDX-License-Identifier: GPL-2.0
VERSION = 6
PATCHLEVEL = 18
SUBLEVEL = 1
EXTRAVERSION =
NAME = Baby Opossum Posse

When applying RFC PATCH v1, v2, v3 with the above version, errors occur
in several places in 'git am' as follows.

-------- [RFC PATCH v1] -------------------------------------------------

$ git am '[RFC PATCH 1/6]'
Applying: mm/damon/core: introduce damon_report_access()

$ git am '[RFC PATCH 2/6]'
Applying: mm/damon/core: add eliglble_report() ops callback

$ git am '[RFC PATCH 3/6]'
Applying: mm/damon/core: check received access reports

$ git am '[RFC PATCH 4/6]'
Applying: mm/damon/vaddr: impleement eligible_report() callback
error: patch failed: mm/damon/vaddr.c:610
error: mm/damon/vaddr.c: patch does not apply
Patch failed at 0001 mm/damon/vaddr: impleement eligible_report() callback
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC PATCH 5/6]'
Applying: mm/damon: add node_id to damon_access_report

$ git am '[RFC PATCH 6/6]'
Applying: mm/damon: add write field to damon_access_report

-------- [RFC PATCH v2] -------------------------------------------------

$ git am '[RFC v2 1/7]'
Applying: mm/damon/core: introduce damon_report_access()
error: patch failed: include/linux/damon.h:104
error: include/linux/damon.h: patch does not apply
error: patch failed: mm/damon/core.c:24
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: introduce damon_report_access()
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v2 2/7]'
Applying: mm/damon/core: add eligible_report() ops callback
error: patch failed: include/linux/damon.h:590
error: include/linux/damon.h: patch does not apply
Patch failed at 0001 mm/damon/core: add eligible_report() ops callback
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v2 3/7]'
Applying: mm/damon/vaddr: implement eligible_report()

$ git am '[RFC v2 4/7]'
Applying: mm/damon/core: read received access reports
error: patch failed: mm/damon/core.c:2560
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: read received access reports
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v2 5/7]'
Applying: mm/memory: implement MM_CP_DAMON

$ git am '[RFC v2 6/7]'
Applying: mm/damon: implement paddr_fault operations set

$ git am '[RFC v2 7/7]'
Applying: mm/damon/sysfs: support paddr_fault

-------- [RFC PATCH v3] -------------------------------------------------

$ git am '[RFC v3 01/37]'
Applying: mm/damon/core: implement damon_report_access()
error: patch failed: include/linux/damon.h:110
error: include/linux/damon.h: patch does not apply
error: patch failed: mm/damon/core.c:20
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: implement damon_report_access()
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 02/37]'
Applying: mm/damon: define struct damon_sample_control

$ git am '[RFC v3 03/37]'
Applying: mm/damon/core: commit damon_sample_control
error: patch failed: mm/damon/core.c:1278
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: commit damon_sample_control
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 04/37]'
Applying: mm/damon/core: implement damon_report_page_fault()
error: patch failed: include/linux/damon.h:1017
error: include/linux/damon.h: patch does not apply
Patch failed at 0001 mm/damon/core: implement damon_report_page_fault()
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 05/37]'
Applying: mm/{mprotect,memory}: (no upstream-aimed hack) implement MM_CP_DAMON
error: patch failed: include/linux/mm.h:2848
error: include/linux/mm.h: patch does not apply
error: patch failed: mm/memory.c:78
error: mm/memory.c: patch does not apply
error: patch failed: mm/mprotect.c:651
error: mm/mprotect.c: patch does not apply
Patch failed at 0001 mm/{mprotect,memory}: (no upstream-aimed hack)
implement MM_CP_DAMON
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 06/37]'
Applying: mm/damon/paddr: support page fault access check primitive
error: patch failed: mm/damon/paddr.c:14
error: mm/damon/paddr.c: patch does not apply
Patch failed at 0001 mm/damon/paddr: support page fault access check primitive
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 07/37]'
Applying: mm/damon/core: apply access reports to high level snapshot
error: patch failed: mm/damon/core.c:2745
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: apply access reports to high level snapshot
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 08/37]'
Applying: mm/damon/sysfs: implement monitoring_attrs/sample/ dir

$ git am '[RFC v3 09/37]'
Applying: mm/damon/sysfs: implement sample/primitives/ dir

$ git am '[RFC v3 10/37]'
Applying: mm/damon/sysfs: connect primitives directory with core

$ git am '[RFC v3 11/37]'
Applying: Docs/mm/damon/design: document page fault sampling primitive

$ git am '[RFC v3 12/37]'
Applying: Docs/admin-guide/mm/damon/usage: document sample primitives dir
error: patch failed: Documentation/admin-guide/mm/damon/usage.rst:65
error: Documentation/admin-guide/mm/damon/usage.rst: patch does not apply
Patch failed at 0001 Docs/admin-guide/mm/damon/usage: document sample
primitives dir
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 13/37]'
Applying: mm/damon: extend damon_access_report for origin CPU reporting
error: patch failed: include/linux/damon.h:115
error: include/linux/damon.h: patch does not apply
Patch failed at 0001 mm/damon: extend damon_access_report for origin
CPU reporting
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 14/37]'
Applying: mm/damon/core: report access origin cpu of page faults
error: patch failed: mm/damon/core.c:1585
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: report access origin cpu of page faults
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 15/37]'
Applying: mm/damon: implement sample filter data structure for
cpus-only monitoring

$ git am '[RFC v3 16/37]'
Applying: mm/damon/core: implement damon_sample_filter manipulations
error: patch failed: mm/damon/core.c:561
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: implement damon_sample_filter manipulations
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 17/37]'
Applying: mm/damon/core: commit damon_sample_filters
error: patch failed: mm/damon/core.c:573
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: commit damon_sample_filters
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 18/37]'
Applying: mm/damon/core: apply sample filter to access reports
error: patch failed: mm/damon/core.c:586
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: apply sample filter to access reports
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 19/37]'
Applying: mm/damon/sysfs: implement sample/filters/ directory

$ git am '[RFC v3 20/37]'
Applying: mm/damon/sysfs: implement sample filter directory

$ git am '[RFC v3 21/37]'
Applying: mm/damon/sysfs: implement type, matching, allow files under
sample filter dir

$ git am '[RFC v3 22/37]'
Applying: mm/damon/sysfs: implement cpumask file under sample filter dir

$ git am '[RFC v3 23/37]'
Applying: mm/damon/sysfs: connect sample filters with core layer

$ git am '[RFC v3 24/37]'
Applying: Docs/mm/damon/design: document sample filters

$ git am '[RFC v3 25/37]'
Applying: Docs/admin-guide/mm/damon/usage: document sample filters dir
error: patch failed: Documentation/admin-guide/mm/damon/usage.rst:66
error: Documentation/admin-guide/mm/damon/usage.rst: patch does not apply
Patch failed at 0001 Docs/admin-guide/mm/damon/usage: document sample
filters dir
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 26/37]'
Applying: mm/damon: extend damon_access_report for access-origin thread info
error: patch failed: include/linux/damon.h:116
error: include/linux/damon.h: patch does not apply
Patch failed at 0001 mm/damon: extend damon_access_report for
access-origin thread info
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 27/37]'
Applying: mm/damon/core: report access-generated thread id of the fault event
error: patch failed: mm/damon/core.c:1712
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: report access-generated thread id
of the fault event
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 28/37]'
Applying: mm/damon: extend damon_sample_filter for threads

$ git am '[RFC v3 29/37]'
Applying: mm/damon/core: support threads type sample filter
error: patch failed: mm/damon/core.c:570
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: support threads type sample filter
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 30/37]'
Applying: mm/damon/sysfs: support thread based access sample filtering

$ git am '[RFC v3 31/37]'
Applying: Docs/mm/damon/design: document threads type sample filter

$ git am '[RFC v3 32/37]'
Applying: Docs/admin-guide/mm/damon/usage: document tids_arr file
error: patch failed: Documentation/admin-guide/mm/damon/usage.rst:67
error: Documentation/admin-guide/mm/damon/usage.rst: patch does not apply
Patch failed at 0001 Docs/admin-guide/mm/damon/usage: document tids_arr file
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 33/37]'
Applying: mm/damon: support reporting write access
error: patch failed: include/linux/damon.h:117
error: include/linux/damon.h: patch does not apply
Patch failed at 0001 mm/damon: support reporting write access
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 34/37]'
Applying: mm/damon/core: report whether the page fault was for writing
error: patch failed: mm/damon/core.c:1732
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: report whether the page fault was
for writing
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 35/37]'
Applying: mm/damon/core: support write access sample filter
error: patch failed: mm/damon/core.c:1336
error: mm/damon/core.c: patch does not apply
Patch failed at 0001 mm/damon/core: support write access sample filter
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

$ git am --abort

$ git am '[RFC v3 36/37]'
Applying: mm/damon/sysfs: support write-type access sample filter

$ git am '[RFC v3 37/37]'
Applying: Docs/mm/damon/design: document write access sample filter type

If I build the kernel with the above status, I get compilation errors
as follows.

/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c:758:25:
error: ‘DAMON_FILTER_TYPE_WRITE’ undeclared here (not in a function);
did you mean ‘DAMOS_FILTER_TYPE_TARGET’?
758 | .type = DAMON_FILTER_TYPE_WRITE,
| ^~~~~~~~~~~~~~~~~~~~~~~
| DAMOS_FILTER_TYPE_TARGET
/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c: In function
‘damon_sysfs_set_sample_filters’:
/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c:2014:26:
error: implicit declaration of function ‘damon_new_sample_filter’; did
you mean ‘damos_new_filter’? [-Werror=implicit-function-declaration]
2014 | filter = damon_new_sample_filter(
| ^~~~~~~~~~~~~~~~~~~~~~~
| damos_new_filter
/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c:2014:24:
warning: assignment to ‘struct damon_sample_filter *’ from ‘int’ makes
pointer from integer without a cast [-Wint-conversion]
2014 | filter = damon_new_sample_filter(
| ^
/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c:2027:33:
error: implicit declaration of function ‘damon_free_sample_filter’;
did you mean ‘damon_sysfs_set_sample_filters’?
[-Werror=implicit-function-declaration]
2027 | damon_free_sample_filter(filter);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| damon_sysfs_set_sample_filters
/home/arm64/projects/kernel/linux-stable/mm/damon/sysfs.c:2032:17:
error: implicit declaration of function ‘damon_add_sample_filter’; did
you mean ‘damos_add_filter’? [-Werror=implicit-function-declaration]
2032 | damon_add_sample_filter(control, filter);
| ^~~~~~~~~~~~~~~~~~~~~~~
| damos_add_filter
cc1: some warnings being treated as errors
make[5]: *** [/home/arm64/projects/kernel/linux-stable/scripts/Makefile.build:287:
mm/damon/sysfs.o] Error 1
make[4]: *** [/home/arm64/projects/kernel/linux-stable/scripts/Makefile.build:556:
mm/damon] Error 2
make[3]: *** [/home/arm64/projects/kernel/linux-stable/scripts/Makefile.build:556:
mm] Error 2
make[3]: *** Waiting for unfinished jobs....
CC kernel/time/timekeeping_debug.o

I am analyzing the source code while I am correcting the errors.

Thanks,
JaeJoon

>
>
> Thanks,
> SJ
>
> …