mm/damon/core: remove unnecessary si_meminfo invoke.
Subsystems (2)
PATCH v2 1/1 mm/damon/core: remove unnecessary si_meminfo invoke.
si_meminfo() will read and assign more info not just free/ram pages. For just DAMOS_WMARK_FREE_MEM_RATE use, only get free and ram pages is ok to save cpu.
Change from v1:
v1 fold free mem rate logic into __damos_get_wmark_free_mem_rate and not invoke si_meminfo, just get free/ram_pages in global.
v2 cancel this __damos_get_wmark_free_mem_rate and just calculate rate in damos_wmark_metric_value to keep it simple.
--- mm/damon/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/damon/core.c +1 -4
@@ -1280,12 +1280,9 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)static unsigned long damos_wmark_metric_value (enum damos_wmark_metric metric) { -struct sysinfo i; -switch (metric) {case DAMOS_WMARK_FREE_MEM_RATE : -si_meminfo (&i); -return i.freeram *1000 / i.totalram; +return global_zone_page_state (NR_FREE_PAGES ) *1000 /totalram_pages ();default :break ; }
Signature · 1 line
2.34.1
Hi Huan,
Quoted 9 lines · On Tue, 19 Sep 2023 10:00:57 +0800 Huan Yang <[email protected]> wrote:
si_meminfo()will read and assign more info not just free/ram pages. For justDAMOS_WMARK_FREE_MEM_RATEuse, only get free and ram pages is ok to save cpu.Change from v1:
v1 fold free mem rate logic into__damos_get_wmark_free_mem_rateand not invokesi_meminfo, just get free/ram_pages in global.
v2 cancel this__damos_get_wmark_free_mem_rateand just calculate rate indamos_wmark_metric_valueto keep it simple.
Thank you for accepting my suggestion and making this change. Nevertheless, we usually not keep patch changelogs on commit message but after the '---' line[1].
Quoted 2 lines
Signed-off-by Huan Yang <[email protected]>
Other than above and below trivial comments,
Quoted 1 line
---
This is usual place for patch changelogs.
Quoted 8 lines
mm/damon/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/damon/core.c +0
-0
mm/damon/core.c static bool kdamond_need_stop(struct damon_ctx *ctx) · line 1285
Quoted 10 lines
mm/damon/core.c +1
-4@@ -1280,12 +1280,9 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)static unsigned long damos_wmark_metric_value (enum damos_wmark_metric metric) { -struct sysinfo i; -switch (metric) {case DAMOS_WMARK_FREE_MEM_RATE : -si_meminfo (&i); -return i.freeram *1000 / i.totalram; +return global_zone_page_state (NR_FREE_PAGES ) *1000 /totalram_pages ();
DAMON code still prefer 80 columns limit[2] (sorry for being stubborn). Could you please break this line for that?
Quoted 6 lines
mm/damon/core.c +0
-0default :break ; }Signature · 1 line
2.34.1
[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format
[2] https://docs.kernel.org/process/coding-style.html#indentation
Thanks,
SJ
Quoted 19 lines · SeongJae Park
[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Hi Huan,
Quoted 9 lines · On Tue, 19 Sep 2023 10:00:57 +0800 Huan Yang <[email protected]> wrote:
si_meminfo()will read and assign more info not just free/ram pages. For justDAMOS_WMARK_FREE_MEM_RATEuse, only get free and ram pages is ok to save cpu.Change from v1:
v1 fold free mem rate logic into__damos_get_wmark_free_mem_rateand not invokesi_meminfo, just get free/ram_pages in global.
v2 cancel this__damos_get_wmark_free_mem_rateand just calculate rate indamos_wmark_metric_valueto keep it simple.Thank you for accepting my suggestion and making this change. Nevertheless, we usually not keep patch changelogs on commit message but after the '---' line[1].
Quoted 7 lines
Quoted 1 line
Signed-off-by Huan Yang <[email protected]>Other than above and below trivial comments,
Reviewed-by SeongJae Park <[email protected]>Quoted 1 line
---
This is usual place for patch changelogs.
Hi SJ, OK, I'll change this.
Quoted 11 lines
Quoted 11 lines
mm/damon/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/damon/core.c +0
-0@@ -1280,12 +1280,9 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)
Quoted 11 lines
mm/damon/core.c static bool kdamond_need_stop(struct damon_ctx *ctx) · line 1285
Quoted 9 lines
mm/damon/core.c +1
-4static unsigned long damos_wmark_metric_value (enum damos_wmark_metric metric) { -struct sysinfo i; -switch (metric) {case DAMOS_WMARK_FREE_MEM_RATE : -si_meminfo (&i); -return i.freeram *1000 / i.totalram; +return global_zone_page_state (NR_FREE_PAGES ) *1000 /totalram_pages ();DAMON code still prefer 80 columns limit[2] (sorry for being stubborn). Could you please break this line for that?
Sorry for break format rule, I'll change it.
Quoted 12 lines
Quoted 7 lines
mm/damon/core.c +0
-1default :break ; } --2.34.1
[1] https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format
[2] https://docs.kernel.org/process/coding-style.html#indentationThanks,
SJ
PATCH v3 1/1 mm/damon/core: remove unnecessary si_meminfo invoke.
si_meminfo() will read and assign more info not just free/ram pages. For just DAMOS_WMARK_FREE_MEM_RATE use, only get free and ram pages is ok to save cpu.
---
Change from v1:
v1 fold free mem rate logic into __damos_get_wmark_free_mem_rate and not invoke si_meminfo, just get free/ram_pages in global.
v2 cancel this __damos_get_wmark_free_mem_rate and just calculate rate in damos_wmark_metric_value to keep it simple.
v3 fix changelog format, fix code style.
mm/damon/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/damon/core.c +2 -4
@@ -1280,12 +1280,10 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)static unsigned long damos_wmark_metric_value (enum damos_wmark_metric metric) { -struct sysinfo i; -switch (metric) {case DAMOS_WMARK_FREE_MEM_RATE : -si_meminfo (&i); -return i.freeram *1000 / i.totalram; +return global_zone_page_state (NR_FREE_PAGES ) *1000 / +totalram_pages ();default :break ; }
Signature · 1 line
2.34.1
Hi Huan,
Quoted 5 lines · On Wed, 20 Sep 2023 09:57:27 +0800 Huan Yang <[email protected]> wrote:
si_meminfo()will read and assign more info not just free/ram pages. For justDAMOS_WMARK_FREE_MEM_RATEuse, only get free and ram pages is ok to save cpu.Signed-off-by Huan Yang <[email protected]>
Thanks,
SJ
Quoted 33 lines
---
Change from v1:
v1 fold free mem rate logic into__damos_get_wmark_free_mem_rateand not invokesi_meminfo, just get free/ram_pages in global.
v2 cancel this__damos_get_wmark_free_mem_rateand just calculate rate indamos_wmark_metric_valueto keep it simple.
v3 fix changelog format, fix code style.mm/damon/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)mm/damon/core.c +2
-4@@ -1280,12 +1280,10 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)static unsigned long damos_wmark_metric_value (enum damos_wmark_metric metric) { -struct sysinfo i; -switch (metric) {case DAMOS_WMARK_FREE_MEM_RATE : -si_meminfo (&i); -return i.freeram *1000 / i.totalram; +return global_zone_page_state (NR_FREE_PAGES ) *1000 / +totalram_pages ();default :break ; }Signature · 1 line
2.34.1