Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ad2459

Browse files
committedNov 11, 2018
only sudo if you aren't already the user running the jvm process
this enables usage inside docker containers that don't contain sudo, when running `docker exec` as the user running the jvm process, eg:`docker exec -it --user daemon` because perf maps may now be created as the jvm process user, we need to tell perf script/top/report to not check ownership by using the --force flag
1 parent d9843a0 commit 8ad2459

4 files changed

+4
-4
lines changed
 

‎bin/create-java-perf-map.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fi
3636
[ -d "$JAVA_HOME" ] || (echo "JAVA_HOME directory at '$JAVA_HOME' does not exist." && false)
3737

3838

39-
if [[ "$LINUX" == "1" ]]; then
39+
if [[ "$LINUX" == "1" ]] && [[ $EUID -ne $TARGET_UID ]]; then
4040
sudo rm $PERF_MAP_FILE -f
4141
(cd $PERF_MAP_DIR/out && sudo -u \#$TARGET_UID -g \#$TARGET_GID $JAVA_HOME/bin/java -cp $ATTACH_JAR_PATH:$JAVA_HOME/lib/tools.jar net.virtualvoid.perf.AttachOnce $PID "$OPTIONS")
4242
sudo chown root:root $PERF_MAP_FILE

‎bin/perf-java-flames

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ if [ -z "$PERF_FLAME_OPTS" ]; then
3030
fi
3131

3232
$PERF_MAP_DIR/bin/perf-java-record-stack $*
33-
sudo perf script -i $PERF_DATA_FILE > $STACKS
33+
sudo perf script --force -i $PERF_DATA_FILE > $STACKS
3434
$FLAMEGRAPH_DIR/stackcollapse-perf.pl $PERF_COLLAPSE_OPTS $STACKS | tee $COLLAPSED | $FLAMEGRAPH_DIR/flamegraph.pl $PERF_FLAME_OPTS > $PERF_FLAME_OUTPUT
3535
echo "Flame graph SVG written to PERF_FLAME_OUTPUT='`readlink -f $PERF_FLAME_OUTPUT`'."

‎bin/perf-java-report-stack

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ if [ -z "$PERF_DATA_FILE" ]; then
1414
fi
1515

1616
$PERF_MAP_DIR/bin/perf-java-record-stack $*
17-
sudo perf report -i $PERF_DATA_FILE
17+
sudo perf report --force -i $PERF_DATA_FILE

‎bin/perf-java-top

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ PERF_MAP_DIR=$(dirname $(readlink -f $0))/..
66

77
PID=$1
88
$PERF_MAP_DIR/bin/create-java-perf-map.sh $PID "$PERF_MAP_OPTIONS"
9-
sudo perf top -p $*
9+
sudo perf top --force -p $*

0 commit comments

Comments
 (0)
Please sign in to comment.