From: 杨欢 <link@vivo.com>
To: "SeongJae Park" <sj@kernel.org>, 杨欢 <link@vivo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"open list:DATA ACCESS MONITOR" <damon@lists.linux.dev>,
"open list:DATA ACCESS MONITOR" <linux-mm@kvack.org>,
open list <linux-kernel@vger.kernel.org>,
opensource.kernel <opensource.kernel@vivo.com>
Subject: Re: [PATCH] mm/damon/core: remove unnecessary si_meminfo invoke.
Date: Tue, 19 Sep 2023 01:48:25 +0000 [thread overview]
Message-ID: <2b587774-4741-42d2-baff-eed2b032aaf1@vivo.com> (raw)
In-Reply-To: <20230918232615.60499-1-sj@kernel.org>
在 2023/9/19 7:26, 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 Mon, 18 Sep 2023 12:12:01 +0000 杨欢 <link@vivo.com> wrote:
>
>> 在 2023/9/18 20:08, 杨欢 写道:
>>> 在 2023/9/18 19:11, SeongJae Park 写道:
>>>> Hi Huan,
>>>>
>>>> On Mon, 18 Sep 2023 17:49:34 +0800 Huan Yang <link@vivo.com> wrote:
>>>>
>>>>> si_meminfo() will read and assign more info not just free/ram pages.
>>>> Nice catch :)
>>>>
>>>>> 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>
>>>>> ---
>>>>> mm/damon/core.c | 10 ++++++----
>>>>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>>>>
>>>>> diff --git a/mm/damon/core.c b/mm/damon/core.c
>>>>> index bcd2bd9d6c10..1cddee9ae73b 100644
>>>>> --- a/mm/damon/core.c
>>>>> +++ b/mm/damon/core.c
>>>>> @@ -1278,14 +1278,16 @@ static bool kdamond_need_stop(struct damon_ctx *ctx)
>>>>> return true;
>>>>> }
>>>>>
>>>>> -static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
>>>>> +static unsigned long __damons_get_wmark_free_mem_rate(void)
>>>> Nit. s/damons/damos/ would look more consistently, in my opinion?
>>> HI, SJ, sorry, what's this mean?
>> Haha, I get, yes, damos is better. If you agree with below, I will
>> resend a new, rename to
>>
>> __damos_get_wmark_free_mem_rate.
>>
>>>>> {
>>>>> - struct sysinfo i;
>>>>> + return global_zone_page_state(NR_FREE_PAGES) * 1000 / totalram_pages();
>>>>> +}
>>>>>
>>>>> +static unsigned long damos_wmark_metric_value(enum damos_wmark_metric metric)
>>>>> +{
>>>>> switch (metric) {
>>>>> case DAMOS_WMARK_FREE_MEM_RATE:
>>>>> - si_meminfo(&i);
>>>>> - return i.freeram * 1000 / i.totalram;
>>>>> + return __damons_get_wmark_free_mem_rate();
>>>> Since __damons_get_wmark_free_mem_rate() is just one line function and
>>>> damos_wmark_metric_value() is the only user of the code, I think we could just
>>>> writ the code here?
>>> I do this in mine first patch, but then, I fold this into
>>> "__damons_get_wmark_free_mem_rate"
>>>
>>> due to I think the "__damons_get_wmark_free_mem_rate" may change the
>>> meaning for furture,
>>>
>>> and may si_meminfo will come back soon?(If we need more info to get the
>>> rate?). And, also, the
>>>
>>> static function If just some user use, it will be inline, so, I just
>>> think fold it will be better.
>>>
>>> Do you think so?
> Unfortunately I don't think so. What would be the future use case that would
> require changing the meaning of the metric? I cannot imagine those off the top
Maybe care about [min, low, high] watermark? Or someting. But,
> of my head. Even if such use case is found, such change would be a
> user-visible behavioral change, which we would like to avoid. If such change
> is really needed, I think we would keep the current metric as is and create an
> alternative metric that having the new meaning. Anyway, we can think about
> such case when it really happened.
Yes, you are right, if need a new case, just create an alternative metric.
>
> Also, the current code is doing the calculation in damos_wmark_metric_value().
> If there is no specific reason to split the logic out to a new function, I'd
> prefer keeping the overall structure as similar as is now.
>
> Please let me know if I'm missing something.
No sure reason to split it into function, keep it in
damos_wmark_metric_value() is
better.
I'll send new patch.
Thanks,
Huan
>
>
> Thanks,
> SJ
>
>>> Thanks,
>>>
>>> Huan
>>>
>>>>> default:
>>>>> break;
>>>>> }
>>>>> --
>>>>> 2.34.1
>>>> Thanks,
>>>> SJ
>>
prev parent reply other threads:[~2023-09-19 1:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230918094934.18123-1-link@vivo.com>
2023-09-18 11:11 ` SeongJae Park
2023-09-18 12:08 ` 杨欢
2023-09-18 12:12 ` 杨欢
2023-09-18 23:26 ` SeongJae Park
2023-09-19 1:48 ` 杨欢 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2b587774-4741-42d2-baff-eed2b032aaf1@vivo.com \
--to=link@vivo.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=opensource.kernel@vivo.com \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox