Skip to contentSkip to conversation

mm/damon/core: remove declaration of kdamond_fn()

PATCH In review Zenghui Yu 4 participants 6 messages Aug 27 – Aug 28

Subsystems (2)
lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH 1/1 mm/damon/core: remove declaration of kdamond_fn()

From: "Zenghui Yu (Huawei)" <[email protected]>

It was added by commit 2224d8485492 ("mm: introduce Data Access MONitor (DAMON)") but is actually not needed. Remove it.

---
 mm/damon/core.c | 2 --
 1 file changed, 2 deletions(-)
mm/damon/core.c +0 -2
index 37d661e2bbc1..183080556404 100644
@@ -1922,8 +1922,6 @@ static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx)
 	return max_region_sz;
 }
 
-static int kdamond_fn(void *data);
-
 /*
  * __damon_start() - Starts monitoring with given context.
  * @ctx:	monitoring context
Signature · 1 line
2.53.0
author
#1 lore raw

Please ignore this patch. This is absolutely wrong. Sorry for the noise..

Quoted 23 lines · Zenghui Yu

From: "Zenghui Yu (Huawei)" <[email protected]>

It was added by commit 2224d8485492 ("mm: introduce Data Access MONitor (DAMON)") but is actually not needed. Remove it.

---
 mm/damon/core.c | 2 --
 1 file changed, 2 deletions(-)
mm/damon/core.c +0 -2
index 37d661e2bbc1..183080556404 100644
@@ -1922,8 +1922,6 @@ static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx)
 	return max_region_sz;
 }
 
-static int kdamond_fn(void *data);
-
 /*
  * __damon_start() - Starts monitoring with given context.
  * @ctx:	monitoring context
#3 lore raw
In reply to Zenghui Yu
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Removing the forward declaration of `kdamond_fn` causes a build failure because it is referenced in…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Removing the forward declaration of kdamond_fn causes a build failure because it is referenced in __damon_start before its definition. --

commit 38eba93e0517bb327a80a5c61f1f8b5a41ec274d
Author: Zenghui Yu (Huawei) <[email protected]>

mm/damon/core: remove declaration of kdamond_fn()

It was added by commit 2224d8485492 ("mm: introduce Data Access MONitor (DAMON)") but is actually not needed. Remove it.

mm/damon/core.c static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx) · line 1926

Quoted 10 lines
mm/damon/core.c +0 -2
index 644daf5a16560..67d93b57a8947 100644
@@ -1922,8 +1922,6 @@ static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx)
 	return max_region_sz;
 }
 
-static int kdamond_fn(void *data);
-

[Severity: Low]
Does removing this forward declaration cause a build failure?

It looks like kdamond_fn is referenced shortly after in __damon_start(), but its actual definition doesn't occur until much later in the file:

mm/damon/core.c:__damon_start() {
        ...
		ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
				nr_running_ctxs);
        ...
}

Will the compiler fail when compiling mm/damon/core.c because kdamond_fn is used before it is defined?

Quoted 3 lines
mm/damon/core.c +0 -0
 /*
  * __damon_start() - Starts monitoring with given context.
  * @ctx:	monitoring context
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#4 lore raw
In reply to Zenghui Yu
kernel test robot noticed the following build errors:

Hi Zenghui,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zenghui-Yu/mm-damon-core-remove-declaration-of-kdamond_fn/20260828-003953
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20260827163953.83520-1-zenghui.yu%40linux.dev
patch subject: [PATCH] mm/damon/core: remove declaration of kdamond_fn()
config: hexagon-randconfig-r052-20260828 (https://download.01.org/0day-ci/archive/20260828/[email protected]/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260828/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> mm/damon/core.c:1941:30: error: use of undeclared identifier 'kdamond_fn'
    1941 |                 ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
         |                                            ^

1 error generated.

vim +/kdamond_fn +1941 mm/damon/core.c

b1029f29eb1d5fb SJ Park        2026-02-28  1924  
2224d8485492e49 SeongJae Park  2021-09-07  1925  /*
2224d8485492e49 SeongJae Park  2021-09-07  1926   * __damon_start() - Starts monitoring with given context.
2224d8485492e49 SeongJae Park  2021-09-07  1927   * @ctx:	monitoring context
2224d8485492e49 SeongJae Park  2021-09-07  1928   *
2224d8485492e49 SeongJae Park  2021-09-07  1929   * This function should be called while damon_lock is hold.
2224d8485492e49 SeongJae Park  2021-09-07  1930   *
2224d8485492e49 SeongJae Park  2021-09-07  1931   * Return: 0 on success, negative error code otherwise.
2224d8485492e49 SeongJae Park  2021-09-07  1932   */
2224d8485492e49 SeongJae Park  2021-09-07  1933  static int __damon_start(struct damon_ctx *ctx)
2224d8485492e49 SeongJae Park  2021-09-07  1934  {
2224d8485492e49 SeongJae Park  2021-09-07  1935  	int err = -EBUSY;
2224d8485492e49 SeongJae Park  2021-09-07  1936  
2224d8485492e49 SeongJae Park  2021-09-07  1937  	mutex_lock(&ctx->kdamond_lock);
2224d8485492e49 SeongJae Park  2021-09-07  1938  	if (!ctx->kdamond) {
2224d8485492e49 SeongJae Park  2021-09-07  1939  		err = 0;
6376a824595607e SJ Park        2023-12-08  1940  		reinit_completion(&ctx->kdamond_started);
2224d8485492e49 SeongJae Park  2021-09-07 @1941  		ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
2224d8485492e49 SeongJae Park  2021-09-07  1942  				nr_running_ctxs);
2224d8485492e49 SeongJae Park  2021-09-07  1943  		if (IS_ERR(ctx->kdamond)) {
2224d8485492e49 SeongJae Park  2021-09-07  1944  			err = PTR_ERR(ctx->kdamond);
7ec1992b891e59d Colin Ian King 2021-11-05  1945  			ctx->kdamond = NULL;
6376a824595607e SJ Park        2023-12-08  1946  		} else {
6376a824595607e SJ Park        2023-12-08  1947  			wait_for_completion(&ctx->kdamond_started);
2224d8485492e49 SeongJae Park  2021-09-07  1948  		}
2224d8485492e49 SeongJae Park  2021-09-07  1949  	}
2224d8485492e49 SeongJae Park  2021-09-07  1950  	mutex_unlock(&ctx->kdamond_lock);
2224d8485492e49 SeongJae Park  2021-09-07  1951  
2224d8485492e49 SeongJae Park  2021-09-07  1952  	return err;
2224d8485492e49 SeongJae Park  2021-09-07  1953  }
2224d8485492e49 SeongJae Park  2021-09-07  1954  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

