All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm/damon/core: remove unnecessary si_meminfo invoke.
@ 2023-09-19  2:00 Huan Yang
  2023-09-19 15:38 ` SeongJae Park
  0 siblings, 1 reply; 5+ messages in thread
From: Huan Yang @ 2023-09-19  2:00 UTC (permalink / raw)
  To: SeongJae Park, Andrew Morton, open list:DATA ACCESS MONITOR,
	open list:DATA ACCESS MONITOR, open list
  Cc: opensource.kernel, Huan Yang

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.

Signed-off-by: Huan Yang <link@vivo.com>
---
 mm/damon/core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index bcd2bd9d6c10..a3f812d78267 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -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;
 	}
-- 
2.34.1


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

* Re: [PATCH v2] mm/damon/core: remove unnecessary si_meminfo invoke.
  2023-09-19  2:00 [PATCH v2] mm/damon/core: remove unnecessary si_meminfo invoke Huan Yang
@ 2023-09-19 15:38 ` SeongJae Park
  2023-09-20  1:46   ` 杨欢
  0 siblings, 1 reply; 5+ messages in thread
From: SeongJae Park @ 2023-09-19 15:38 UTC (permalink / raw)
  To: Huan Yang
  Cc: SeongJae Park, Andrew Morton, open list:DATA ACCESS MONITOR,
	open list:DATA ACCESS MONITOR, open list, opensource.kernel

Hi Huan,

On Tue, 19 Sep 2023 10:00:57 +0800 Huan Yang <link@vivo.com> wrote:

> 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.

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].

> 
> Signed-off-by: Huan Yang <link@vivo.com>

Other than above and below trivial comments,

Reviewed-by: SeongJae Park <sj@kernel.org>

> ---

This is usual place for patch changelogs.


>  mm/damon/core.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index bcd2bd9d6c10..a3f812d78267 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -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?

>  	default:
>  		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#indentation

Thanks,
SJ

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

* Re: [PATCH v2] mm/damon/core: remove unnecessary si_meminfo invoke.
  2023-09-19 15:38 ` SeongJae Park
@ 2023-09-20  1:46   ` 杨欢
  2023-09-20  1:57     ` [PATCH v3] " Huan Yang
  0 siblings, 1 reply; 5+ messages in thread
From: 杨欢 @ 2023-09-20  1:46 UTC (permalink / raw)
  To: SeongJae Park, 杨欢
  Cc: Andrew Morton, open list:DATA ACCESS MONITOR,
	open list:DATA ACCESS MONITOR, open list, opensource.kernel

在 2023/9/19 23:38, SeongJae Park 写道:
> [Some people who received this message don't often get email from sj@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Hi Huan,
>
> On Tue, 19 Sep 2023 10:00:57 +0800 Huan Yang <link@vivo.com> wrote:
>
>> 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.
> 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].
>
>> Signed-off-by: Huan Yang <link@vivo.com>
> Other than above and below trivial comments,
>
> Reviewed-by: SeongJae Park <sj@kernel.org>
>
>> ---
> This is usual place for patch changelogs.
Hi SJ, OK, I'll change this.
>
>
>>   mm/damon/core.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/mm/damon/core.c b/mm/damon/core.c
>> index bcd2bd9d6c10..a3f812d78267 100644
>> --- a/mm/damon/core.c
>> +++ b/mm/damon/core.c
>> @@ -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?
Sorry for break format rule, I'll change it.
>
>>        default:
>>                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#indentation
>
> Thanks,
> SJ



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

* [PATCH v3] mm/damon/core: remove unnecessary si_meminfo invoke.
  2023-09-20  1:46   ` 杨欢
@ 2023-09-20  1:57     ` Huan Yang
  2023-09-20  7:19       ` SeongJae Park
  0 siblings, 1 reply; 5+ messages in thread
From: Huan Yang @ 2023-09-20  1:57 UTC (permalink / raw)
  To: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel
  Cc: opensource.kernel, Huan Yang

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.

Signed-off-by: Huan Yang <link@vivo.com>
---
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(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index bcd2bd9d6c10..6ceb52298904 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -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;
 	}
-- 
2.34.1


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

* Re: [PATCH v3] mm/damon/core: remove unnecessary si_meminfo invoke.
  2023-09-20  1:57     ` [PATCH v3] " Huan Yang
@ 2023-09-20  7:19       ` SeongJae Park
  0 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2023-09-20  7:19 UTC (permalink / raw)
  To: Huan Yang
  Cc: SeongJae Park, Andrew Morton, damon, linux-mm, linux-kernel,
	opensource.kernel

Hi Huan,

On Wed, 20 Sep 2023 09:57:27 +0800 Huan Yang <link@vivo.com> wrote:

> 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.
> 
> Signed-off-by: Huan Yang <link@vivo.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

> ---
> 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(-)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index bcd2bd9d6c10..6ceb52298904 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -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;
>  	}
> -- 
> 2.34.1

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

end of thread, other threads:[~2023-09-20  7:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19  2:00 [PATCH v2] mm/damon/core: remove unnecessary si_meminfo invoke Huan Yang
2023-09-19 15:38 ` SeongJae Park
2023-09-20  1:46   ` 杨欢
2023-09-20  1:57     ` [PATCH v3] " Huan Yang
2023-09-20  7:19       ` SeongJae Park

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.