Skip to content

Commit 12c9da6

Browse files
kvanheesnickalcock
authored andcommitted
dtrace: add SDT probes
This adds a variety of SDT probes. XXX add documentation here from the commit messages Signed-off-by: Nick Alcock <[email protected]> Signed-off-by: Kris Van Hees <[email protected]> Signed-off-by: Tomas Jedlicka <[email protected]> Signed-off-by: Eugene Loh <[email protected]> Signed-off-by: Alan Maguire <[email protected]> Signed-off-by: David Mc Lean <[email protected]> Signed-off-by: Vincent Lim <[email protected]>
1 parent 4555d9a commit 12c9da6

34 files changed

+1135
-105
lines changed

block/bio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,11 @@ int submit_bio_wait(struct bio *bio)
926926
bio->bi_end_io = submit_bio_wait_endio;
927927
bio->bi_opf |= REQ_SYNC;
928928
submit_bio(bio);
929+
DTRACE_IO(wait__start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
930+
struct file * : fileinfo_t *, NULL);
929931
wait_for_completion_io(&done);
932+
DTRACE_IO(wait__done, struct bio * : (bufinfo_t *, devinfo_t *), bio,
933+
struct file * : fileinfo_t *, NULL);
930934

931935
return blk_status_to_errno(bio->bi_status);
932936
}
@@ -1787,6 +1791,9 @@ void bio_endio(struct bio *bio)
17871791
}
17881792

17891793
blk_throtl_bio_endio(bio);
1794+
DTRACE_IO(done, struct bio * :
1795+
(bufinfo_t *, devinfo_t *), bio,
1796+
struct file * : fileinfo_t *, NULL);
17901797
/* release cgroup info */
17911798
bio_uninit(bio);
17921799
if (bio->bi_end_io)

block/blk-core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,11 +970,15 @@ generic_make_request_checks(struct bio *bio)
970970
*/
971971
bio_set_flag(bio, BIO_TRACE_COMPLETION);
972972
}
973+
DTRACE_IO(start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
974+
struct file * : fileinfo_t *, NULL);
973975
return true;
974976

975977
not_supported:
976978
status = BLK_STS_NOTSUPP;
977979
end_io:
980+
DTRACE_IO(start, struct bio * : (bufinfo_t *, devinfo_t *), bio,
981+
struct file * : fileinfo_t *, NULL);
978982
bio->bi_status = status;
979983
bio_endio(bio);
980984
return false;

fs/exec.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <linux/oom.h>
6363
#include <linux/compat.h>
6464
#include <linux/vmalloc.h>
65+
#include <linux/sdt.h>
6566
#include <linux/dtrace_os.h>
6667

