Skip to content
Permalink
Browse files
dtrace: add SDT probes
This adds a variety of SDT probes.

XXX add documentation here from the commit messages

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Signed-off-by: Tomas Jedlicka <tomas.jedlicka@oracle.com>
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: David Mc Lean <david.mclean@oracle.com>
Signed-off-by: Vincent Lim <vincent.lim@oracle.com>
  • Loading branch information
kvanhees authored and nickalcock committed Nov 7, 2021
1 parent 5a85dfb commit 7ed2333cfd691c676b0adfe951d92244f1ef5128
Show file tree
Hide file tree
Showing 34 changed files with 1,175 additions and 119 deletions.
@@ -1247,6 +1247,8 @@ int submit_bio_wait(struct bio *bio)
bio->bi_opf |= REQ_SYNC;
submit_bio(bio);

DTRACE_IO(wait__start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
struct file * : fileinfo_t *, NULL);
/* Prevent hang_check timer from firing at us during very long I/O */
hang_check = sysctl_hung_task_timeout_secs;
if (hang_check)
@@ -1255,6 +1257,8 @@ int submit_bio_wait(struct bio *bio)
;
else
wait_for_completion_io(&done);
DTRACE_IO(wait__done, struct bio * : (bufinfo_t *, devinfo_t *), bio,
struct file * : fileinfo_t *, NULL);

return blk_status_to_errno(bio->bi_status);
}
@@ -1488,6 +1492,9 @@ void bio_endio(struct bio *bio)
}

blk_throtl_bio_endio(bio);
DTRACE_IO(done, struct bio * :
(bufinfo_t *, devinfo_t *), bio,
struct file * : fileinfo_t *, NULL);
/* release cgroup info */
bio_uninit(bio);
if (bio->bi_end_io)
@@ -902,11 +902,15 @@ static noinline_for_stack bool submit_bio_checks(struct bio *bio)
*/
bio_set_flag(bio, BIO_TRACE_COMPLETION);
}
DTRACE_IO(start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
struct file * : fileinfo_t *, NULL);
return true;

not_supported:
status = BLK_STS_NOTSUPP;
end_io:
DTRACE_IO(start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
struct file * : fileinfo_t *, NULL);
bio->bi_status = status;
bio_endio(bio);
return false;
@@ -65,6 +65,7 @@
#include <linux/vmalloc.h>
#include <linux/io_uring.h>
#include <linux/syscall_user_dispatch.h>
#include <linux/sdt.h>
#include <linux/dtrace_os.h>

