Skip to contentSkip to conversation

mm/damon/core: modified control->repeat loop at the kdamond_call()

PATCH In review JaeJoon Jung 2 participants 13 messages Dec 24, 2025 – Jan 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon/core: modified control->repeat loop at the kdamond_call()

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn(). For ease of explanation, the data structure names will be abbreviated as follows:

damon_call_control.list: C.list
ctx->call_controls: CTX.head
repeat_controls: R.head

the execution flow of the while loop of the kdamond_call() function,

Before modification:
Old while loop:

CTX.head <-----> C.list <-----> C.list <----> C.list
^ | |
| if (C.repeat) if (!C.repeat)
restore: only one | |
list_add_tail() list_del() list_del()

        |                   |                           |
        +                   |                       complete()
        R.head <------ list_add()

To process C.repeat above, we use an additional list, repeat_controls. The process of adding C.list to repeat_controls and then restoring it back to CTX.head is complex and inefficient. Furthermore, there's the problem of restoring only a single C.list to CTX.head.

Below, repeat_controls is removed and the existing CTX.head is modified to loop once(1st rotation). This simplifies list processing and creates a more efficient structure.

Modified while loop:
Not used repeat_controls:

CTX.head <-----> C.list <-----> C.list <----> C.list <-------+
| | |
if (C.repeat) if (!C.repeat) |
| | |
list_del() list_del() |
| | |
| complete() |
| |
first --------> list_add_tail() -----------+

if (C.list == first) break;

---
 mm/damon/core.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
mm/damon/core.c +19 -18
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-	struct damon_call_control *control;
-	LIST_HEAD(repeat_controls);
-	int ret = 0;
+	struct damon_call_control *control, *first = NULL;
+	unsigned int idx = 0;
 
 	while (true) {
 		mutex_lock(&ctx->call_controls_lock);
 		control = list_first_entry_or_null(&ctx->call_controls,
 				struct damon_call_control, list);
 		mutex_unlock(&ctx->call_controls_lock);
-		if (!control)
+
+		/* check control empty or 1st rotation */
+		if (!control || control == first)
 			break;
-		if (cancel) {
+
+		if (++idx == 1)
+			first = control;
+
+		if (cancel)
 			control->canceled = true;
-		} else {
-			ret = control->fn(control->data);
-			control->return_code = ret;
-		}
+		else
+			control->return_code = control->fn(control->data);
+
 		mutex_lock(&ctx->call_controls_lock);
 		list_del(&control->list);
 		mutex_unlock(&ctx->call_controls_lock);
+
 		if (!control->repeat) {
+			/* run control->fn() one time */
 			complete(&control->completion);
 		} else if (control->canceled && control->dealloc_on_cancel) {
 			kfree(control);
-			continue;
 		} else {
-			list_add(&control->list, &repeat_controls);
+			/* to repeat next time */
+			mutex_lock(&ctx->call_controls_lock);
+			list_add_tail(&control->list, &ctx->call_controls);
+			mutex_unlock(&ctx->call_controls_lock);
 		}
 	}
-	control = list_first_entry_or_null(&repeat_controls,
-			struct damon_call_control, list);
-	if (!control || cancel)
-		return;
-	mutex_lock(&ctx->call_controls_lock);
-	list_add_tail(&control->list, &ctx->call_controls);
-	mutex_unlock(&ctx->call_controls_lock);
 }
 
 /* Returns negative error code if it's not activated but should return */

--
2.43.0

maintainer
#1 lore raw
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

Quoted 17 lines

For ease of explanation,
the data structure names will be abbreviated as follows:

damon_call_control.list: C.list
ctx->call_controls: CTX.head
repeat_controls: R.head

the execution flow of the while loop of the kdamond_call() function,

Before modification:
Old while loop:

CTX.head <-----> C.list <-----> C.list <----> C.list
^ | |
| if (C.repeat) if (!C.repeat)
restore: only one | |
list_add_tail() list_del() list_del()

Quoted 5 lines
        |                   |                           |
        +                   |                       complete()
        R.head <------ list_add()

To process C.repeat above, we use an additional list, repeat_controls.

