Skip to content

Instantly share code, notes, and snippets.

Subject: [PATCH 1/1] mm, fadvise: improve the expensive remote LRU cache
draining after FADV_DONTNEED
Our users reported that there're some random latency spikes when their RT
process is running. Finally we found that latency spike is caused by
FADV_DONTNEED. Which may call lru_add_drain_all() to drain LRU cache on
remote CPUs, and then waits the per-cpu work to complete. The wait time
is uncertain, which may be tens millisecond.
That behavior is unreasonable, because this process is bound to a
specific CPU and the file is only accessed by itself, IOW, there should
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9b3c5df75..16fc88b3f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -416,6 +416,8 @@ struct address_space {
unsigned long nrpages; /* number of total pages */
/* number of shadow or DAX exceptional entries */
unsigned long nrexceptional;
+ unsigned long nractive;
+ unsigned long nrinactive;
From e75fa7b22e766aa6c7b87aecb30d552fb1d2b386 Mon Sep 17 00:00:00 2001
From: Yafang Shao <[email protected]>
Date: Mon, 16 Dec 2019 05:09:31 -0500
Subject: [PATCH 2/5] mm, memcg: introduce MEMCG_PROT_SKIP for memcg zero usage
case
If the usage of a memcg is zero, we don't need to do useless work to scan
it. That is a minor optimization.
Cc: Roman Gushchin <[email protected]>
Subject: [PATCH 1/4] mm, memcg: reduce size of struct mem_cgroup by using bit
field
There are some members in struct mem_group can be either 0(false) or
1(true), so we can define them using bit field to reduce size. With this
patch, the size of struct mem_cgroup can be reduced by 64 bytes in theory,
but as there're some MEMCG_PADDING()s, the real number may be different,
which is relate with the cacheline size. Anyway, this patch could reduce
the size of struct mem_cgroup more or less.
diff --git a/fs/inode.c b/fs/inode.c
index fef457a..fb4a0a0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -753,6 +753,39 @@ static enum lru_status inode_lru_isolate(struct list_head *item,
return LRU_ROTATE;
}
+ /* Page protection only works in reclaimer */
+ if (inode->i_data.nrpages && current->reclaim_state) {
@laoar
laoar / get_memcg_count.stp
Last active December 9, 2019 10:33
trace: trace to help anayze issue
# usage : stap -g get_memcg_count.stp
# I only verified it on CentOS 7 (kernel-3.10) @yafang
# With it we can calculate how many offline memcgs.
# This script gets all memcgs, and /proc/cgroup gets online memcgs.
#
# all memcgs = online memcgs + offline memcgs
%{
Subject: [PATCH] mm, memcg: fix the stupid OOM killer when shrinking memcg
hard limit
When there are no more processes in a memcg (e.g., due to OOM
group), we can still have file pages in the page cache.
If these pages are protected by memory.min, they can't be reclaimed.
Especially if there won't be another process in this memcg and the memcg
is kept online, we do want to drop these pages from the page cache.
@laoar
laoar / mm-memcg-introduce-multiple-level-memory-low-protect.patch
Last active October 25, 2019 08:20
mm, memcg: introduce multiple level memory low protection
From f16bb9724a4a9b802a981231c7021d2aea9f4dc2 Mon Sep 17 00:00:00 2001
From: Yafang Shao <[email protected]>
Date: Tue, 22 Oct 2019 22:17:15 -0400
Subject: [PATCH] mm, memcg: introduce multiple level memory low protection
This patch introduces a new memory controller file memory.low.level,
which is used to set multiple level memory.low protetion.
The valid value of memory.low.level is [0..3], meaning we support four
levels protection now. This new controller file takes effect only when
memory.low is set.
@laoar
laoar / page-reclaim.py
Last active September 18, 2019 01:27
under tools/perf/scripts/python/
import os
import sys
import getopt
import signal
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
usage = "usage: perf script report page-reclaim -- [-h] [-p] [-v]\n"
latency_metric = ['total', 'max', 'avg', 'min']
@laoar
laoar / per memcg score_adj
Created August 22, 2019 07:13
patch for memcg socre_adj
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -21,6 +21,7 @@
#include <linux/vmstat.h>
#include <linux/writeback.h>
#include <linux/page-flags.h>
+#include <linux/oom.h>
struct mem_cgroup;
struct page;