Message ID | 20220914093636.1184590-1-yajun.deng@linux.dev (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/damon: fix missing damon_del_region() | expand |
Hi Yajun, On Wed, 14 Sep 2022 17:36:36 +0800 Yajun Deng <yajun.deng@linux.dev> wrote: > It should be called damon_del_region() before free each region, so use > damon_destroy_region() instead of damon_free_region(). What 'damon_del_region()' does is deleting the region from target's regions linked list so that nobody references it later after its freed. However, as each region is linked to one target, and as we will free the target here, the list will also be freed. Therefore, we don't need to worry about future references to the region. Anything I'm missing? Thanks, SJ > > Fixes: f23b8eee1871 (mm/damon/core: implement region-based sampling) > Signed-off-by: Yajun Deng <yajun.deng@linux.dev> > --- > mm/damon/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/damon/core.c b/mm/damon/core.c > index 0b1eb945c68a..e62e7ebf4b12 100644 > --- a/mm/damon/core.c > +++ b/mm/damon/core.c > @@ -361,7 +361,7 @@ void damon_free_target(struct damon_target *t) > struct damon_region *r, *next; > > damon_for_each_region_safe(r, next, t) > - damon_free_region(r); > + damon_destroy_region(r, t); > kfree(t); > } > > -- > 2.25.1
September 14, 2022 5:52 PM, "SeongJae Park" <sj@kernel.org> wrote: > Hi Yajun, > > On Wed, 14 Sep 2022 17:36:36 +0800 Yajun Deng <yajun.deng@linux.dev> wrote: > >> It should be called damon_del_region() before free each region, so use >> damon_destroy_region() instead of damon_free_region(). > > What 'damon_del_region()' does is deleting the region from target's regions > linked list so that nobody references it later after its freed. However, as > each region is linked to one target, and as we will free the target here, the > list will also be freed. Therefore, we don't need to worry about future > references to the region. > > Anything I'm missing? > OK, got it. > Thanks, > SJ > >> Fixes: f23b8eee1871 (mm/damon/core: implement region-based sampling) >> Signed-off-by: Yajun Deng <yajun.deng@linux.dev> >> --- >> mm/damon/core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/damon/core.c b/mm/damon/core.c >> index 0b1eb945c68a..e62e7ebf4b12 100644 >> --- a/mm/damon/core.c >> +++ b/mm/damon/core.c >> @@ -361,7 +361,7 @@ void damon_free_target(struct damon_target *t) >> struct damon_region *r, *next; >> >> damon_for_each_region_safe(r, next, t) >> - damon_free_region(r); >> + damon_destroy_region(r, t); >> kfree(t); >> } >> >> -- >> 2.25.1
diff --git a/mm/damon/core.c b/mm/damon/core.c index 0b1eb945c68a..e62e7ebf4b12 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -361,7 +361,7 @@ void damon_free_target(struct damon_target *t) struct damon_region *r, *next; damon_for_each_region_safe(r, next, t) - damon_free_region(r); + damon_destroy_region(r, t); kfree(t); }
It should be called damon_del_region() before free each region, so use damon_destroy_region() instead of damon_free_region(). Fixes: f23b8eee1871 (mm/damon/core: implement region-based sampling) Signed-off-by: Yajun Deng <yajun.deng@linux.dev> --- mm/damon/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)