Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

f2fs: optimize trace_f2fs_write_checkpoint with enums

This patch optimizes the tracepoint by replacing these hardcoded strings
with a new enumeration f2fs_cp_phase.

1.Defines enum f2fs_cp_phase with values for each checkpoint phase.
2.Updates trace_f2fs_write_checkpoint to accept a u16 phase argument
instead of a string pointer.
3.Uses __print_symbolic in TP_printk to convert the enum values
back to their corresponding strings for human-readable trace output.

This change reduces the storage overhead for each trace event
by replacing a variable-length string with a 2-byte integer,
while maintaining the same readable output in ftrace.

Signed-off-by: YH Lin <yhli@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

YH Lin and committed by
Jaegeuk Kim
8d1cb17a 37345eae

+23 -8
+3 -3
fs/f2fs/checkpoint.c
··· 1673 1673 goto out; 1674 1674 } 1675 1675 1676 - trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops"); 1676 + trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_START_BLOCK_OPS); 1677 1677 1678 1678 err = block_operations(sbi); 1679 1679 if (err) ··· 1681 1681 1682 1682 stat_cp_time(cpc, CP_TIME_OP_LOCK); 1683 1683 1684 - trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops"); 1684 + trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_FINISH_BLOCK_OPS); 1685 1685 1686 1686 f2fs_flush_merged_writes(sbi); 1687 1687 ··· 1747 1747 1748 1748 /* update CP_TIME to trigger checkpoint periodically */ 1749 1749 f2fs_update_time(sbi, CP_TIME); 1750 - trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint"); 1750 + trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, CP_PHASE_FINISH_CHECKPOINT); 1751 1751 out: 1752 1752 if (cpc->reason != CP_RESIZE) 1753 1753 f2fs_up_write(&sbi->cp_global_sem);
+6
fs/f2fs/f2fs.h
··· 319 319 struct cp_stats stats; 320 320 }; 321 321 322 + enum f2fs_cp_phase { 323 + CP_PHASE_START_BLOCK_OPS, 324 + CP_PHASE_FINISH_BLOCK_OPS, 325 + CP_PHASE_FINISH_CHECKPOINT, 326 + }; 327 + 322 328 /* 323 329 * indicate meta/data type 324 330 */
+14 -5
include/trace/events/f2fs.h
··· 50 50 TRACE_DEFINE_ENUM(CP_RESIZE); 51 51 TRACE_DEFINE_ENUM(EX_READ); 52 52 TRACE_DEFINE_ENUM(EX_BLOCK_AGE); 53 + TRACE_DEFINE_ENUM(CP_PHASE_START_BLOCK_OPS); 54 + TRACE_DEFINE_ENUM(CP_PHASE_FINISH_BLOCK_OPS); 55 + TRACE_DEFINE_ENUM(CP_PHASE_FINISH_CHECKPOINT); 53 56 54 57 #define show_block_type(type) \ 55 58 __print_symbolic(type, \ ··· 177 174 178 175 #define S_ALL_PERM (S_ISUID | S_ISGID | S_ISVTX | \ 179 176 S_IRWXU | S_IRWXG | S_IRWXO) 177 + 178 + #define show_cp_phase(phase) \ 179 + __print_symbolic(phase, \ 180 + { CP_PHASE_START_BLOCK_OPS, "start block_ops" }, \ 181 + { CP_PHASE_FINISH_BLOCK_OPS, "finish block_ops" }, \ 182 + { CP_PHASE_FINISH_CHECKPOINT, "finish checkpoint" }) 180 183 181 184 struct f2fs_sb_info; 182 185 struct f2fs_io_info; ··· 1582 1573 1583 1574 TRACE_EVENT(f2fs_write_checkpoint, 1584 1575 1585 - TP_PROTO(struct super_block *sb, int reason, const char *msg), 1576 + TP_PROTO(struct super_block *sb, int reason, u16 phase), 1586 1577 1587 - TP_ARGS(sb, reason, msg), 1578 + TP_ARGS(sb, reason, phase), 1588 1579 1589 1580 TP_STRUCT__entry( 1590 1581 __field(dev_t, dev) 1591 1582 __field(int, reason) 1592 - __string(dest_msg, msg) 1583 + __field(u16, phase) 1593 1584 ), 1594 1585 1595 1586 TP_fast_assign( 1596 1587 __entry->dev = sb->s_dev; 1597 1588 __entry->reason = reason; 1598 - __assign_str(dest_msg); 1589 + __entry->phase = phase; 1599 1590 ), 1600 1591 1601 1592 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s", 1602 1593 show_dev(__entry->dev), 1603 1594 show_cpreason(__entry->reason), 1604 - __get_str(dest_msg)) 1595 + show_cp_phase(__entry->phase)) 1605 1596 ); 1606 1597 1607 1598 DECLARE_EVENT_CLASS(f2fs_discard,