1 From 8fe742807e65af29dac3fea568ff93cbc5dd9a56 Mon Sep 17 00:00:00 2001
2 From: Michael Jeanson <mjeanson@efficios.com>
3 Date: Mon, 24 Aug 2020 15:26:04 -0400
4 Subject: [PATCH 04/10] fix: ext4: limit the length of per-inode prealloc list
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
12 commit 27bc446e2def38db3244a6eb4bb1d6312936610a
13 Author: brookxu <brookxu.cn@gmail.com>
14 Date: Mon Aug 17 15:36:15 2020 +0800
16 ext4: limit the length of per-inode prealloc list
18 In the scenario of writing sparse files, the per-inode prealloc list may
19 be very long, resulting in high overhead for ext4_mb_use_preallocated().
20 To circumvent this problem, we limit the maximum length of per-inode
21 prealloc list to 512 and allow users to modify it.
23 After patching, we observed that the sys ratio of cpu has dropped, and
24 the system throughput has increased significantly. We created a process
25 to write the sparse file, and the running time of the process on the
26 fixed kernel was significantly reduced, as follows:
28 Running time on unfixed kernel:
29 [root@TENCENT64 ~]# time taskset 0x01 ./sparse /data1/sparce.dat
34 Running time on fixed kernel:
35 [root@TENCENT64 ~]# time taskset 0x01 ./sparse /data1/sparce.dat
40 Upstream-Status: Backport
42 Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
43 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
44 Change-Id: I5169cb24853d4da32e2862a6626f1f058689b053
46 instrumentation/events/lttng-module/ext4.h | 15 +++++++++++++++
47 1 file changed, 15 insertions(+)
49 diff --git a/instrumentation/events/lttng-module/ext4.h b/instrumentation/events/lttng-module/ext4.h
50 index 5f7ab28..72ad4c9 100644
51 --- a/instrumentation/events/lttng-module/ext4.h
52 +++ b/instrumentation/events/lttng-module/ext4.h
53 @@ -460,6 +460,20 @@ LTTNG_TRACEPOINT_EVENT(ext4_mb_release_group_pa,
57 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0))
58 +LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations,
59 + TP_PROTO(struct inode *inode, unsigned int len, unsigned int needed),
61 + TP_ARGS(inode, len, needed),
64 + ctf_integer(dev_t, dev, inode->i_sb->s_dev)
65 + ctf_integer(ino_t, ino, inode->i_ino)
66 + ctf_integer(unsigned int, len, len)
67 + ctf_integer(unsigned int, needed, needed)
71 LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations,
72 TP_PROTO(struct inode *inode),
74 @@ -470,6 +484,7 @@ LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations,
75 ctf_integer(ino_t, ino, inode->i_ino)
80 LTTNG_TRACEPOINT_EVENT(ext4_mb_discard_preallocations,
81 TP_PROTO(struct super_block *sb, int needed),