6768
#include <linux/uaccess.h>
@@ -1755,8 +1756,10 @@ static int __do_execve_file(int fd, struct filename *filename,
17551756
check_unsafe_exec(bprm);
17561757
current->in_execve = 1;
17571758

1758-
if (!file)
1759+
if (!file) {
17591760
file = do_open_execat(fd, filename, flags);
1761+
DTRACE_PROC(exec, char *, filename->name);
1762+
}
17601763
retval = PTR_ERR(file);
17611764
if (IS_ERR(file))
17621765
goto out_unmark;
@@ -1837,6 +1840,8 @@ static int __do_execve_file(int fd, struct filename *filename,
18371840
putname(filename);
18381841
if (displaced)
18391842
put_files_struct(displaced);
1843+
1844+
DTRACE_PROC(exec__success);
18401845
return retval;
18411846

18421847
out:
@@ -1857,8 +1862,10 @@ static int __do_execve_file(int fd, struct filename *filename,
18571862
if (displaced)
18581863
reset_files_struct(displaced);
18591864
out_ret:
1860-
if (filename)
1865+
if (filename) {
18611866
putname(filename);
1867+
DTRACE_PROC(exec__failure, int, retval);
1868+
}
18621869
return retval;
18631870
}
18641871

fs/nfs/internal.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/crc32.h>
1010
#include <linux/nfs_page.h>
1111
#include <linux/wait_bit.h>
12+
#include <linux/sdt.h>
1213

1314
#define NFS_MS_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
1415

@@ -775,3 +776,16 @@ static inline void nfs_context_set_write_error(struct nfs_open_context *ctx, int
775776
smp_wmb();
776777
set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
777778
}
779+
780+
#define DTRACE_IO_NFS(name, rw, size, inode) \
781+
if (DTRACE_IO_ENABLED(name)) { \
782+
struct bio bio __maybe_unused = { \
783+
.bi_opf = rw, \
784+
.bi_flags = (1 << BIO_USER_MAPPED), \
785+
.bi_iter.bi_size = size, \
786+
.bi_iter.bi_sector = NFS_FILEID(inode), \
787+
}; \
788+
DTRACE_IO(name, struct bio * : (bufinfo_t *, \
789+
devinfo_t *), &bio, \
790+
struct file * : fileinfo_t *, NULL); \
791+
}

fs/nfs/read.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr,
199199
struct inode *inode = hdr->inode;
200200
int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
201201

202+
DTRACE_IO_NFS(start, REQ_OP_READ, hdr->args.count, hdr->inode);
203+
202204
task_setup_data->flags |= swap_flags;
203205
rpc_ops->read_setup(hdr, msg);
204206
trace_nfs_initiate_read(inode, hdr->io_start, hdr->good_bytes);
@@ -230,6 +232,7 @@ static int nfs_readpage_done(struct rpc_task *task,
230232
struct inode *inode)
231233
{
232234
int status = NFS_PROTO(inode)->read_done(task, hdr);
235+
DTRACE_IO_NFS(done, REQ_OP_READ, hdr->res.count, hdr->inode);
233236
if (status != 0)
234237
return status;
235238

fs/nfs/write.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
13981398
rpc_ops->write_setup(hdr, msg, &task_setup_data->rpc_client);
13991399
trace_nfs_initiate_write(hdr->inode, hdr->io_start, hdr->good_bytes,
14001400
hdr->args.stable);
1401+
DTRACE_IO_NFS(start, REQ_OP_WRITE, hdr->args.count, hdr->inode);
14011402
}
14021403

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

fs/xfs/xfs_buf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ static kmem_zone_t *xfs_buf_zone;
6464
* b_lock (trylock due to inversion)
6565
*/
6666

67+
#define DTRACE_IO_XFS_WAIT(name, bp, is_write) \
68+
if (DTRACE_IO_ENABLED(name)) { \
69+
struct bio bio __maybe_unused = { \
70+
.bi_iter.bi_sector = (bp)->b_bn, \
71+
.bi_iter.bi_size = (bp)->b_length, \
72+
.bi_opf = is_write ? \
73+
REQ_OP_WRITE : REQ_OP_READ, \
74+
.bi_disk = (bp)->b_target->bt_bdev->bd_disk, \
75+
.bi_partno = (bp)->b_target->bt_bdev->bd_partno,\
76+
}; \
77+
DTRACE_IO(name, struct bio * : (bufinfo_t *, \
78+
devinfo_t *), &bio, \
79+
struct file * : fileinfo_t *, NULL); \
80+
}
81+
6782
static inline int
6883
xfs_buf_is_vmapped(
6984
struct xfs_buf *bp)
@@ -1521,10 +1536,14 @@ static int
15211536
xfs_buf_iowait(
15221537
struct xfs_buf *bp)
15231538
{
1539+
int orig_flags __attribute__((unused)) = bp->b_flags;
1540+
15241541
ASSERT(!(bp->b_flags & XBF_ASYNC));
15251542

15261543
trace_xfs_buf_iowait(bp, _RET_IP_);
1544+
DTRACE_IO_XFS_WAIT(wait__start, bp, orig_flags & XBF_WRITE);
15271545
wait_for_completion(&bp->b_iowait);
1546+
DTRACE_IO_XFS_WAIT(wait__done, bp, orig_flags & XBF_WRITE);
15281547
trace_xfs_buf_iowait_done(bp, _RET_IP_);
15291548

15301549
return bp->b_error;

include/linux/rwlock_api_smp.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# error "please don't include this file directly"
66
#endif
77

8+
#include <linux/sdt.h>
9+
810
/*
911
* include/linux/rwlock_api_smp.h
1012
*
@@ -119,6 +121,8 @@ static inline int __raw_read_trylock(rwlock_t *lock)
119121
preempt_disable();
120122
if (do_raw_read_trylock(lock)) {
121123
rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_);
124+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
125+
DTRACE_LOCKSTAT_RW_READER);
122126
return 1;
123127
}
124128
preempt_enable();
@@ -130,6 +134,8 @@ static inline int __raw_write_trylock(rwlock_t *lock)
130134
preempt_disable();
131135
if (do_raw_write_trylock(lock)) {
132136
rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_);
137+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
138+
DTRACE_LOCKSTAT_RW_WRITER);
133139
return 1;
134140
}
135141
preempt_enable();
@@ -148,6 +154,8 @@ static inline void __raw_read_lock(rwlock_t *lock)
148154
preempt_disable();
149155
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
150156
LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
157+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
158+
DTRACE_LOCKSTAT_RW_READER);
151159
}
152160

153161
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)
159167
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
160168
LOCK_CONTENDED_FLAGS(lock, do_raw_read_trylock, do_raw_read_lock,
161169
do_raw_read_lock_flags, &flags);
170+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
171+
DTRACE_LOCKSTAT_RW_READER);
162172
return flags;
163173
}
164174

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

173185
static inline void __raw_read_lock_bh(rwlock_t *lock)
174186
{
175187
__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
176188
rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
177189
LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
190+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
191+
DTRACE_LOCKSTAT_RW_READER);
178192
}
179193

180194
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)
186200
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
187201
LOCK_CONTENDED_FLAGS(lock, do_raw_write_trylock, do_raw_write_lock,
188202
do_raw_write_lock_flags, &flags);
203+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
204+
DTRACE_LOCKSTAT_RW_WRITER);
189205
return flags;
190206
}
191207

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

200218
static inline void __raw_write_lock_bh(rwlock_t *lock)
201219
{
202220
__local_bh_disable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
203221
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
204222
LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
223+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
224+
DTRACE_LOCKSTAT_RW_WRITER);
205225
}
206226

207227
static inline void __raw_write_lock(rwlock_t *lock)
208228
{
209229
preempt_disable();
210230
rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
211231
LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
232+
DTRACE_LOCKSTAT(rw__acquire, struct rwlock *, lock, int,
233+
DTRACE_LOCKSTAT_RW_WRITER);
212234
}
213235

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

223247
static inline void __raw_read_unlock(rwlock_t *lock)
224248
{
225249
rwlock_release(&lock->dep_map, 1, _RET_IP_);
226250
do_raw_read_unlock(lock);
251+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
252+
DTRACE_LOCKSTAT_RW_READER);
227253
preempt_enable();
228254
}
229255

@@ -232,6 +258,8 @@ __raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
232258
{
233259
rwlock_release(&lock->dep_map, 1, _RET_IP_);
234260
do_raw_read_unlock(lock);
261+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
262+
DTRACE_LOCKSTAT_RW_READER);
235263
local_irq_restore(flags);
236264
preempt_enable();
237265
}
@@ -240,6 +268,8 @@ static inline void __raw_read_unlock_irq(rwlock_t *lock)
240268
{
241269
rwlock_release(&lock->dep_map, 1, _RET_IP_);
242270
do_raw_read_unlock(lock);
271+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
272+
DTRACE_LOCKSTAT_RW_READER);
243273
local_irq_enable();
244274
preempt_enable();
245275
}
@@ -248,6 +278,8 @@ static inline void __raw_read_unlock_bh(rwlock_t *lock)
248278
{
249279
rwlock_release(&lock->dep_map, 1, _RET_IP_);
250280
do_raw_read_unlock(lock);
281+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
282+
DTRACE_LOCKSTAT_RW_READER);
251283
__local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
252284
}
253285

@@ -256,6 +288,8 @@ static inline void __raw_write_unlock_irqrestore(rwlock_t *lock,
256288
{
257289
rwlock_release(&lock->dep_map, 1, _RET_IP_);
258290
do_raw_write_unlock(lock);
291+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
292+
DTRACE_LOCKSTAT_RW_WRITER);
259293
local_irq_restore(flags);
260294
preempt_enable();
261295
}
@@ -264,6 +298,8 @@ static inline void __raw_write_unlock_irq(rwlock_t *lock)
264298
{
265299
rwlock_release(&lock->dep_map, 1, _RET_IP_);
266300
do_raw_write_unlock(lock);
301+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
302+
DTRACE_LOCKSTAT_RW_WRITER);
267303
local_irq_enable();
268304
preempt_enable();
269305
}
@@ -272,6 +308,8 @@ static inline void __raw_write_unlock_bh(rwlock_t *lock)
272308
{
273309
rwlock_release(&lock->dep_map, 1, _RET_IP_);
274310
do_raw_write_unlock(lock);
311+
DTRACE_LOCKSTAT(rw__release, struct rwlock *, lock, int,
312+
DTRACE_LOCKSTAT_RW_WRITER);
275313
__local_bh_enable_ip(_RET_IP_, SOFTIRQ_LOCK_OFFSET);
276314
}
277315

0 commit comments

Comments
 (0)