Your above abbreviation didn't explain what C.repeat is. Maybe you mean 'damon_call_control.repeat'?

Quoted 2 lines

The process of adding C.list to repeat_controls and then restoring it back to CTX.head is complex and inefficient.

I agree.

Quoted 2 lines

Furthermore, there's the problem
of restoring only a single C.list to CTX.head.

I had to take some time on understanding what this mean. And it seems you are working on an old version of the tree, and therefore saying about an issue that already fixed by commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects").

Please use mm-new as a baseline of DAMON patches, unless there are special reasons. If there are special reasons, please explicitly specify.

Quoted 71 lines

Below, repeat_controls is removed and the existing CTX.head is modified to loop once(1st rotation). This simplifies list processing and creates a more efficient structure.

Modified while loop:
Not used repeat_controls:

CTX.head <-----> C.list <-----> C.list <----> C.list <-------+
| | |
if (C.repeat) if (!C.repeat) |
| | |
list_del() list_del() |
| | |
| complete() |
| |
first --------> list_add_tail() -----------+

if (C.list == first) break;

---
 mm/damon/core.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
mm/damon/core.c +15 -9
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-	struct damon_call_control *control;
-	LIST_HEAD(repeat_controls);
-	int ret = 0;
+	struct damon_call_control *control, *first = NULL;
+	unsigned int idx = 0;
 
 	while (true) {
 		mutex_lock(&ctx->call_controls_lock);
 		control = list_first_entry_or_null(&ctx->call_controls,
 				struct damon_call_control, list);
 		mutex_unlock(&ctx->call_controls_lock);
-		if (!control)
+
+		/* check control empty or 1st rotation */
+		if (!control || control == first)
 			break;
-		if (cancel) {
+
+		if (++idx == 1)
+			first = control;
+
+		if (cancel)
 			control->canceled = true;
-		} else {
-			ret = control->fn(control->data);
-			control->return_code = ret;
-		}
+		else
+			control->return_code = control->fn(control->data);
+
 		mutex_lock(&ctx->call_controls_lock);
 		list_del(&control->list);
 		mutex_unlock(&ctx->call_controls_lock);
+
 		if (!control->repeat) {
+			/* run control->fn() one time */
 			complete(&control->completion);
 		} else if (control->canceled && control->dealloc_on_cancel) {

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 10 lines
mm/damon/core.c +4 -2
 			kfree(control);
-			continue;
 		} else {
-			list_add(&control->list, &repeat_controls);
+			/* to repeat next time */
+			mutex_lock(&ctx->call_controls_lock);
+			list_add_tail(&control->list, &ctx->call_controls);
+			mutex_unlock(&ctx->call_controls_lock);
 		}
 	}

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2592

Quoted 7 lines
mm/damon/core.c +0 -7
-	control = list_first_entry_or_null(&repeat_controls,
-			struct damon_call_control, list);
-	if (!control || cancel)
-		return;
-	mutex_lock(&ctx->call_controls_lock);
-	list_add_tail(&control->list, &ctx->call_controls);
-	mutex_unlock(&ctx->call_controls_lock);

As I mentioned above, apparently you are using an old version of the tree that not having commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects") that modified this part. Please use mm-new as a baseline, or specify reasons why you cannot do so.

Quoted 5 lines
mm/damon/core.c +0 -1
 }
 
 /* Returns negative error code if it's not activated but should return */
--

2.43.0

Thanks,
SJ

#2 lore raw
Quoted 8 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

Quoted 4 lines

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

This is because kdamond_call() is called repeatedly in kdamond_fn().

Quoted 22 lines
Quoted 22 lines

For ease of explanation,
the data structure names will be abbreviated as follows:

damon_call_control.list: C.list
ctx->call_controls: CTX.head
repeat_controls: R.head

the execution flow of the while loop of the kdamond_call() function,

Before modification:
Old while loop:

CTX.head <-----> C.list <-----> C.list <----> C.list
^ | |
| if (C.repeat) if (!C.repeat)
restore: only one | |
list_add_tail() list_del() list_del()

        |                   |                           |
        +                   |                       complete()
        R.head <------ list_add()
