Skip to content

Commit 7d2eba0

Browse files
ebruAkagunduztorvalds
authored andcommitted
mm: add tracepoint for scanning pages
This patch series makes swapin readahead up to a certain number to gain more thp performance and adds tracepoint for khugepaged_scan_pmd, collapse_huge_page, __collapse_huge_page_isolate. This patch series was written to deal with programs that access most, but not all, of their memory after they get swapped out. Currently these programs do not get their memory collapsed into THPs after the system swapped their memory out, while they would get THPs before swapping happened. This patch series was tested with a test program, it allocates 400MB of memory, writes to it, and then sleeps. I force the system to swap out all. Afterwards, the test program touches the area by writing and leaves a piece of it without writing. This shows how much swap in readahead made by the patch. Test results: After swapped out ------------------------------------------------------------------- | Anonymous | AnonHugePages | Swap | Fraction | ------------------------------------------------------------------- With patch | 90076 kB | 88064 kB | 309928 kB | %99 | ------------------------------------------------------------------- Without patch | 194068 kB | 192512 kB | 205936 kB | %99 | ------------------------------------------------------------------- After swapped in ------------------------------------------------------------------- | Anonymous | AnonHugePages | Swap | Fraction | ------------------------------------------------------------------- With patch | 201408 kB | 198656 kB | 198596 kB | %98 | ------------------------------------------------------------------- Without patch | 292624 kB | 192512 kB | 107380 kB | %65 | ------------------------------------------------------------------- This patch (of 3): Using static tracepoints, data of functions is recorded. It is good to automatize debugging without doing a lot of changes in the source code. This patch adds tracepoint for khugepaged_scan_pmd, collapse_huge_page and __collapse_huge_page_isolate. [[email protected]: add a missing tab] Signed-off-by: Ebru Akagunduz <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Xie XiuQi <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Cc: Mel Gorman <[email protected]> Cc: David Rientjes <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cb5490a commit 7d2eba0

File tree

2 files changed

+270
-32
lines changed

2 files changed

+270
-32
lines changed