#include <linux/uaccess.h>
@@ -1809,6 +1810,7 @@ static int bprm_execve(struct linux_binprm *bprm,
current->in_execve = 1;

file = do_open_execat(fd, filename, flags);
DTRACE_PROC(exec, char *, filename->name);
retval = PTR_ERR(file);
if (IS_ERR(file))
goto out_unmark;
@@ -1847,6 +1849,8 @@ static int bprm_execve(struct linux_binprm *bprm,
rseq_execve(current);
acct_update_integrals(current);
task_numa_free(current, false);

DTRACE_PROC(exec__success);
return retval;

out:
@@ -1932,6 +1936,8 @@ static int do_execveat_common(int fd, struct filename *filename,

out_ret:
putname(filename);
if (retval < 0)
DTRACE_PROC(exec__failure, int, retval);
return retval;
}

@@ -1985,6 +1991,8 @@ int kernel_execve(const char *kernel_filename,
free_bprm(bprm);
out_ret:
putname(filename);
if (retval < 0)
DTRACE_PROC(exec__failure, int, retval);
return retval;
}

@@ -10,6 +10,7 @@
#include <linux/sunrpc/addr.h>
#include <linux/nfs_page.h>
#include <linux/wait_bit.h>
#include <linux/sdt.h>

#define NFS_SB_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)

@@ -834,3 +835,15 @@ static inline void nfs_set_port(struct sockaddr *sap, int *port,

rpc_set_port(sap, *port);
}

#define DTRACE_IO_NFS(name, rw, size, inode) \
if (DTRACE_IO_ENABLED(name)) { \
struct bio bio __maybe_unused = { \
.bi_opf = rw, \
.bi_iter.bi_size = size, \
.bi_iter.bi_sector = NFS_FILEID(inode), \
}; \
DTRACE_IO(name, struct bio * : (bufinfo_t *, \
devinfo_t *), &bio, \
struct file * : fileinfo_t *, NULL); \
}
@@ -197,6 +197,8 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr,
struct inode *inode = hdr->inode;
int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;

DTRACE_IO_NFS(start, REQ_OP_READ, hdr->args.count, hdr->inode);

task_setup_data->flags |= swap_flags;
rpc_ops->read_setup(hdr, msg);
trace_nfs_initiate_read(hdr);
@@ -228,6 +230,7 @@ static int nfs_readpage_done(struct rpc_task *task,
struct inode *inode)
{
int status = NFS_PROTO(inode)->read_done(task, hdr);
DTRACE_IO_NFS(done, REQ_OP_READ, hdr->res.count, hdr->inode);
if (status != 0)
return status;

@@ -1411,6 +1411,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
task_setup_data->priority = priority;
rpc_ops->write_setup(hdr, msg, &task_setup_data->rpc_client);
trace_nfs_initiate_write(hdr);
DTRACE_IO_NFS(start, REQ_OP_WRITE, hdr->args.count, hdr->inode);
}

/* If a nfs_flush_* function fails, it should remove reqs from @head and
@@ -1570,6 +1571,7 @@ static int nfs_writeback_done(struct rpc_task *task,
* depend on tighter cache coherency when writing.
*/
status = NFS_PROTO(inode)->write_done(task, hdr);
DTRACE_IO_NFS(done, REQ_OP_WRITE, hdr->res.count, hdr->inode);
if (status != 0)
return status;

@@ -49,6 +49,20 @@ static kmem_zone_t *xfs_buf_zone;
* b_lock (trylock due to inversion)
*/

#define DTRACE_IO_XFS_WAIT(name, bp, is_write) \
if (DTRACE_IO_ENABLED(name)) { \
struct bio bio __maybe_unused = { \
.bi_iter.bi_sector = xfs_buf_daddr(bp), \
.bi_iter.bi_size = (bp)->b_length, \
.bi_opf = is_write ? \
REQ_OP_WRITE : REQ_OP_READ, \
.bi_bdev = (bp)->b_target->bt_bdev \
}; \
DTRACE_IO(name, struct bio * : (bufinfo_t *, \
devinfo_t *), &bio, \
struct file * : fileinfo_t *, NULL); \
}

static int __xfs_buf_submit(struct xfs_buf *bp, bool wait);

static inline int
@@ -1567,10 +1581,14 @@ static int
xfs_buf_iowait(
struct xfs_buf *bp)
{
int orig_flags __attribute__((unused)) = bp->b_flags;

ASSERT(!(bp->b_flags & XBF_ASYNC));

trace_xfs_buf_iowait(bp, _RET_IP_);
DTRACE_IO_XFS_WAIT(wait__start, bp, orig_flags & XBF_WRITE);
wait_for_completion(&bp->b_iowait);
DTRACE_IO_XFS_WAIT(wait__done, bp, orig_flags & XBF_WRITE);
trace_xfs_buf_iowait_done(bp, _RET_IP_);

return bp->b_error;
@@ -5,6 +5,8 @@
# error "please don't include this file directly"
#endif

#include <linux/sdt.h>

/*
* include/linux/rwlock_api_smp.h
*
@@ -119,6 +121,8 @@ static inline int __raw_read_trylock(rwlock_t *lock)
preempt_disable();
if (do_raw_read_trylock(lock)) {
rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
return 1;
}
preempt_enable();
@@ -130,6 +134,8 @@ static inline int __raw_write_trylock(rwlock_t *lock)
preempt_disable();
if (do_raw_write_trylock(lock)) {
rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
return 1;
}
preempt_enable();
@@ -148,6 +154,8 @@ static inline void __raw_read_lock(rwlock_t *lock)
preempt_disable();
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
}

static inline unsigned long __raw_read_lock_irqsave(rwlock_t *lock)
@@ -159,6 +167,8 @@ static inline unsigned long __raw_read_lock_irqsave(rwlock_t *lock)
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED_FLAGS(lock, do_raw_read_trylock, do_raw_read_lock,
do_raw_read_lock_flags, &flags);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
return flags;
}

@@ -168,13 +178,17 @@ static inline void __raw_read_lock_irq(rwlock_t *lock)
preempt_disable();
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
}

static inline void __raw_read_lock_bh(rwlock_t *lock)
{
__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
}

static inline unsigned long __raw_write_lock_irqsave(rwlock_t *lock)
@@ -186,6 +200,8 @@ static inline unsigned long __raw_write_lock_irqsave(rwlock_t *lock)
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED_FLAGS(lock, do_raw_write_trylock, do_raw_write_lock,
do_raw_write_lock_flags, &flags);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
return flags;
}

@@ -195,20 +211,26 @@ static inline void __raw_write_lock_irq(rwlock_t *lock)
preempt_disable();
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
}

static inline void __raw_write_lock_bh(rwlock_t *lock)
{
__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
}

static inline void __raw_write_lock(rwlock_t *lock)
{
preempt_disable();
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
}

#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */
@@ -217,13 +239,17 @@ static inline void __raw_write_unlock(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_write_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
preempt_enable();
}

static inline void __raw_read_unlock(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_read_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
preempt_enable();
}

@@ -232,6 +258,8 @@ __raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_read_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
local_irq_restore(flags);
preempt_enable();
}
@@ -240,6 +268,8 @@ static inline void __raw_read_unlock_irq(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_read_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
local_irq_enable();
preempt_enable();
}
@@ -248,6 +278,8 @@ static inline void __raw_read_unlock_bh(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_read_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_READER);
__local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
}

@@ -256,6 +288,8 @@ static inline void __raw_write_unlock_irqrestore(rwlock_t *lock,
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_write_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
local_irq_restore(flags);
preempt_enable();
}
@@ -264,6 +298,8 @@ static inline void __raw_write_unlock_irq(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_write_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
local_irq_enable();
preempt_enable();
}
@@ -272,6 +308,8 @@ static inline void __raw_write_unlock_bh(rwlock_t *lock)
{
rwlock_release(&lock->dep_map, _RET_IP_);
do_raw_write_unlock(lock);
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
DTRACE_LOCKSTAT_RW_WRITER);
__local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
}

0 comments on commit 7ed2333

Please sign in to comment.