Quoted 4 lines
Quoted 1 line

To process C.repeat above, we use an additional list, repeat_controls.

Your above abbreviation didn't explain what C.repeat is. Maybe you mean 'damon_call_control.repeat'?

Yes, that's right.

Quoted 9 lines
Quoted 3 lines

The process of adding C.list to repeat_controls and then restoring it back to CTX.head is complex and inefficient.

I agree.

Quoted 2 lines

Furthermore, there's the problem
of restoring only a single C.list to CTX.head.

Quoted 7 lines

I had to take some time on understanding what this mean. And it seems you are working on an old version of the tree, and therefore saying about an issue that already fixed by commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects").

Please use mm-new as a baseline of DAMON patches, unless there are special reasons. If there are special reasons, please explicitly specify.

This patch is based on v6.19-rc2.
I will continue to refer to mm-new and damon-new.

Quoted 79 lines
Quoted 79 lines

Below, repeat_controls is removed and the existing CTX.head is modified to loop once(1st rotation). This simplifies list processing and creates a more efficient structure.

Modified while loop:
Not used repeat_controls:

CTX.head <-----> C.list <-----> C.list <----> C.list <-------+
| | |
if (C.repeat) if (!C.repeat) |
| | |
list_del() list_del() |
| | |
| complete() |
| |
first --------> list_add_tail() -----------+

if (C.list == first) break;

---
 mm/damon/core.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Quoted 9 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2592

Quoted 8 lines
mm/damon/core.c +0 -7
-     control = list_first_entry_or_null(&repeat_controls,
-                     struct damon_call_control, list);
-     if (!control || cancel)
-             return;
-     mutex_lock(&ctx->call_controls_lock);
-     list_add_tail(&control->list, &ctx->call_controls);
-     mutex_unlock(&ctx->call_controls_lock);
Quoted 4 lines

As I mentioned above, apparently you are using an old version of the tree that not having commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects") that modified this part. Please use mm-new as a baseline, or specify reasons why you cannot do so.

I'll look into what you said.
I'll also continue to look at the mm-new version.

Thanks,
JaeJoon

Quoted 10 lines
Quoted 6 lines
mm/damon/core.c +0 -1
 }
 
 /* Returns negative error code if it's not activated but should return */
--

2.43.0

Thanks,
SJ

maintainer
#3 lore raw
Quoted 9 lines · On Thu, 25 Dec 2025 12:10:30 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 8 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

Quoted 6 lines
Quoted 4 lines

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

This is because kdamond_call() is called repeatedly in kdamond_fn().

Yes, it is repeatedly called. But, my question is, does it impose overhead that great enough to make a negative impact to the real world.

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

For ease of explanation,
the data structure names will be abbreviated as follows:

damon_call_control.list: C.list
ctx->call_controls: CTX.head
repeat_controls: R.head

the execution flow of the while loop of the kdamond_call() function,

Before modification:
Old while loop:

CTX.head <-----> C.list <-----> C.list <----> C.list
^ | |
| if (C.repeat) if (!C.repeat)
restore: only one | |
list_add_tail() list_del() list_del()

        |                   |                           |
        +                   |                       complete()
        R.head <------ list_add()
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

To process C.repeat above, we use an additional list, repeat_controls.

Your above abbreviation didn't explain what C.repeat is. Maybe you mean 'damon_call_control.repeat'?

Yes, that's right.

Thank you for confirming.

Quoted 109 lines
Quoted 10 lines
Quoted 4 lines

The process of adding C.list to repeat_controls and then restoring it back to CTX.head is complex and inefficient.

I agree.

Quoted 2 lines

Furthermore, there's the problem
of restoring only a single C.list to CTX.head.

Quoted 7 lines

I had to take some time on understanding what this mean. And it seems you are working on an old version of the tree, and therefore saying about an issue that already fixed by commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects").

Please use mm-new as a baseline of DAMON patches, unless there are special reasons. If there are special reasons, please explicitly specify.

This patch is based on v6.19-rc2.
I will continue to refer to mm-new and damon-new.