include/trace/events/huge_memory.h

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#undef TRACE_SYSTEM
2+
#define TRACE_SYSTEM huge_memory
3+
4+
#if !defined(__HUGE_MEMORY_H) || defined(TRACE_HEADER_MULTI_READ)
5+
#define __HUGE_MEMORY_H
6+
7+
#include <linux/tracepoint.h>
8+
9+
#include <trace/events/gfpflags.h>
10+
11+
#define SCAN_STATUS \
12+
EM( SCAN_FAIL, "failed") \
13+
EM( SCAN_SUCCEED, "succeeded") \
14+
EM( SCAN_PMD_NULL, "pmd_null") \
15+
EM( SCAN_EXCEED_NONE_PTE, "exceed_none_pte") \
16+
EM( SCAN_PTE_NON_PRESENT, "pte_non_present") \
17+
EM( SCAN_PAGE_RO, "no_writable_page") \
18+
EM( SCAN_NO_REFERENCED_PAGE, "no_referenced_page") \
19+
EM( SCAN_PAGE_NULL, "page_null") \
20+
EM( SCAN_SCAN_ABORT, "scan_aborted") \
21+
EM( SCAN_PAGE_COUNT, "not_suitable_page_count") \
22+
EM( SCAN_PAGE_LRU, "page_not_in_lru") \
23+
EM( SCAN_PAGE_LOCK, "page_locked") \
24+
EM( SCAN_PAGE_ANON, "page_not_anon") \
25+
EM( SCAN_ANY_PROCESS, "no_process_for_page") \
26+
EM( SCAN_VMA_NULL, "vma_null") \
27+
EM( SCAN_VMA_CHECK, "vma_check_failed") \
28+
EM( SCAN_ADDRESS_RANGE, "not_suitable_address_range") \
29+
EM( SCAN_SWAP_CACHE_PAGE, "page_swap_cache") \
30+
EM( SCAN_DEL_PAGE_LRU, "could_not_delete_page_from_lru")\
31+
EM( SCAN_ALLOC_HUGE_PAGE_FAIL, "alloc_huge_page_failed") \
32+
EMe( SCAN_CGROUP_CHARGE_FAIL, "ccgroup_charge_failed")
33+
34+
#undef EM
35+
#undef EMe
36+
#define EM(a, b) TRACE_DEFINE_ENUM(a);
37+
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
38+
39+
SCAN_STATUS
40+
41+
#undef EM
42+
#undef EMe
43+
#define EM(a, b) {a, b},
44+
#define EMe(a, b) {a, b}
45+
46+
TRACE_EVENT(mm_khugepaged_scan_pmd,
47+
48+
TP_PROTO(struct mm_struct *mm, unsigned long pfn, bool writable,
49+
bool referenced, int none_or_zero, int status),
50+
51+
TP_ARGS(mm, pfn, writable, referenced, none_or_zero, status),
52+
53+
TP_STRUCT__entry(
54+
__field(struct mm_struct *, mm)
55+
__field(unsigned long, pfn)
56+
__field(bool, writable)
57+
__field(bool, referenced)
58+
__field(int, none_or_zero)
59+
__field(int, status)
60+
),
61+
62+
TP_fast_assign(
63+
__entry->mm = mm;
64+
__entry->pfn = pfn;
65+
__entry->writable = writable;
66+
__entry->referenced = referenced;
67+
__entry->none_or_zero = none_or_zero;
68+
__entry->status = status;
69+
),
70+
71+
TP_printk("mm=%p, scan_pfn=0x%lx, writable=%d, referenced=%d, none_or_zero=%d, status=%s",
72+
__entry->mm,
73+
__entry->pfn,
74+
__entry->writable,
75+
__entry->referenced,
76+
__entry->none_or_zero,
77+
__print_symbolic(__entry->status, SCAN_STATUS))
78+
);
79+
80+
TRACE_EVENT(mm_collapse_huge_page,
81+
82+
TP_PROTO(struct mm_struct *mm, int isolated, int status),
83+
84+
TP_ARGS(mm, isolated, status),
85+
86+
TP_STRUCT__entry(
87+
__field(struct mm_struct *, mm)
88+
__field(int, isolated)
89+
__field(int, status)
90+
),
91+
92+
TP_fast_assign(
93+
__entry->mm = mm;
94+
__entry->isolated = isolated;
95+
__entry->status = status;
96+
),
97+
98+
TP_printk("mm=%p, isolated=%d, status=%s",
99+
__entry->mm,
100+
__entry->isolated,
101+
__print_symbolic(__entry->status, SCAN_STATUS))
102+
);
103+
104+
TRACE_EVENT(mm_collapse_huge_page_isolate,
105+
106+
TP_PROTO(unsigned long pfn, int none_or_zero,
107+
bool referenced, bool writable, int status),
108+
109+
TP_ARGS(pfn, none_or_zero, referenced, writable, status),
110+
111+
TP_STRUCT__entry(
112+
__field(unsigned long, pfn)
113+
__field(int, none_or_zero)
114+
__field(bool, referenced)
115+
__field(bool, writable)
116+
__field(int, status)
117+
),
118+
119+
TP_fast_assign(
120+
__entry->pfn = pfn;
121+
__entry->none_or_zero = none_or_zero;
122+
__entry->referenced = referenced;
123+
__entry->writable = writable;
124+
__entry->status = status;
125+
),
126+
127+
TP_printk("scan_pfn=0x%lx, none_or_zero=%d, referenced=%d, writable=%d, status=%s",
128+
__entry->pfn,
129+
__entry->none_or_zero,
130+
__entry->referenced,
131+
__entry->writable,
132+
__print_symbolic(__entry->status, SCAN_STATUS))
133+
);
134+
135+
#endif /* __HUGE_MEMORY_H */
136+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)