mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huan Yang <11133793@vivo.com>
To: Dan Schatzberg <schatzberg.dan@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Yosry Ahmed <yosryahmed@google.com>, Huan Yang <link@vivo.com>,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org, Tejun Heo <tj@kernel.org>,
	Zefan Li <lizefan.x@bytedance.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Michal Hocko <mhocko@kernel.org>,
	Shakeel Butt <shakeelb@google.com>,
	Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Chris Li <chrisl@kernel.org>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	Yue Zhao <findns94@gmail.com>, Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH V4 1/2] mm: add defines for min/max swappiness
Date: Thu, 14 Dec 2023 10:00:02 +0800	[thread overview]
Message-ID: <e40aa928-4bcd-4acd-924a-d2f154845908@vivo.com> (raw)
In-Reply-To: <ZXnexTxt3JE8mEMV@dschatzberg-fedora-PF3DHTBV>


在 2023/12/14 0:41, Dan Schatzberg 写道:
> [Some people who received this message don't often get email from schatzberg.dan@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Wed, Dec 13, 2023 at 09:58:26AM +0800, Huan Yang wrote:
>> 在 2023/12/13 9:38, Dan Schatzberg 写道:
>>> [????????? schatzberg.dan@gmail.com ????????? https://aka.ms/LearnAboutSenderIdentification,????????????]
>>>
>>> We use the constants 0 and 200 in a few places in the mm code when
>>> referring to the min and max swappiness. This patch adds MIN_SWAPPINESS
>>> and MAX_SWAPPINESS #defines to improve clarity. There are no functional
>>> changes.
>>>
>>> Signed-off-by: Dan Schatzberg <schatzberg.dan@gmail.com>
>>> ---
>>>    include/linux/swap.h |  2 ++
>>>    mm/memcontrol.c      |  2 +-
>>>    mm/vmscan.c          | 10 +++++-----
>>>    3 files changed, 8 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/include/linux/swap.h b/include/linux/swap.h
>>> index f6dd6575b905..e2ab76c25b4a 100644
>>> --- a/include/linux/swap.h
>>> +++ b/include/linux/swap.h
>>> @@ -407,6 +407,8 @@ extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
>>>
>>>    #define MEMCG_RECLAIM_MAY_SWAP (1 << 1)
>>>    #define MEMCG_RECLAIM_PROACTIVE (1 << 2)
>>> +#define MIN_SWAPPINESS 0
>>> +#define MAX_SWAPPINESS 200
>> Do MAX_SWAPPINESS apply for all swapppiness? If so, maybe better change
>> swappiness sysctl define:
>> ```
>> sysctl.c:
>>
>> {
>>          .procname    = "swappiness",
>>          .data        = &vm_swappiness,
>>          .maxlen        = sizeof(vm_swappiness),
>>          .mode        = 0644,
>>          .proc_handler    = proc_dointvec_minmax,
>>          .extra1        = SYSCTL_ZERO,
>>          .extra2        = SYSCTL_TWO_HUNDRED,
>>      },
>>
>> ```
>>
>> Here hard code swappiness in [0, 200], and now add a new define.
> Yes, MAX_SWAPPINESS is a hard limit. I'm not sure what you're
> proposing here - the SYSCTL_ZERO and SYSCTL_TWO_HUNDRED values are a
I mean, MAX_SWAPPINESS and SYSCTL_TWO_HUNDRED  all limit swappiness,
but  are different definitions.

If swappiness change 200 into 400, you need to change here extra2 and your
MAX_SWAPPINESS. It's wierd.
> little different than the defines I added. I think most of the value
> is just consistently using the defines in the core mm code.
>
>> And many other code hard reference 200 into max value of swappiness, like:
>>
>> ```
>> memcontrol.c:
>> static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css,
>>                         struct cftype *cft, u64 val)
>> {
>>      struct mem_cgroup *memcg = mem_cgroup_from_css(css);
>>
>>      if (val > 200)
>>          return -EINVAL;
>>
>>      if (!mem_cgroup_is_root(memcg))
>>          memcg->swappiness = val;
>>      else
>>          vm_swappiness = val;
>>
>>      return 0;
>> }
> This one is already fixed in my patch.

  reply	other threads:[~2023-12-14  2:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  1:38 [PATCH V4 0/1] Add swappiness argument to memory.reclaim Dan Schatzberg
2023-12-13  1:38 ` [PATCH V4 1/2] mm: add defines for min/max swappiness Dan Schatzberg
2023-12-13  1:58   ` Huan Yang
2023-12-13 16:41     ` Dan Schatzberg
2023-12-14  2:00       ` Huan Yang [this message]
2023-12-13  1:38 ` [PATCH V4 2/2] mm: add swapiness= arg to memory.reclaim Dan Schatzberg
2023-12-13  2:05   ` Yu Zhao
2023-12-13 16:38     ` Dan Schatzberg
2023-12-14  4:28       ` Yosry Ahmed
2023-12-14  8:38   ` Michal Hocko
2023-12-14 18:22     ` Dan Schatzberg
2023-12-14 18:28       ` Yosry Ahmed
2023-12-15  8:50       ` Michal Hocko

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=e40aa928-4bcd-4acd-924a-d2f154845908@vivo.com \
    --to=11133793@vivo.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=chrisl@kernel.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=findns94@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=link@vivo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=schatzberg.dan@gmail.com \
    --cc=shakeelb@google.com \
    --cc=tj@kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=yosryahmed@google.com \
    /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

all inboxes | Powered by JetHome®