maintainer
#2 lore raw
In reply to Zenghui Yu
Quoted 1 line · On Fri, 28 Aug 2026 00:47:08 +0800 Zenghui Yu <[email protected]> wrote:

Please ignore this patch. This is absolutely wrong. Sorry for the noise..

No worry. Thank you for the patch though!

Thanks,
SJ

[...]

#5 lore raw
In reply to Zenghui Yu
kernel test robot noticed the following build errors:

Hi Zenghui,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Zenghui-Yu/mm-damon-core-remove-declaration-of-kdamond_fn/20260828-003953
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20260827163953.83520-1-zenghui.yu%40linux.dev
patch subject: [PATCH] mm/damon/core: remove declaration of kdamond_fn()
config: xtensa-randconfig-r073-20260828 (https://download.01.org/0day-ci/archive/20260828/[email protected]/config)
compiler: xtensa-linux-gcc (GCC) 16.1.0
smatch: v0.5.0-9187-g5189e3fb
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260828/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from include/linux/psi_types.h:5,

                    from include/linux/cgroup-defs.h:24,
                    from include/linux/cgroup.h:29,
                    from include/linux/memcontrol.h:13,
                    from include/linux/damon.h:10,
                    from mm/damon/core.c:8:
   mm/damon/core.c: In function '__damon_start':
>> mm/damon/core.c:1941:44: error: 'kdamond_fn' undeclared (first use in this function)
    1941 |                 ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
         |                                            ^~~~~~~~~~
   include/linux/kthread.h:46:32: note: in definition of macro 'kthread_create'
      46 |         kthread_create_on_node(threadfn, data, NUMA_NO_NODE, namefmt, ##arg)
         |                                ^~~~~~~~
   mm/damon/core.c:1941:32: note: in expansion of macro 'kthread_run'
    1941 |                 ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
         |                                ^~~~~~~~~~~
   mm/damon/core.c:1941:44: note: each undeclared identifier is reported only once for each function it appears in
   include/linux/kthread.h:46:32: note: in definition of macro 'kthread_create'
      46 |         kthread_create_on_node(threadfn, data, NUMA_NO_NODE, namefmt, ##arg)
         |                                ^~~~~~~~
   mm/damon/core.c:1941:32: note: in expansion of macro 'kthread_run'
    1941 |                 ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
         |                                ^~~~~~~~~~~
   mm/damon/core.c: At top level:
>> mm/damon/core.c:3750:12: warning: 'kdamond_fn' defined but not used [-Wunused-function]

3750 | static int kdamond_fn(void *data)
| ^~~~~~~~~~

vim +/kdamond_fn +1941 mm/damon/core.c

b1029f29eb1d5fb SJ Park        2026-02-28  1924  
2224d8485492e49 SeongJae Park  2021-09-07  1925  /*
2224d8485492e49 SeongJae Park  2021-09-07  1926   * __damon_start() - Starts monitoring with given context.
2224d8485492e49 SeongJae Park  2021-09-07  1927   * @ctx:	monitoring context
2224d8485492e49 SeongJae Park  2021-09-07  1928   *
2224d8485492e49 SeongJae Park  2021-09-07  1929   * This function should be called while damon_lock is hold.
2224d8485492e49 SeongJae Park  2021-09-07  1930   *
2224d8485492e49 SeongJae Park  2021-09-07  1931   * Return: 0 on success, negative error code otherwise.
2224d8485492e49 SeongJae Park  2021-09-07  1932   */
2224d8485492e49 SeongJae Park  2021-09-07  1933  static int __damon_start(struct damon_ctx *ctx)
2224d8485492e49 SeongJae Park  2021-09-07  1934  {
2224d8485492e49 SeongJae Park  2021-09-07  1935  	int err = -EBUSY;
2224d8485492e49 SeongJae Park  2021-09-07  1936  
2224d8485492e49 SeongJae Park  2021-09-07  1937  	mutex_lock(&ctx->kdamond_lock);
2224d8485492e49 SeongJae Park  2021-09-07  1938  	if (!ctx->kdamond) {
2224d8485492e49 SeongJae Park  2021-09-07  1939  		err = 0;
6376a824595607e SJ Park        2023-12-08  1940  		reinit_completion(&ctx->kdamond_started);
2224d8485492e49 SeongJae Park  2021-09-07 @1941  		ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
2224d8485492e49 SeongJae Park  2021-09-07  1942  				nr_running_ctxs);
2224d8485492e49 SeongJae Park  2021-09-07  1943  		if (IS_ERR(ctx->kdamond)) {
2224d8485492e49 SeongJae Park  2021-09-07  1944  			err = PTR_ERR(ctx->kdamond);
7ec1992b891e59d Colin Ian King 2021-11-05  1945  			ctx->kdamond = NULL;
6376a824595607e SJ Park        2023-12-08  1946  		} else {
6376a824595607e SJ Park        2023-12-08  1947  			wait_for_completion(&ctx->kdamond_started);
2224d8485492e49 SeongJae Park  2021-09-07  1948  		}
2224d8485492e49 SeongJae Park  2021-09-07  1949  	}
2224d8485492e49 SeongJae Park  2021-09-07  1950  	mutex_unlock(&ctx->kdamond_lock);
2224d8485492e49 SeongJae Park  2021-09-07  1951  
2224d8485492e49 SeongJae Park  2021-09-07  1952  	return err;
2224d8485492e49 SeongJae Park  2021-09-07  1953  }
2224d8485492e49 SeongJae Park  2021-09-07  1954  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki