Skip to content

Commit

Permalink
lttng-modules: backport patches for kernel v6.11
Browse files Browse the repository at this point in the history
While we wait for a new lttng-release, we backport 6
patches to fix the build against the 6.11 kernel.

Signed-off-by: Bruce Ashfield <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
zeddii authored and rpurdie committed Aug 8, 2024
1 parent c1bcebf commit 168e98c
Show file tree
Hide file tree
Showing 7 changed files with 500 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 9706d0431c9cc4178db4cf630fee6f5f85f2543e Mon Sep 17 00:00:00 2001
From: Kienan Stewart <[email protected]>
Date: Mon, 29 Jul 2024 14:01:18 +0000
Subject: [PATCH 1/6] Fix: kfree_skb changed in 6.11-rc1

See upstream commit:

commit c53795d48ee8f385c6a9e394651e7ee914baaeba
Author: Yan Zhai <[email protected]>
Date: Mon Jun 17 11:09:04 2024 -0700

net: add rx_sk to trace_kfree_skb

skb does not include enough information to find out receiving
sockets/services and netns/containers on packet drops. In theory
skb->dev tells about netns, but it can get cleared/reused, e.g. by TCP
stack for OOO packet lookup. Similarly, skb->sk often identifies a local
sender, and tells nothing about a receiver.

Allow passing an extra receiving socket to the tracepoint to improve
the visibility on receiving drops.

Upstream-Status: Backport

Change-Id: I33c8ce1a48006456f198ab1592f733b55be01016
Signed-off-by: Kienan Stewart <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
include/instrumentation/events/skb.h | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/include/instrumentation/events/skb.h b/include/instrumentation/events/skb.h
index edfda7ff..0b5a95dc 100644
--- a/include/instrumentation/events/skb.h
+++ b/include/instrumentation/events/skb.h
@@ -43,7 +43,25 @@ LTTNG_TRACEPOINT_ENUM(skb_drop_reason,
)
#endif

-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+LTTNG_TRACEPOINT_EVENT_MAP(kfree_skb,
+
+ skb_kfree,
+
+ TP_PROTO(struct sk_buff *skb, void *location,
+ enum skb_drop_reason reason, struct sock *rx_sk),
+
+ TP_ARGS(skb, location, reason, rx_sk),
+
+ TP_FIELDS(
+ ctf_integer_hex(void *, skbaddr, skb)
+ ctf_integer_hex(void *, location, location)
+ ctf_integer_network(unsigned short, protocol, skb->protocol)
+ ctf_enum(skb_drop_reason, uint8_t, reason, reason)
+ ctf_integer_hex(void *, rx_skaddr, rx_sk)
+ )
+)
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
|| LTTNG_KERNEL_RANGE(5,15,58, 5,16,0) \
|| LTTNG_RHEL_KERNEL_RANGE(5,14,0,70,0,0, 5,15,0,0,0,0) \
|| LTTNG_RHEL_KERNEL_RANGE(4,18,0,477,10,1, 4,19,0,0,0,0))
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From 7f0f61083a9e88abb289c7575586178739e94955 Mon Sep 17 00:00:00 2001
From: Kienan Stewart <[email protected]>
Date: Mon, 29 Jul 2024 14:08:32 +0000
Subject: [PATCH 2/6] Fix: ext4_da_reserve_space changed in 6.11-rc1

See upstream commit:

commit 0d66b23d79c750276f791411d81a524549a64852
Author: Zhang Yi <[email protected]>
Date: Fri May 17 20:40:02 2024 +0800

ext4: make ext4_da_reserve_space() reserve multi-clusters

Add 'nr_resv' parameter to ext4_da_reserve_space(), which indicates the
number of clusters wants to reserve, make it reserve multiple clusters
at a time.

Upstream-Status: Backport

Change-Id: Ib1ce8c3023d53a6d22ec444a435fdb3c871f64c5
Signed-off-by: Kienan Stewart <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
include/instrumentation/events/ext4.h | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/instrumentation/events/ext4.h b/include/instrumentation/events/ext4.h
index 462b11bf..addf2246 100644
--- a/include/instrumentation/events/ext4.h
+++ b/include/instrumentation/events/ext4.h
@@ -730,7 +730,23 @@ LTTNG_TRACEPOINT_EVENT(ext4_da_update_reserve_space,
)
#endif

-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+LTTNG_TRACEPOINT_EVENT(ext4_da_reserve_space,
+ TP_PROTO(struct inode *inode, int nr_resv),
+
+ TP_ARGS(inode, nr_resv),
+
+ TP_FIELDS(
+ ctf_integer(dev_t, dev, inode->i_sb->s_dev)
+ ctf_integer(ino_t, ino, inode->i_ino)
+ ctf_integer(__u64, i_blocks, inode->i_blocks)
+ ctf_integer(__u64, nr_resv, nr_resv)
+ ctf_integer(int, reserved_data_blocks,
+ EXT4_I(inode)->i_reserved_data_blocks)
+ ctf_integer(TP_MODE_T, mode, inode->i_mode)
+ )
+)
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,13,0))
LTTNG_TRACEPOINT_EVENT(ext4_da_reserve_space,
TP_PROTO(struct inode *inode),

--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From aef97cb8d8ce45a9ea02eaedd20c28e4b69f4acf Mon Sep 17 00:00:00 2001
From: Kienan Stewart <[email protected]>
Date: Mon, 29 Jul 2024 14:11:36 +0000
Subject: [PATCH 3/6] Fix: orig_start removed from btrfs_get_extent in 6.11-rc1

See upstream commit:

commit 4aa7b5d1784f510c0f42afc1d74efb41947221d7
Author: Qu Wenruo <[email protected]>
Date: Tue Apr 30 07:53:04 2024 +0930

btrfs: remove extent_map::orig_start member

Since we have extent_map::offset, the old extent_map::orig_start is just
extent_map::start - extent_map::offset for non-hole/inline extents.

And since the new extent_map::offset is already verified by
validate_extent_map() while the old orig_start is not, let's just remove
the old member from all call sites.

Upstream-Status: Backport

Change-Id: I025a30d49b3e3ddc37d7846acc191ebbdf2ff19e
Signed-off-by: Kienan Stewart <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
include/instrumentation/events/btrfs.h | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/instrumentation/events/btrfs.h b/include/instrumentation/events/btrfs.h
index f1b82db4..40139dee 100644
--- a/include/instrumentation/events/btrfs.h
+++ b/include/instrumentation/events/btrfs.h
@@ -176,7 +176,29 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__inode, btrfs_inode_evict,
)
#endif

-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,11,0))
+
+LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
+
+ TP_PROTO(const struct btrfs_root *root, const struct btrfs_inode *inode,
+ const struct extent_map *map),
+
+ TP_ARGS(root, inode, map),
+
+ TP_FIELDS(
+ ctf_integer(u64, root_objectid, root->root_key.objectid)
+ ctf_integer(u64, ino, btrfs_ino(inode))
+ ctf_integer(u64, start, map->start)
+ ctf_integer(u64, len, map->len)
+ ctf_integer(u64, block_start, map->block_start)
+ ctf_integer(u64, block_len, map->block_len)
+ ctf_integer(unsigned int, flags, map->flags)
+ ctf_integer(int, refs, refcount_read(&map->refs))
+ ctf_integer(unsigned int, compress_type, extent_map_compression(map))
+ )
+)
+
+#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,8,0))

LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,

--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From d44bc12d138513eb3d1dae4e66a4d76d7c567212 Mon Sep 17 00:00:00 2001
From: Kienan Stewart <[email protected]>
Date: Mon, 29 Jul 2024 14:12:47 +0000
Subject: [PATCH 4/6] Fix: block_len removed frmo btrfs_get_extent in 6.11-rc1

