@@ -1064,6 +1064,7 @@ static unsigned long btrfs_scan_inode(struct btrfs_inode *inode,
btrfs_set_inode_full_sync(inode);
remove_extent_mapping(inode, em);
+ trace_btrfs_extent_map_shrinker_remove_em(inode, em);
/* Drop the reference for the tree. */
free_extent_map(em);
nr_dropped++;
@@ -1156,6 +1157,12 @@ static unsigned long btrfs_extent_maps_scan(struct shrinker *shrinker,
unsigned long scanned = 0;
u64 next_root_id = 0;
+ if (trace_btrfs_extent_map_shrinker_scan_enter_enabled()) {
+ s64 nr = percpu_counter_sum_positive(&fs_info->evictable_extent_maps);
+
+ trace_btrfs_extent_map_shrinker_scan_enter(fs_info, sc->nr_to_scan, nr);
+ }
+
while (scanned < sc->nr_to_scan) {
struct btrfs_root *root;
unsigned long count;
@@ -1180,6 +1187,12 @@ static unsigned long btrfs_extent_maps_scan(struct shrinker *shrinker,
btrfs_put_root(root);
}
+ if (trace_btrfs_extent_map_shrinker_scan_exit_enabled()) {
+ s64 nr = percpu_counter_sum_positive(&fs_info->evictable_extent_maps);
+
+ trace_btrfs_extent_map_shrinker_scan_exit(fs_info, nr_dropped, nr);
+ }
+
return nr_dropped;
}
@@ -1189,6 +1202,8 @@ static unsigned long btrfs_extent_maps_count(struct shrinker *shrinker,
struct btrfs_fs_info *fs_info = shrinker->private_data;
const s64 total = percpu_counter_sum_positive(&fs_info->evictable_extent_maps);
+ trace_btrfs_extent_map_shrinker_count(fs_info, sc->nr_to_scan, total);
+
/* The unsigned long type is 32 bits on 32 bits platforms. */
#if BITS_PER_LONG == 32
if (total > ULONG_MAX)
@@ -2551,6 +2551,98 @@ TRACE_EVENT(btrfs_get_raid_extent_offset,
__entry->devid)
);
+TRACE_EVENT(btrfs_extent_map_shrinker_count,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info, u64 nr_to_scan, u64 nr),
+
+ TP_ARGS(fs_info, nr_to_scan, nr),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, nr_to_scan )
+ __field( u64, nr )
+ ),
+
+ TP_fast_assign_btrfs(fs_info,
+ __entry->nr_to_scan = nr_to_scan;
+ __entry->nr = nr;
+ ),
+
+ TP_printk_btrfs("nr_to_scan=%llu nr=%llu",
+ __entry->nr_to_scan, __entry->nr)
+);
+
+TRACE_EVENT(btrfs_extent_map_shrinker_scan_enter,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info, u64 nr_to_scan, u64 nr),
+
+ TP_ARGS(fs_info, nr_to_scan, nr),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, nr_to_scan )
+ __field( u64, nr )
+ ),
+
+ TP_fast_assign_btrfs(fs_info,
+ __entry->nr_to_scan = nr_to_scan;
+ __entry->nr = nr;
+ ),
+
+ TP_printk_btrfs("nr_to_scan=%llu nr=%llu",
+ __entry->nr_to_scan, __entry->nr)
+);
+
+TRACE_EVENT(btrfs_extent_map_shrinker_scan_exit,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info, u64 nr_dropped, u64 nr),
+
+ TP_ARGS(fs_info, nr_dropped, nr),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, nr_dropped )
+ __field( u64, nr )
+ ),
+
+ TP_fast_assign_btrfs(fs_info,
+ __entry->nr_dropped = nr_dropped;
+ __entry->nr = nr;
+ ),
+
+ TP_printk_btrfs("nr_dropped=%llu nr=%llu",
+ __entry->nr_dropped, __entry->nr)
+);
+
+TRACE_EVENT(btrfs_extent_map_shrinker_remove_em,
+
+ TP_PROTO(const struct btrfs_inode *inode, const struct extent_map *em),
+
+ TP_ARGS(inode, em),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, ino )
+ __field( u64, root_id )
+ __field( u64, start )
+ __field( u64, len )
+ __field( u64, block_start )
+ __field( u32, flags )
+ ),
+
+ TP_fast_assign_btrfs(inode->root->fs_info,
+ __entry->ino = btrfs_ino(inode);
+ __entry->root_id = inode->root->root_key.objectid;
+ __entry->start = em->start;
+ __entry->len = em->len;
+ __entry->block_start = em->block_start;
+ __entry->flags = em->flags;
+ ),
+
+ TP_printk_btrfs(
+"ino=%llu root=%llu(%s) start=%llu len=%llu block_start=%llu(%s) flags=%s",
+ __entry->ino, show_root_type(__entry->root_id),
+ __entry->start, __entry->len,
+ show_map_type(__entry->block_start),
+ show_map_flags(__entry->flags))
+);
+
#endif /* _TRACE_BTRFS_H */
/* This part must be outside protection */