All of lore.kernel.org
 help / color / mirror / Atom feed
From: teawater <teawaterz@linux.alibaba.com>
To: Chris Down <chris@chrisdown.name>
Cc: Hui Zhu <teawater@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	vdavydov.dev@gmail.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [RFC] memcg: Add swappiness to cgroup2
Date: Thu, 26 Dec 2019 14:56:40 +0800	[thread overview]
Message-ID: <6E9887B9-EEF7-406E-90D4-3FAEFE0A505E@linux.alibaba.com> (raw)
In-Reply-To: <20191225140546.GA311630@chrisdown.name>



> 在 2019年12月25日,22:05,Chris Down <chris@chrisdown.name> 写道:
> 
> Hi Hui,
> 
> Hui Zhu writes:
>> Even if cgroup2 has swap.max, swappiness is still a very useful config.
>> This commit add swappiness to cgroup2.
> 
> When submitting patches like this, it's important to explain *why* you want it and what evidence there is. For example, how should one use this to compose a reasonable system? Why aren't existing protection controls sufficient for your use case? Where's the data?
> 
> Also, why would swappiness be something cgroup-specific instead of hardware-specific, when desired swappiness is really largely about the hardware you have in your system?
> 
> I struggle to think of situations where per-cgroup swappiness would be useful, since it's really not a workload-specific setting.


Hi Chris,

My thought about per-cgroup swappiness is different applications should have different memory footprint.
For example, an application does a lot of file access work in a memory-constrained environment.  Its performance depend on the file access speed.  Keep more file cache will good for it.  Then more swappiness will good for it, especially with the high speed swap device(zram/zswap).
And in the same environment, an application that access anon memory a lot of times.  Use low swapiness will good for its performance.  But just let it not to swap is not a good for it because the code is inside file cache.  Just drop the file cache will decrease the application speed sometime.
Both of them are extreme examples.  Other applications maybe access both file and anon.  Maybe define a special swapiness is good for it.

This is what I thought about add swappiness to cgroup2.

Best,
Hui

> 
> Thanks,
> 
> Chris
> 
>> Signed-off-by: Hui Zhu <teawaterz@linux.alibaba.com>
>> ---
>> mm/memcontrol.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>> 
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index c5b5f74..e966396 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -7143,6 +7143,11 @@ static struct cftype swap_files[] = {
>> 		.file_offset = offsetof(struct mem_cgroup, swap_events_file),
>> 		.seq_show = swap_events_show,
>> 	},
>> +	{
>> +		.name = "swappiness",
>> +		.read_u64 = mem_cgroup_swappiness_read,
>> +		.write_u64 = mem_cgroup_swappiness_write,
>> +	},
>> 	{ }	/* terminate */
>> };
>> 
>> -- 
>> 2.7.4
>> 


  reply	other threads:[~2019-12-26  6:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-25  5:36 [RFC] memcg: Add swappiness to cgroup2 Hui Zhu
2019-12-25 14:05 ` Chris Down
2019-12-26  6:56   ` teawater [this message]
2020-01-03  9:48     ` Michal Koutný
2020-01-06 13:10   ` Michal Hocko
2020-01-06 13:24     ` Chris Down
2019-12-31 23:16 ` Andrew Morton
2020-01-02  1:44   ` teawater

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=6E9887B9-EEF7-406E-90D4-3FAEFE0A505E@linux.alibaba.com \
    --to=teawaterz@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=chris@chrisdown.name \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=teawater@gmail.com \
    --cc=vdavydov.dev@gmail.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 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.