All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Shixin <liushixin2@huawei.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>, Liu Shixin <liushixin2@huawei.com>
Subject: [PATCH 0/2] Fix I/O high when memory almost met memcg limit
Date: Thu, 1 Feb 2024 18:08:33 +0800	[thread overview]
Message-ID: <20240201100835.1626685-1-liushixin2@huawei.com> (raw)

Recently, when install package in a docker environment where the memory
almost reached the memcg limit, the program have no respond severely for
more than 15 minutes. During this period, the I/O is high(~1G/s) which
cause other programs failed to work properly.

The problem can be constructed in the following way:

 1. Download the image:
	docker pull centos:7
 2. Create a docker with 4G memory limit and 6G memsw limit(cgroupv1):
	docker create --name dockerhub_centos7 --cpu-period=100000
	--cpu-quota=400000 --memory 4G --memory-swap 6G --cap-add=SYS_PTRACE
	--cap-add=SYS_ADMIN --cap-add=NET_ADMIN --cap-add=NET_RAW
	--pids-limit=20000 --ulimit nofile=1048576:1048576
	--ulimit memlock=-1:-1 dockerhub_centos7:latest /usr/sbin/init
 3. Start the docker:
	docker start dockerhub_centos7
 4. Allocate 6094MB memory in docker.
 5. run 'yum install expect'.

We found that this problem is caused by a lot ot meaningless readahead.
Since memory is almost met memcg limit, the readahead page will be
reclaimed immediately and will readahead and reclaim again and again.

These two patch will stop readahead early when memcg charge failed and
will skip readahead when there are too many active refault.

[1] https://lore.kernel.org/linux-mm/c2f4a2fa-3bde-72ce-66f5-db81a373fdbc@huawei.com/T/

Liu Shixin (2):
  mm/readahead: stop readahead loop if memcg charge fails
  mm/readahead: limit sync readahead while too many active refault

 include/linux/fs.h      |  2 ++
 include/linux/pagemap.h |  1 +
 mm/filemap.c            | 16 ++++++++++++++++
 mm/readahead.c          | 12 ++++++++++--
 4 files changed, 29 insertions(+), 2 deletions(-)

-- 
2.25.1


             reply	other threads:[~2024-02-01  9:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 10:08 Liu Shixin [this message]
2024-02-01 10:08 ` [PATCH 1/2] mm/readahead: stop readahead loop if memcg charge fails Liu Shixin
2024-02-01  9:28   ` Jan Kara
2024-02-01 13:47   ` Matthew Wilcox
2024-02-01 13:52     ` Jan Kara
2024-02-01 13:53       ` Matthew Wilcox
2024-02-01 10:08 ` [PATCH 2/2] mm/readahead: limit sync readahead while too many active refault Liu Shixin
2024-02-01  9:37   ` Jan Kara
2024-02-01 10:41     ` Liu Shixin
2024-02-01 17:31       ` Jan Kara
2024-02-02  1:25         ` Liu Shixin
2024-02-02  9:02         ` Liu Shixin
2024-02-29  9:01           ` Liu Shixin
2024-03-05  7:07   ` Liu Shixin

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=20240201100835.1626685-1-liushixin2@huawei.com \
    --to=liushixin2@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.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 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.