* [PATCH v4] mm/damon: simplify scheme create in lru_sort.c
@ 2022-09-15 13:30 SeongJae Park
2022-09-15 14:06 ` haoxin
0 siblings, 1 reply; 2+ messages in thread
From: SeongJae Park @ 2022-09-15 13:30 UTC (permalink / raw)
To: akpm; +Cc: damon, linux-mm, linux-kernel, Xin Hao, SeongJae Park
From: Xin Hao <xhao@linux.alibaba.com>
In damon_lru_sort_new_hot_scheme() and damon_lru_sort_new_cold_scheme(),
they have so much in common, so we can combine them into a single
function, and we just need to distinguish their differences.
Suggested-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
changes from v3
(https://lore.kernel.org/damon/20220915023655.41923-1-xhao@linux.alibaba.com/)
- Cosmetic cleanups
Changes from v2
(https://lore.kernel.org/linux-mm/20220914113859.37637-1-xhao@linux.alibaba.com/)
- Add static global 'struct damos_access_pattern' stub variable
mm/damon/lru_sort.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index 46e7c0738bc5..abfaf471e3e9 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -132,6 +132,18 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat,
lru_sort_tried_cold_regions, lru_sorted_cold_regions,
cold_quota_exceeds);
+struct damos_access_pattern damon_lru_sort_stub_pattern = {
+ /* Find regions having PAGE_SIZE or larger size */
+ .min_sz_region = PAGE_SIZE,
+ .max_sz_region = ULONG_MAX,
+ /* no matter its access frequency */
+ .min_nr_accesses = 0,
+ .max_nr_accesses = UINT_MAX,
+ /* no matter its age */
+ .min_age_region = 0,
+ .max_age_region = UINT_MAX,
+};
+
static struct damon_ctx *ctx;
static struct damon_target *target;
@@ -157,36 +169,19 @@ static struct damos *damon_lru_sort_new_scheme(
/* Create a DAMON-based operation scheme for hot memory regions */
static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres)
{
- struct damos_access_pattern pattern = {
- /* Find regions having PAGE_SIZE or larger size */
- .min_sz_region = PAGE_SIZE,
- .max_sz_region = ULONG_MAX,
- /* and accessed for more than the threshold */
- .min_nr_accesses = hot_thres,
- .max_nr_accesses = UINT_MAX,
- /* no matter its age */
- .min_age_region = 0,
- .max_age_region = UINT_MAX,
- };
+ struct damos_access_pattern pattern = damon_lru_sort_stub_pattern;
+ pattern.min_nr_accesses = hot_thres;
return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_PRIO);
}
/* Create a DAMON-based operation scheme for cold memory regions */
static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
{
- struct damos_access_pattern pattern = {
- /* Find regions having PAGE_SIZE or larger size */
- .min_sz_region = PAGE_SIZE,
- .max_sz_region = ULONG_MAX,
- /* and not accessed at all */
- .min_nr_accesses = 0,
- .max_nr_accesses = 0,
- /* for min_age or more micro-seconds */
- .min_age_region = cold_thres,
- .max_age_region = UINT_MAX,
- };
+ struct damos_access_pattern pattern = damon_lru_sort_stub_pattern;
+ pattern.max_nr_accesses = 0;
+ pattern.min_age_region = cold_thres;
return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO);
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v4] mm/damon: simplify scheme create in lru_sort.c
2022-09-15 13:30 [PATCH v4] mm/damon: simplify scheme create in lru_sort.c SeongJae Park
@ 2022-09-15 14:06 ` haoxin
0 siblings, 0 replies; 2+ messages in thread
From: haoxin @ 2022-09-15 14:06 UTC (permalink / raw)
To: SeongJae Park, akpm; +Cc: damon, linux-mm, linux-kernel
Reviewed-by: Xin Hao <xhao@linux.alibaba.com>
Thanks.
在 2022/9/15 下午9:30, SeongJae Park 写道:
> From: Xin Hao <xhao@linux.alibaba.com>
>
> In damon_lru_sort_new_hot_scheme() and damon_lru_sort_new_cold_scheme(),
> they have so much in common, so we can combine them into a single
> function, and we just need to distinguish their differences.
>
> Suggested-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
> changes from v3
> (https://lore.kernel.org/damon/20220915023655.41923-1-xhao@linux.alibaba.com/)
> - Cosmetic cleanups
>
> Changes from v2
> (https://lore.kernel.org/linux-mm/20220914113859.37637-1-xhao@linux.alibaba.com/)
> - Add static global 'struct damos_access_pattern' stub variable
>
> mm/damon/lru_sort.c | 39 +++++++++++++++++----------------------
> 1 file changed, 17 insertions(+), 22 deletions(-)
>
> diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
> index 46e7c0738bc5..abfaf471e3e9 100644
> --- a/mm/damon/lru_sort.c
> +++ b/mm/damon/lru_sort.c
> @@ -132,6 +132,18 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat,
> lru_sort_tried_cold_regions, lru_sorted_cold_regions,
> cold_quota_exceeds);
>
> +struct damos_access_pattern damon_lru_sort_stub_pattern = {
> + /* Find regions having PAGE_SIZE or larger size */
> + .min_sz_region = PAGE_SIZE,
> + .max_sz_region = ULONG_MAX,
> + /* no matter its access frequency */
> + .min_nr_accesses = 0,
> + .max_nr_accesses = UINT_MAX,
> + /* no matter its age */
> + .min_age_region = 0,
> + .max_age_region = UINT_MAX,
> +};
> +
> static struct damon_ctx *ctx;
> static struct damon_target *target;
>
> @@ -157,36 +169,19 @@ static struct damos *damon_lru_sort_new_scheme(
> /* Create a DAMON-based operation scheme for hot memory regions */
> static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres)
> {
> - struct damos_access_pattern pattern = {
> - /* Find regions having PAGE_SIZE or larger size */
> - .min_sz_region = PAGE_SIZE,
> - .max_sz_region = ULONG_MAX,
> - /* and accessed for more than the threshold */
> - .min_nr_accesses = hot_thres,
> - .max_nr_accesses = UINT_MAX,
> - /* no matter its age */
> - .min_age_region = 0,
> - .max_age_region = UINT_MAX,
> - };
> + struct damos_access_pattern pattern = damon_lru_sort_stub_pattern;
>
> + pattern.min_nr_accesses = hot_thres;
> return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_PRIO);
> }
>
> /* Create a DAMON-based operation scheme for cold memory regions */
> static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
> {
> - struct damos_access_pattern pattern = {
> - /* Find regions having PAGE_SIZE or larger size */
> - .min_sz_region = PAGE_SIZE,
> - .max_sz_region = ULONG_MAX,
> - /* and not accessed at all */
> - .min_nr_accesses = 0,
> - .max_nr_accesses = 0,
> - /* for min_age or more micro-seconds */
> - .min_age_region = cold_thres,
> - .max_age_region = UINT_MAX,
> - };
> + struct damos_access_pattern pattern = damon_lru_sort_stub_pattern;
>
> + pattern.max_nr_accesses = 0;
> + pattern.min_age_region = cold_thres;
> return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO);
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-15 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15 13:30 [PATCH v4] mm/damon: simplify scheme create in lru_sort.c SeongJae Park
2022-09-15 14:06 ` haoxin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox