linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Roman Gushchin <guro@fb.com>
To: linux-mm@kvack.org
Cc: Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>, Shaohua Li <shli@fb.com>,
	Rik van Riel <riel@surriel.com>,
	linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [RFC] mm: allow to decrease swap.max below actual swap usage
Date: Thu, 5 Apr 2018 15:47:50 +0100	[thread overview]
Message-ID: <20180405144744.GA15097@castle.DHCP.thefacebook.com> (raw)
In-Reply-To: <20180320223543.6188-1-guro@fb.com>

On Tue, Mar 20, 2018 at 10:35:43PM +0000, Roman Gushchin wrote:
> Currently an attempt to set swap.max into a value lower
> than the actual swap usage fails. And a user can't do much
> with it, except turning off swap globally (using swapoff).
> 
> This patch aims to fix this issue by allowing setting swap.max
> into any value (which corresponds to cgroup v2 API design),
> and schedule a background job to fit swap size into the new limit.
> 
> The following script can be used to test the memory.swap behavior:
>   #!/bin/bash
> 
>   mkdir -p /sys/fs/cgroup/test_swap
>   echo 100M > /sys/fs/cgroup/test_swap/memory.max
>   echo max > /sys/fs/cgroup/test_swap/memory.swap.max
> 
>   mkdir -p /sys/fs/cgroup/test_swap_2
>   echo 100M > /sys/fs/cgroup/test_swap_2/memory.max
>   echo max > /sys/fs/cgroup/test_swap_2/memory.swap.max
> 
>   echo $$ > /sys/fs/cgroup/test_swap/cgroup.procs
>   allocate 200M &
> 
>   echo $$ > /sys/fs/cgroup/test_swap_2/cgroup.procs
>   allocate 200M &
> 
>   sleep 2
> 
>   cat /sys/fs/cgroup/test_swap/memory.swap.current
>   cat /sys/fs/cgroup/test_swap_2/memory.swap.current
> 
>   echo max > /sys/fs/cgroup/test_swap/memory.max
>   echo 50M > /sys/fs/cgroup/test_swap/memory.swap.max
> 
>   sleep 10
> 
>   cat /sys/fs/cgroup/test_swap/memory.swap.current
>   cat /sys/fs/cgroup/test_swap_2/memory.swap.current
> 
>   pkill allocate
> 
> Original test results:
>   106024960
>   106348544
>   ./swap.sh: line 23: echo: write error: Device or resource busy
>   106024960
>   106348544
> 
> With this patch applied:
>   106045440
>   106352640
>   52428800
>   106201088

Any comments, thoughts, feedback?

Rebased version below.

---

      reply	other threads:[~2018-04-05 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20 22:35 Roman Gushchin
2018-04-05 14:47 ` Roman Gushchin [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=20180405144744.GA15097@castle.DHCP.thefacebook.com \
    --to=guro@fb.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=riel@surriel.com \
    --cc=shli@fb.com \
    --cc=tj@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