See upstream commit:

commit e28b851ed9b232c3b84cb8d0fedbdfa8ca881386
Author: Qu Wenruo <[email protected]>
Date: Tue Apr 30 07:53:05 2024 +0930

btrfs: remove extent_map::block_len member

The extent_map::block_len is either extent_map::len (non-compressed
extent) or extent_map::disk_num_bytes (compressed extent).

Since we already have sanity checks to do the cross-checks between the
new and old members, we can drop the old extent_map::block_len now.

For most call sites, they can manually select extent_map::len or
extent_map::disk_num_bytes, since most if not all of them have checked
if the extent is compressed.

Upstream-Status: Backport

Change-Id: Ib03fc685b4e876bf4e53afdd28ca9826342a0e4e
Signed-off-by: Kienan Stewart <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
include/instrumentation/events/btrfs.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/include/instrumentation/events/btrfs.h b/include/instrumentation/events/btrfs.h
index 40139dee..a764fb3b 100644
--- a/include/instrumentation/events/btrfs.h
+++ b/include/instrumentation/events/btrfs.h
@@ -191,7 +191,6 @@ LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
ctf_integer(u64, start, map->start)
ctf_integer(u64, len, map->len)
ctf_integer(u64, block_start, map->block_start)
- ctf_integer(u64, block_len, map->block_len)
ctf_integer(unsigned int, flags, map->flags)
ctf_integer(int, refs, refcount_read(&map->refs))
ctf_integer(unsigned int, compress_type, extent_map_compression(map))
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From f2762247871d9340f3cbe7e40f25ceb6dbdb81f1 Mon Sep 17 00:00:00 2001
From: Kienan Stewart <[email protected]>
Date: Mon, 29 Jul 2024 14:14:24 +0000
Subject: [PATCH 5/6] Fix: block_start removed from btrfs_get_extent in
6.11-rc1

See upstream commit:

commit c77a8c61002e91d859e118008fd495efbe1d9373
Author: Qu Wenruo <[email protected]>
Date: Tue Apr 30 07:53:06 2024 +0930

btrfs: remove extent_map::block_start member

The member extent_map::block_start can be calculated from
extent_map::disk_bytenr + extent_map::offset for regular extents.
And otherwise just extent_map::disk_bytenr.

And this is already validated by the validate_extent_map(). Now we can
remove the member.

However there is a special case in btrfs_create_dio_extent() where we
for NOCOW/PREALLOC ordered extents cannot directly use the resulting
btrfs_file_extent, as btrfs_split_ordered_extent() cannot handle them
yet.

So for that call site, we pass file_extent->disk_bytenr +
file_extent->num_bytes as disk_bytenr for the ordered extent, and 0 for
offset.

Upstream-Status: Backport

Change-Id: I2e3245bb0d1f5263e902659aa05848d5e231909b
Signed-off-by: Kienan Stewart <[email protected]>
Signed-off-by: Mathieu Desnoyers <[email protected]>
---
include/instrumentation/events/btrfs.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/include/instrumentation/events/btrfs.h b/include/instrumentation/events/btrfs.h
index a764fb3b..4ceb8e02 100644
--- a/include/instrumentation/events/btrfs.h
+++ b/include/instrumentation/events/btrfs.h
@@ -190,7 +190,6 @@ LTTNG_TRACEPOINT_EVENT(btrfs_get_extent,
ctf_integer(u64, ino, btrfs_ino(inode))
ctf_integer(u64, start, map->start)
ctf_integer(u64, len, map->len)
- ctf_integer(u64, block_start, map->block_start)
ctf_integer(unsigned int, flags, map->flags)
ctf_integer(int, refs, refcount_read(&map->refs))
ctf_integer(unsigned int, compress_type, extent_map_compression(map))
--
2.39.2

Loading

0 comments on commit 168e98c

Please sign in to comment.