Quoted 79 lines
Quoted 79 lines

Below, repeat_controls is removed and the existing CTX.head is modified to loop once(1st rotation). This simplifies list processing and creates a more efficient structure.

Modified while loop:
Not used repeat_controls:

CTX.head <-----> C.list <-----> C.list <----> C.list <-------+
| | |
if (C.repeat) if (!C.repeat) |
| | |
list_del() list_del() |
| | |
| complete() |
| |
first --------> list_add_tail() -----------+

if (C.list == first) break;

---
 mm/damon/core.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

Quoted 4 lines

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Maybe my explanation was not enough. Let me explain a bit in more detail.

In the scenario I mentioned, at the first iteration of the loop, 'first' will be the first control object, which has ->repeat unset. The object will be removed from the list. In the second iteration of the loop, it handles the second object, which has ->repeat set. The object is added to the list again. In the third iteration, the loop runs for the second object again. Because it is not same to 'first', the 'break' statement is not reached. The loop continues forever.

Am I missing something?

Thanks,
SJ

[...]

#4 lore raw
Quoted 17 lines · SeongJae Park
Quoted 14 lines · On Thu, 25 Dec 2025 12:10:30 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 12 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

Quoted 4 lines
Quoted 1 line

This is because kdamond_call() is called repeatedly in kdamond_fn().

Yes, it is repeatedly called. But, my question is, does it impose overhead that great enough to make a negative impact to the real world.

I agree that the overhead is not that much since there are only a few lists added to ctx->call_controls(CTX.head).

Quoted 157 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

For ease of explanation,
the data structure names will be abbreviated as follows:

damon_call_control.list: C.list
ctx->call_controls: CTX.head
repeat_controls: R.head

the execution flow of the while loop of the kdamond_call() function,

Before modification:
Old while loop:

CTX.head <-----> C.list <-----> C.list <----> C.list
^ | |
| if (C.repeat) if (!C.repeat)
restore: only one | |
list_add_tail() list_del() list_del()

        |                   |                           |
        +                   |                       complete()
        R.head <------ list_add()
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

To process C.repeat above, we use an additional list, repeat_controls.

Your above abbreviation didn't explain what C.repeat is. Maybe you mean 'damon_call_control.repeat'?

Yes, that's right.

Thank you for confirming.

Quoted 109 lines
Quoted 10 lines
Quoted 4 lines

The process of adding C.list to repeat_controls and then restoring it back to CTX.head is complex and inefficient.

I agree.

Quoted 2 lines

Furthermore, there's the problem
of restoring only a single C.list to CTX.head.

Quoted 7 lines

I had to take some time on understanding what this mean. And it seems you are working on an old version of the tree, and therefore saying about an issue that already fixed by commit 592e5c5f8ec6 ("mm/damon/core: fix memory leak of repeat mode damon_call_control objects").

Please use mm-new as a baseline of DAMON patches, unless there are special reasons. If there are special reasons, please explicitly specify.

This patch is based on v6.19-rc2.
I will continue to refer to mm-new and damon-new.

Quoted 79 lines
Quoted 79 lines

Below, repeat_controls is removed and the existing CTX.head is modified to loop once(1st rotation). This simplifies list processing and creates a more efficient structure.

Modified while loop:
Not used repeat_controls:

CTX.head <-----> C.list <-----> C.list <----> C.list <-------+
| | |
if (C.repeat) if (!C.repeat) |
| | |
list_del() list_del() |
| | |
| complete() |
| |
first --------> list_add_tail() -----------+

if (C.list == first) break;

---
 mm/damon/core.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

Quoted 4 lines

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Maybe my explanation was not enough. Let me explain a bit in more detail.

In the scenario I mentioned, at the first iteration of the loop, 'first' will be the first control object, which has ->repeat unset. The object will be removed from the list. In the second iteration of the loop, it handles the second object, which has ->repeat set. The object is added to the list again. In the third iteration, the loop runs for the second object again. Because it is not same to 'first', the 'break' statement is not reached. The loop continues forever.

Quoted 1 line

Am I missing something?

