From: Lukasz Odzioba <lukasz.odzioba@intel.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
mhocko@suse.com, aarcange@redhat.com, vdavydov@parallels.com,
mingli199x@qq.com, minchan@kernel.org
Cc: dave.hansen@intel.com, lukasz.anaczkowski@intel.com,
lukasz.odzioba@intel.com
Subject: [PATCH 1/1] mm/swap.c: flush lru_add pvecs on compound page arrival
Date: Wed, 8 Jun 2016 16:35:37 +0200 [thread overview]
Message-ID: <1465396537-17277-1-git-send-email-lukasz.odzioba@intel.com> (raw)
When the application does not exit cleanly (i.e. SIGTERM) we might
end up with some pages in lru_add_pvec, which is ok. With THP
enabled huge pages may also end up on per cpu lru_add_pvecs.
In the systems with a lot of processors we end up with quite a lot
of memory pending for addition to LRU cache - in the worst case
scenario up to CPUS * PAGE_SIZE * PAGEVEC_SIZE, which on machine
with 200+CPUs means GBs in practice.
We are able to reproduce this problem with the following program:
void main() {
{
size_t size = 55 * 1000 * 1000; // smaller than MEM/CPUS
void *p = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS , -1, 0);
if (p != MAP_FAILED)
memset(p, 0, size);
//munmap(p, size); // uncomment to make the problem go away
}
}
When we run it it will leave significant amount of memory on pvecs.
This memory will be not reclaimed if we hit OOM, so when we run
above program in a loop:
$ for i in `seq 100`; do ./a.out; done
many processes (95% in my case) will be killed by OOM.
This patch flushes lru_add_pvecs on compound page arrival making
the problem less severe - kill rate drops to 0%.
Suggested-by: Michal Hocko <mhocko@suse.com>
Tested-by: Lukasz Odzioba <lukasz.odzioba@intel.com>
Signed-off-by: Lukasz Odzioba <lukasz.odzioba@intel.com>
---
mm/swap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/swap.c b/mm/swap.c
index 9591614..3fe4f18 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -391,9 +391,8 @@ static void __lru_cache_add(struct page *page)
struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
get_page(page);
- if (!pagevec_space(pvec))
+ if (!pagevec_add(pvec, page) || PageCompound(page))
__pagevec_lru_add(pvec);
- pagevec_add(pvec, page);
put_cpu_var(lru_add_pvec);
}
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2016-06-08 14:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 14:35 Lukasz Odzioba [this message]
2016-06-08 15:04 ` [PATCH 1/1] mm/swap.c: flush lru_add pvecs on compound page arrival Michal Hocko
2016-06-09 8:01 ` Odzioba, Lukasz
2016-06-08 15:31 ` Dave Hansen
2016-06-08 16:06 ` Michal Hocko
2016-06-08 16:34 ` Dave Hansen
2016-06-09 12:21 ` Michal Hocko
2016-06-16 18:08 ` Odzioba, Lukasz
2016-06-16 18:19 ` Michal Hocko
2016-06-16 20:03 ` Odzioba, Lukasz
2016-06-09 8:50 ` Odzioba, Lukasz
2016-06-09 15:41 ` Dave Hansen
2016-06-13 21:01 ` Odzioba, Lukasz
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=1465396537-17277-1-git-send-email-lukasz.odzioba@intel.com \
--to=lukasz.odzioba@intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lukasz.anaczkowski@intel.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=mingli199x@qq.com \
--cc=vdavydov@parallels.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;
as well as URLs for NNTP newsgroup(s).