From: William C. <wc...@nc...> - 2002-12-09 20:51:16
|
Note this is assuming that the patch for generating complete_dump is in the daemon. Like the attached patch. -Will William Cohen wrote: > I am not sure that we want to deal with the complications making > opcontrol handle being possibly run by normal users. > > I have have made a revised version of op_dump, op_dump_25, which should > work for both 2.4 and 2.5. For the 2.5 version It looks at the > modification date to determine when the daemon has processed the kernel > data, and it doesn't need to write into the > /var/lib/oprofile/dump_complete. The patch also revises the opcontrol > code to use the same mechanism to determine when the daemon is done > dumping the data. This makes the handshake a little less hackish between > the opcontrol script and the daemon. > > The other things that is needed for user dumps is to make > /dev/oprofile/dump user writeable. This patch doesn't address that. > > 2002-12-09 Will Cohen <wc...@re...> > > * utils/op_dump_25: New file. > * utils/Makefile.am: Add op_dump_25. > * utils/opcontrol (do_dump): Revise how dump performed. > > -Will > > John Levon wrote: > >> On Wed, Dec 04, 2002 at 11:45:03AM -0500, William Cohen wrote: >> >> >>> I realized this morning that normal users cannot force a dump of the >>> data. We had op_dump set up to allow normal users to make sure the >>> data was saved. However, opcontrol needs to be run as root and >>> /dev/oprofile/dump as proposed in the patch currently has 644 >>> permissions. >> >> >> >> We can change the perms. As for opcontrol --dump I guess we need a >> special exception (same for --help too I suppose) >> >> regards >> john > > > > ------------------------------------------------------------------------ > > diff -Nur oprofile/utils/Makefile.am oprofile-build.20021209b/utils/Makefile.am > --- oprofile/utils/Makefile.am 2002-12-02 14:57:34.000000000 -0500 > +++ oprofile-build.20021209b/utils/Makefile.am 2002-12-09 14:13:13.000000000 -0500 > @@ -12,7 +12,7 @@ > if kernel_support > OP_START=op_start_25 > OP_STOP=op_stop_25 > -OP_DUMP= > +OP_DUMP=op_dump_25 > else > OP_START=op_start > OP_STOP=op_stop > @@ -20,4 +20,4 @@ > endif > > # make sure everything gets distributed... > -EXTRA_DIST = op_dump op_start_25 op_stop_25 op_start op_stop opcontrol > +EXTRA_DIST = op_dump op_dump_25 op_start_25 op_stop_25 op_start op_stop opcontrol > diff -Nur oprofile/utils/opcontrol oprofile-build.20021209b/utils/opcontrol > --- oprofile/utils/opcontrol 2002-12-04 16:38:06.000000000 -0500 > +++ oprofile-build.20021209b/utils/opcontrol 2002-12-09 15:11:50.000000000 -0500 > @@ -725,17 +725,37 @@ > } > > do_dump() { > - if test "$KERNEL_SUPPORT" = "yes"; then > - # FIXME the 2.5 version really should be able to dump data > - echo "No dumps for 2.5 version." >& 2 > - # exit 1 > - else > - if [ ! -w $MOUNT/dump ]; then > - echo "Cannot initiate dump." >&2 > + #make sure that the daemon is running > + if test -e "$DIR/lock"; then > + OPROFILED_PID=`cat $DIR/lock` > + ps -p $OPROFILED_PID | grep $OPROFILED_PID > /dev/null > + if [ "$?" -ne 0 ]; then > + echo "No daemon running" >& 2 > exit 1 > fi > - > - echo 1 >/proc/sys/dev/oprofile/dump > + else > + echo "No daemon running" >& 2 > + exit 1 > + fi > + > + if test "$KERNEL_SUPPORT" = "yes"; then > + # find current time > + TMPFILE=`mktemp /tmp/$0.XXXXXX` || exit 1 > + echo 1 > $MOUNT/dump > + # loop until there is a file to check > + while [ ! -e "$DIR/complete_dump" ] > + do > + sleep 1; > + done > + # loop until modification data of $MOUNT/dump after TMPFILE > + while [ "$TMPFILE" -nt "$DIR/complete_dump" ] > + do > + sleep 1; > + done > + rm $TMPFILE > + else > + > + echo 1 > $MOUNT/dump > fi > } > > diff -Nur oprofile/utils/op_dump_25 oprofile-build.20021209b/utils/op_dump_25 > --- oprofile/utils/op_dump_25 1969-12-31 19:00:00.000000000 -0500 > +++ oprofile-build.20021209b/utils/op_dump_25 2002-12-09 15:12:00.000000000 -0500 > @@ -0,0 +1,58 @@ > +#!/bin/bash > +# > +# op_dump_25 is a script to dump data for OProfile > +# > +# Copyright 2002 > +# Read the file COPYING > +# > +# Authors: Will Cohen > + > +grep oprofilefs /proc/filesystems >/dev/null > +if [ "$?" -eq 0 ]; then > + KERNEL_SUPPORT=yes > +fi > + > +DIR="/var/lib/oprofile" > +if test "$KERNEL_SUPPORT" = "yes"; then > + MOUNT="/dev/oprofile" > +else > + MOUNT="/proc/sys/dev/oprofile" > +fi > + > +if [ ! -w $MOUNT/dump ]; then > + echo "Cannot initiate dump." >& 2 > + exit 1 > +fi > + > +#make sure that the daemon is running > +if test -e "$DIR/lock"; then > + OPROFILED_PID=`cat $DIR/lock` > + ps -p $OPROFILED_PID | grep $OPROFILED_PID > /dev/null > + if [ "$?" -ne 0 ]; then > + echo "No daemon running" >& 2 > + exit 1 > + fi > +else > + echo "No daemon running" >& 2 > + exit 1 > +fi > + > +if test "$KERNEL_SUPPORT" = "yes"; then > + # find current time > + TMPFILE=`mktemp /tmp/$0.XXXXXX` || exit 1 > + echo 1 > $MOUNT/dump > + # loop until there is a file to check > + while [ ! -e "$DIR/complete_dump" ] > + do > + sleep 1; > + done > + # loop until modification data of $MOUNT/dump after TMPFILE > + while [ "$TMPFILE" -nt "$DIR/complete_dump" ] > + do > + sleep 1; > + done > + rm $TMPFILE > +else > + > + echo 1 > $MOUNT/dump > +fi |