Thank you for your detailed review.
There may be cases where C->repeat=false is the first control. This can also be solved simply as follows:

@@ -2567,9 +2599,6 @@ static void kdamond_call(struct damon_ctx *ctx, bool cancel)

                if (!control || control == first)
                        break;

- if (++idx == 1)
- first = control;
-

                if (cancel)
                        control->canceled = true;
                else
@@ -2589,6 +2618,8 @@ static void kdamond_call(struct damon_ctx *ctx,
bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list, &ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
+                       if (++idx == 1)
+                               first = control;
                }
        }

}

Thanks,
JaeJoon

Quoted 6 lines

Thanks,
SJ

[...]

maintainer
#5 lore raw
Quoted 25 lines · On Fri, 26 Dec 2025 11:19:28 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 17 lines · SeongJae Park
Quoted 14 lines · On Thu, 25 Dec 2025 12:10:30 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 12 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

Quoted 4 lines
Quoted 1 line

This is because kdamond_call() is called repeatedly in kdamond_fn().

Yes, it is repeatedly called. But, my question is, does it impose overhead that great enough to make a negative impact to the real world.

I agree that the overhead is not that much since there are only a few lists added to ctx->call_controls(CTX.head).

[...]

Quoted 103 lines
Quoted 77 lines
Quoted 62 lines
Quoted 53 lines
Quoted 53 lines
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

Quoted 4 lines

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Maybe my explanation was not enough. Let me explain a bit in more detail.

In the scenario I mentioned, at the first iteration of the loop, 'first' will be the first control object, which has ->repeat unset. The object will be removed from the list. In the second iteration of the loop, it handles the second object, which has ->repeat set. The object is added to the list again. In the third iteration, the loop runs for the second object again. Because it is not same to 'first', the 'break' statement is not reached. The loop continues forever.

Quoted 1 line

Am I missing something?

Thank you for your detailed review.
There may be cases where C->repeat=false is the first control. This can also be solved simply as follows:

(quoted diff) +0 -3
@@ -2567,9 +2599,6 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                if (!control || control == first)
                        break;
 
-               if (++idx == 1)
-                       first = control;
-
                if (cancel)
                        control->canceled = true;

else

mm/damon/core.c +2 -0
@@ -2589,6 +2618,8 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list, &ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
+                       if (++idx == 1)
+                               first = control;
                }
        }
Quoted 1 line

}

Yes, that should fix the issue.

And it seems 'idx' is being used for only this? If I'm not wrong, I think it may be easier to read if you do something like 'first = first ? first :
control' and drop 'idx'.

Thanks,
SJ

[...]

#6 lore raw
Quoted 136 lines · SeongJae Park
Quoted 25 lines · On Fri, 26 Dec 2025 11:19:28 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 17 lines · SeongJae Park
Quoted 14 lines · On Thu, 25 Dec 2025 12:10:30 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 12 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

Quoted 4 lines
Quoted 1 line

This is because kdamond_call() is called repeatedly in kdamond_fn().

Yes, it is repeatedly called. But, my question is, does it impose overhead that great enough to make a negative impact to the real world.

I agree that the overhead is not that much since there are only a few lists added to ctx->call_controls(CTX.head).

[...]

Quoted 103 lines
Quoted 77 lines
Quoted 62 lines
Quoted 53 lines
Quoted 53 lines
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

Quoted 4 lines

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Maybe my explanation was not enough. Let me explain a bit in more detail.

In the scenario I mentioned, at the first iteration of the loop, 'first' will be the first control object, which has ->repeat unset. The object will be removed from the list. In the second iteration of the loop, it handles the second object, which has ->repeat set. The object is added to the list again. In the third iteration, the loop runs for the second object again. Because it is not same to 'first', the 'break' statement is not reached. The loop continues forever.

Quoted 1 line

Am I missing something?

Thank you for your detailed review.
There may be cases where C->repeat=false is the first control. This can also be solved simply as follows:

(quoted diff) +0 -3
@@ -2567,9 +2599,6 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                if (!control || control == first)
                        break;
 
-               if (++idx == 1)
-                       first = control;
-
                if (cancel)
                        control->canceled = true;

