All of lore.kernel.org
 help / color / mirror / Atom feed
* [Question] About damon_set_regions function.
@ 2022-09-06  3:19 Yun Levi
  2022-09-06 17:55 ` SeongJae Park
  0 siblings, 1 reply; 5+ messages in thread
From: Yun Levi @ 2022-09-06  3:19 UTC (permalink / raw)
  To: sj; +Cc: damon

Hello damon community.
I'm a beginner of damon who want to use it well :)

While I'm reading the damon core code,
I have a question about the "damon_set_regions" function's features.

Comment said that
"This function adds new regions to, or modify existing regions of a
monitoring target to fit in specific ranges".

But I don't know if it's correct in the case below:

Suppose, target already has 2 ranges one of them is 4K to 16K and the
other 24K to 32K
And someone calls damon_set_regions with a range 8K to 28K.

In that situation, damon_set_regions function will modify existing two
region like
    - first as 8K to 16K
    - last as 24K to 28K

base on below code snippet:
         } else {
              /* resize intersecting regions to fit in this range */
              first->ar.start = ALIGN_DOWN(range->start,
                      DAMON_MIN_REGION);
              last->ar.end = ALIGN(range->end, DAMON_MIN_REGION);
         }

But, I don't know the reason why the region having 16K to 24K range
isn't added to the target region list and it's correct or not.

In my thinking,  there should be the code adding the region like:

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 7d25dc582fe3..f755efca71b2 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -225,6 +225,15 @@ int damon_set_regions(struct damon_target *t,
struct damon_addr_range *ranges,
                        first->ar.start = ALIGN_DOWN(range->start,
                                        DAMON_MIN_REGION);
                        last->ar.end = ALIGN(range->end, DAMON_MIN_REGION);
+
+                       if (first != last) {
+                               newr = damon_new_region(
+                                               first->ar.end,
last->ar_start); /**< already aligned. */
+                               if (!newr)
+                                       return -ENOMEM;
+
+                               damon_insert_region(newr, first, last, t);
+                       }
                }
        }
        return 0;

Am I wrong?

Thanks.

-- 
Best regards,
Levi

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-08  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-06  3:19 [Question] About damon_set_regions function Yun Levi
2022-09-06 17:55 ` SeongJae Park
2022-09-07  4:50   ` Yun Levi
2022-09-07 16:35     ` SeongJae Park
2022-09-08  0:04       ` Yun Levi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.