Hi ! While playing with DTrace to find out why xterm -C doesn''t work on Solaris I noticed an ioctl() call that fails with EINVAL and I was curious to see where exactly that happens. So I ran dtrace -c xterm -C -s /tmp/tr.d | less where tr.d is the following script: ---------- #!/usr/sbin/dtrace #pragma D option flowindent #pragma D option quiet syscall::ioctl:entry / curpsinfo->pr_pid == $target / { self->spec = speculation(); } syscall::ioctl:return /self->spec && errno == EINVAL/ { commit(self->spec); self->spec = 0; } syscall::ioctl:return /self->spec && errno != EINVAL/ { discard(self->spec); self->spec = 0; } fbt:::entry /self->spec/ { speculate(self->spec); printf(" %s:%s \n", probeprov, probefunc); } fbt:::return /self->spec/ { speculate(self->spec); printf(" %s:%s - %d \n", probeprov, probefunc, arg1); } ---------- In the output I get: ---------- 0 -> fifo_ioctl fbt:fifo_ioctl 0 <- fifo_ioctl fbt:fifo_ioctl - 3298589757952 0 -> fifo_fastioctl fbt:fifo_fastioctl 0 <- fifo_fastioctl fbt:fifo_fastioctl - 22 0 -> releasef fbt:releasef 0 -> clear_active_fd fbt:clear_active_fd 0 <- clear_active_fd fbt:clear_active_fd - 1 ---------- The output shows fifo_ioctl() returning before fifo_fastioctl(). Looking at the code in http://cvs.opensolaris.org/source/xref/usr/src/uts/common/fs/fifofs/fifovnops.c I see ---------- 1017 static int 1018 fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, 1019 cred_t *cr, int *rvalp) 1020 { .... 1027 return ((VTOF(vp)->fn_flag & FIFOFAST) ? 1028 fifo_fastioctl(vp, cmd, arg, mode, cr, rvalp) : 1029 fifo_strioctl(vp, cmd, arg, mode, cr, rvalp)); 1030 } 1031 ---------- How can fifo_ioctl() return before fifo_fastioctl() ? Vlad. This message posted from opensolaris.org
Roch Bourbonnais - Performance Engineering
2005-Sep-20 15:09 UTC
[dtrace-discuss] Probe firing question
This is because of tail call optimisation. Your not the first to be surprised by this. Basically fifo_ioctl is done with whatever it has to do. The return code is the one that is about to come out of fifo_fastioctl(); so it arranges to call that function without leaving it''s own trace. fifo_fastioctl() will then return into the caller of fifo_ioctl(). HTH -r Vlad Grama writes: > Hi ! > > While playing with DTrace to find out why xterm -C doesn''t work on Solaris > I noticed an ioctl() call that fails with EINVAL and I was curious to see > where exactly that happens. > > So I ran > dtrace -c xterm -C -s /tmp/tr.d | less > where tr.d is the following script: > > ---------- > #!/usr/sbin/dtrace > > #pragma D option flowindent > #pragma D option quiet > > syscall::ioctl:entry > / curpsinfo->pr_pid == $target / > { > self->spec = speculation(); > } > > syscall::ioctl:return > /self->spec && errno == EINVAL/ > { > commit(self->spec); > self->spec = 0; > } > > syscall::ioctl:return > /self->spec && errno != EINVAL/ > { > discard(self->spec); > self->spec = 0; > } > > fbt:::entry > /self->spec/ > { > speculate(self->spec); > printf(" %s:%s \n", probeprov, probefunc); > > } > > fbt:::return > /self->spec/ > { > speculate(self->spec); > printf(" %s:%s - %d \n", probeprov, probefunc, arg1); > } > ---------- > > In the output I get: > ---------- > 0 -> fifo_ioctl fbt:fifo_ioctl > 0 <- fifo_ioctl fbt:fifo_ioctl - 3298589757952 > 0 -> fifo_fastioctl fbt:fifo_fastioctl > 0 <- fifo_fastioctl fbt:fifo_fastioctl - 22 > 0 -> releasef fbt:releasef > 0 -> clear_active_fd fbt:clear_active_fd > 0 <- clear_active_fd fbt:clear_active_fd - 1 > ---------- > > The output shows fifo_ioctl() returning before fifo_fastioctl(). Looking at > the code in http://cvs.opensolaris.org/source/xref/usr/src/uts/common/fs/fifofs/fifovnops.c > I see > > ---------- > 1017 static int > 1018 fifo_ioctl(vnode_t *vp, int cmd, intptr_t arg, int mode, > 1019 cred_t *cr, int *rvalp) > 1020 { > .... > 1027 return ((VTOF(vp)->fn_flag & FIFOFAST) ? > 1028 fifo_fastioctl(vp, cmd, arg, mode, cr, rvalp) : > 1029 fifo_strioctl(vp, cmd, arg, mode, cr, rvalp)); > 1030 } > 1031 > ---------- > > How can fifo_ioctl() return before fifo_fastioctl() ? > > Vlad. > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org