else

mm/damon/core.c +2 -0
@@ -2589,6 +2618,8 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list, &ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
+                       if (++idx == 1)
+                               first = control;
                }
        }
Quoted 1 line

}

Yes, that should fix the issue.

Quoted 3 lines

And it seems 'idx' is being used for only this? If I'm not wrong, I think it may be easier to read if you do something like 'first = first ? first :
control' and drop 'idx'.

It's better removing idx.
Thanks.
JaeJoon

@@ -2587,7 +2587,6 @@ static void kdamond_usleep(unsigned long usecs)
static void kdamond_call(struct damon_ctx *ctx, bool cancel)

 {
        struct damon_call_control *control, *first = NULL;

- unsigned int idx = 0;

        while (true) {
                mutex_lock(&ctx->call_controls_lock);
@@ -2618,8 +2617,8 @@ static void kdamond_call(struct damon_ctx *ctx,
bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list,
&ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
-                       if (++idx == 1)
-                               first = control;
+
+                       first = (first) ? first : control;
                }
        }

}

Quoted 6 lines

Thanks,
SJ

[...]

#7 lore raw

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

Quoted 174 lines · JaeJoon Jung
Quoted 136 lines · SeongJae Park
Quoted 25 lines · On Fri, 26 Dec 2025 11:19:28 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 17 lines · SeongJae Park
Quoted 14 lines · On Thu, 25 Dec 2025 12:10:30 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 12 lines · SeongJae Park
Quoted 4 lines · On Wed, 24 Dec 2025 21:43:54 +0900 JaeJoon Jung <[email protected]> wrote:

The kdamond_call() function is executed repeatedly in the kdamond_fn() kernel thread. The kdamond_call() function is implemented as a while loop. Therefore, it is important to improve the list processing logic here to ensure faster execution of control->fn().

That depends on how critical the performance is, and how much complexity the optimization introduces. I have no idea about if the performance of kdamond_call() is really important. If you have a realistic use case that shows it, sharing it would be nice.

Quoted 4 lines
Quoted 1 line

This is because kdamond_call() is called repeatedly in kdamond_fn().

Yes, it is repeatedly called. But, my question is, does it impose overhead that great enough to make a negative impact to the real world.

I agree that the overhead is not that much since there are only a few lists added to ctx->call_controls(CTX.head).

[...]

Quoted 103 lines
Quoted 77 lines
Quoted 62 lines
Quoted 53 lines
Quoted 53 lines
mm/damon/core.c +18 -11
index 824aa8f22db3..babad37719b6 100644
@@ -2554,42 +2554,43 @@ static void kdamond_usleep(unsigned long usecs)
  */
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
-     struct damon_call_control *control;
-     LIST_HEAD(repeat_controls);
-     int ret = 0;
+     struct damon_call_control *control, *first = NULL;
+     unsigned int idx = 0;
 
      while (true) {
              mutex_lock(&ctx->call_controls_lock);
              control = list_first_entry_or_null(&ctx->call_controls,
                              struct damon_call_control, list);
              mutex_unlock(&ctx->call_controls_lock);
-             if (!control)
+
+             /* check control empty or 1st rotation */
+             if (!control || control == first)
                      break;
-             if (cancel) {
+
+             if (++idx == 1)
+                     first = control;
+
+             if (cancel)
                      control->canceled = true;
-             } else {
-                     ret = control->fn(control->data);
-                     control->return_code = ret;
-             }
+             else
+                     control->return_code = control->fn(control->data);
+
              mutex_lock(&ctx->call_controls_lock);
              list_del(&control->list);
              mutex_unlock(&ctx->call_controls_lock);
+
              if (!control->repeat) {
+                     /* run control->fn() one time */
                      complete(&control->completion);
              } else if (control->canceled && control->dealloc_on_cancel) {
                      kfree(control);
-                     continue;
              } else {
-                     list_add(&control->list, &repeat_controls);
+                     /* to repeat next time */
+                     mutex_lock(&ctx->call_controls_lock);
+                     list_add_tail(&control->list, &ctx->call_controls);
Quoted 8 lines

mm/damon/core.c static void kdamond_usleep(unsigned long usecs) · line 2593

Quoted 3 lines
mm/damon/core.c +1 -0
+                     mutex_unlock(&ctx->call_controls_lock);
              }
      }

