X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=instrumentation%2Fevents%2Flttng-module%2Fwriteback.h;h=fd898c511f51cb6660cb0e80c9c447d3868c9726;hb=3b4aafcbbef722c5d04f2fe06a47c47d4d23eda0;hp=a215f55badf5a024315dc868a1a5bc51fef11bd4;hpb=c94ac1ac8ad4a732df9bc7adaa18114b3024d5aa;p=lttng-modules.git diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h index a215f55b..fd898c51 100644 --- a/instrumentation/events/lttng-module/writeback.h +++ b/instrumentation/events/lttng-module/writeback.h @@ -1,10 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ #undef TRACE_SYSTEM #define TRACE_SYSTEM writeback #if !defined(LTTNG_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ) #define LTTNG_TRACE_WRITEBACK_H -#include +#include #include #include #include @@ -13,17 +14,34 @@ #ifndef _TRACE_WRITEBACK_DEF_ #define _TRACE_WRITEBACK_DEF_ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0) && \ - LTTNG_RHEL_VERSION_CODE < LTTNG_RHEL_KERNEL_VERSION(3,10,0,327,10,1)) -static inline struct backing_dev_info *inode_to_bdi(struct inode *inode) +/* + * Vanilla kernels before 4.0 do not implement inode_to_bdi + * RHEL kernels before 3.10.0-327.10.1 do not implement inode_to_bdi + * RHEL kernel 3.10.0-327.10.1 has inode_to_bdi + * RHEL kernel 3.10.0-327.13.1 includes a partial merge of upstream + * commit a212b105b07d75b48b1a166378282e8a77fbf53d which inlines + * inode_to_bdi but not sb_is_blkdev_sb making it unusable by modules. + */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)) +static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode) { - struct super_block *sb = inode->i_sb; + struct super_block *sb; + + if (!inode) + return &noop_backing_dev_info; + + sb = inode->i_sb; if (strcmp(sb->s_type->name, "bdev") == 0) return inode->i_mapping->backing_dev_info; return sb->s_bdi; } +#else +static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode) +{ + return inode_to_bdi(inode); +} #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)) */ #endif @@ -65,7 +83,7 @@ LTTNG_TRACEPOINT_EVENT(writeback_dirty_page, TP_ARGS(page, mapping), TP_FIELDS( ctf_array_text(char, name, - mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32) + mapping ? dev_name(lttng_inode_to_bdi(mapping->host)->dev) : "(unknown)", 32) ctf_integer(unsigned long, ino, mapping ? mapping->host->i_ino : 0) ctf_integer(pgoff_t, index, page->index) ) @@ -77,8 +95,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_dirty_inode_template, TP_FIELDS( /* may be called for files on pseudo FSes w/ unregistered bdi */ ctf_array_text(char, name, - inode_to_bdi(inode)->dev ? - dev_name(inode_to_bdi(inode)->dev) : "(unknown)", 32) + lttng_inode_to_bdi(inode)->dev ? + dev_name(lttng_inode_to_bdi(inode)->dev) : "(unknown)", 32) ctf_integer(unsigned long, ino, inode->i_ino) ctf_integer(unsigned long, state, inode->i_state) ctf_integer(unsigned long, flags, flags) @@ -97,7 +115,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_write_inode_template, TP_ARGS(inode, wbc), TP_FIELDS( ctf_array_text(char, name, - dev_name(inode_to_bdi(inode)->dev), 32) + dev_name(lttng_inode_to_bdi(inode)->dev), 32) ctf_integer(unsigned long, ino, inode->i_ino) ctf_integer(int, sync_mode, wbc->sync_mode) ) @@ -290,9 +308,7 @@ DEFINE_WRITEBACK_EVENT(writeback_bdi_register) #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)) */ DEFINE_WRITEBACK_EVENT(writeback_nowork) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) DEFINE_WRITEBACK_EVENT(writeback_wake_background) -#endif DEFINE_WRITEBACK_EVENT(writeback_wake_thread) DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread) DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister) @@ -383,6 +399,31 @@ LTTNG_TRACEPOINT_EVENT(writeback_queue_io, ) ) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) +LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, + + writeback_global_dirty_state, + + TP_PROTO(unsigned long background_thresh, + unsigned long dirty_thresh + ), + + TP_ARGS(background_thresh, + dirty_thresh + ), + + TP_FIELDS( + ctf_integer(unsigned long, nr_dirty, global_node_page_state(NR_FILE_DIRTY)) + ctf_integer(unsigned long, nr_writeback, global_node_page_state(NR_WRITEBACK)) + ctf_integer(unsigned long, nr_unstable, global_node_page_state(NR_UNSTABLE_NFS)) + ctf_integer(unsigned long, nr_dirtied, global_node_page_state(NR_DIRTIED)) + ctf_integer(unsigned long, nr_written, global_node_page_state(NR_WRITTEN)) + ctf_integer(unsigned long, background_thresh, background_thresh) + ctf_integer(unsigned long, dirty_thresh, dirty_thresh) + ctf_integer(unsigned long, dirty_limit, global_dirty_limit) + ) +) +#else LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, writeback_global_dirty_state, @@ -407,6 +448,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, ) ) #endif +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) @@ -609,7 +651,7 @@ LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue, TP_FIELDS( ctf_array_text(char, name, - dev_name(inode_to_bdi(inode)->dev), 32) + dev_name(lttng_inode_to_bdi(inode)->dev), 32) ctf_integer(unsigned long, ino, inode->i_ino) ctf_integer(unsigned long, state, inode->i_state) ctf_integer(unsigned long, dirtied_when, inode->dirtied_when) @@ -617,7 +659,6 @@ LTTNG_TRACEPOINT_EVENT(writeback_sb_inodes_requeue, ) #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) LTTNG_TRACEPOINT_EVENT_CLASS(writeback_congest_waited_template, TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), @@ -643,7 +684,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_congest_waited_template, writeback_wai TP_ARGS(usec_timeout, usec_delayed) ) -#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template, @@ -657,7 +697,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(writeback_single_inode_template, TP_FIELDS( ctf_array_text(char, name, - dev_name(inode_to_bdi(inode)->dev), 32) + dev_name(lttng_inode_to_bdi(inode)->dev), 32) ctf_integer(unsigned long, ino, inode->i_ino) ctf_integer(unsigned long, state, inode->i_state) ctf_integer(unsigned long, dirtied_when, inode->dirtied_when) @@ -689,4 +729,4 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(writeback_single_inode_template, writeback_singl #endif /* LTTNG_TRACE_WRITEBACK_H */ /* This part must be outside protection */ -#include +#include