Let's suppose there are two damon_call_control objects on the ctx->call_controls. The first one has ->repeat unset, while the second one has. Then, it seems the 'break' condition will never met and therefore this loop will never finished. Am I missing something?

Quoted 4 lines

You misjudged.
If (!C.repeat), it will be removed with list_del() and disappear. If (C.repeat) loops through the loop once, and when it returns to the first, it breaks.

Maybe my explanation was not enough. Let me explain a bit in more detail.

In the scenario I mentioned, at the first iteration of the loop, 'first' will be the first control object, which has ->repeat unset. The object will be removed from the list. In the second iteration of the loop, it handles the second object, which has ->repeat set. The object is added to the list again. In the third iteration, the loop runs for the second object again. Because it is not same to 'first', the 'break' statement is not reached. The loop continues forever.

Quoted 1 line

Am I missing something?

Thank you for your detailed review.
There may be cases where C->repeat=false is the first control. This can also be solved simply as follows:

(quoted diff) +0 -3
@@ -2567,9 +2599,6 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                if (!control || control == first)
                        break;
 
-               if (++idx == 1)
-                       first = control;
-
                if (cancel)
                        control->canceled = true;

else

(quoted diff) +2 -0
@@ -2589,6 +2618,8 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list, &ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
+                       if (++idx == 1)
+                               first = control;
                }
        }
Quoted 1 line

}

Yes, that should fix the issue.

Quoted 3 lines

And it seems 'idx' is being used for only this? If I'm not wrong, I think it may be easier to read if you do something like 'first = first ? first :
control' and drop 'idx'.

It's better removing idx.
Thanks.
JaeJoon

(quoted diff) +2 -3
@@ -2587,7 +2587,6 @@ static void kdamond_usleep(unsigned long usecs)
 static void kdamond_call(struct damon_ctx *ctx, bool cancel)
 {
        struct damon_call_control *control, *first = NULL;
-       unsigned int idx = 0;
 
        while (true) {
                mutex_lock(&ctx->call_controls_lock);
@@ -2618,8 +2617,8 @@ static void kdamond_call(struct damon_ctx *ctx,
 bool cancel)
                        mutex_lock(&ctx->call_controls_lock);
                        list_add_tail(&control->list,
 &ctx->call_controls);
                        mutex_unlock(&ctx->call_controls_lock);
-                       if (++idx == 1)
-                               first = control;
+
+                       first = (first) ? first : control;
                }
        }

}

Quoted 6 lines

Thanks,
SJ

[...]

maintainer
#8 lore raw
Quoted 2 lines · On Tue, 30 Dec 2025 09:14:37 +0900 JaeJoon Jung <[email protected]> wrote:

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

I just found my fix [1] of the bug that you reported has a race condition. And to fix that, I think kdamond_call() will anyway need to be modified. I will shortly send more details as a reply to the fix [1]. Can you please hold this refactoring until all discussions about the bug fix is done? Sorry for your inconvenience.

[1] https://lore.kernel.org/[email protected]

Thanks,
SJ

[...]

maintainer
#9 lore raw
Quoted 5 lines · On Mon, 29 Dec 2025 16:57:15 -0800 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Tue, 30 Dec 2025 09:14:37 +0900 JaeJoon Jung <[email protected]> wrote:

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

Quoted 7 lines

I just found my fix [1] of the bug that you reported has a race condition. And to fix that, I think kdamond_call() will anyway need to be modified. I will shortly send more details as a reply to the fix [1]. Can you please hold this refactoring until all discussions about the bug fix is done? Sorry for your inconvenience.

[1] https://lore.kernel.org/[email protected]

I ended up sending the new version of the fix [1] without changes on kdamond_call(). Unless you have concerns on the fix, please feel free to proceed to v2 of this patch. Thank you for patiently waiting.

[1] https://lore.kernel.org/[email protected]

Thanks,
SJ

[...]

#10 lore raw
Quoted 14 lines · SeongJae Park
Quoted 11 lines · On Mon, 29 Dec 2025 16:57:15 -0800 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Tue, 30 Dec 2025 09:14:37 +0900 JaeJoon Jung <[email protected]> wrote:

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

I just found my fix [1] of the bug that you reported has a race condition. And to fix that, I think kdamond_call() will anyway need to be modified. I will shortly send more details as a reply to the fix [1]. Can you please hold this refactoring until all discussions about the bug fix is done? Sorry for your inconvenience.

Quoted 7 lines
Quoted 1 line

[1] https://lore.kernel.org/[email protected]

I ended up sending the new version of the fix [1] without changes on kdamond_call(). Unless you have concerns on the fix, please feel free to proceed to v2 of this patch. Thank you for patiently waiting.

[1] https://lore.kernel.org/[email protected]

My patch for the kdamond_call() function further improves control->list to behave as a FIFO. This also improves stability against the control->list collision issue encountered when damon_call() is called.
If there are no further objections, I'll send you Patch v2.

Thanks,
JaeJoon

Quoted 6 lines

Thanks,
SJ

[...]

maintainer
#11 lore raw
Quoted 21 lines · On Wed, 31 Dec 2025 15:23:49 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 20 lines · SeongJae Park
Quoted 5 lines · On Mon, 29 Dec 2025 16:57:15 -0800 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Tue, 30 Dec 2025 09:14:37 +0900 JaeJoon Jung <[email protected]> wrote:

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

Quoted 7 lines

I just found my fix [1] of the bug that you reported has a race condition. And to fix that, I think kdamond_call() will anyway need to be modified. I will shortly send more details as a reply to the fix [1]. Can you please hold this refactoring until all discussions about the bug fix is done? Sorry for your inconvenience.

[1] https://lore.kernel.org/[email protected]

I ended up sending the new version of the fix [1] without changes on kdamond_call(). Unless you have concerns on the fix, please feel free to proceed to v2 of this patch. Thank you for patiently waiting.

Quoted 6 lines
Quoted 1 line

[1] https://lore.kernel.org/[email protected]

My patch for the kdamond_call() function further improves control->list to behave as a FIFO. This also improves stability against the control->list collision issue encountered when damon_call() is called.
If there are no further objections, I'll send you Patch v2.

If you want to say something about damon_call() uaf issue, let's make a conclusion about it first, rather than mixing topics.

Thanks,
SJ

[...]

#12 lore raw
Quoted 26 lines · SeongJae Park
Quoted 23 lines · On Wed, 31 Dec 2025 15:23:49 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 21 lines · SeongJae Park
Quoted 5 lines · On Mon, 29 Dec 2025 16:57:15 -0800 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Tue, 30 Dec 2025 09:14:37 +0900 JaeJoon Jung <[email protected]> wrote:

I will reflect the above in patch v2.
Would you like me to resend patch v2 ?

Quoted 7 lines

I just found my fix [1] of the bug that you reported has a race condition. And to fix that, I think kdamond_call() will anyway need to be modified. I will shortly send more details as a reply to the fix [1]. Can you please hold this refactoring until all discussions about the bug fix is done? Sorry for your inconvenience.

[1] https://lore.kernel.org/[email protected]

I ended up sending the new version of the fix [1] without changes on kdamond_call(). Unless you have concerns on the fix, please feel free to proceed to v2 of this patch. Thank you for patiently waiting.

[1] https://lore.kernel.org/[email protected]

Quoted 7 lines
Quoted 4 lines

My patch for the kdamond_call() function further improves control->list to behave as a FIFO. This also improves stability against the control->list collision issue encountered when damon_call() is called.
If there are no further objections, I'll send you Patch v2.

If you want to say something about damon_call() uaf issue, let's make a conclusion about it first, rather than mixing topics.

I agree.
I hope you first resolve the damon_call() issue, and then move on to v2 for kdamond_call(), which I patched. That would be clearer and less confusing.

Thanks,
JaeJoon

Quoted 6 lines

Thanks,
SJ

[...]