【发布时间】:2019-03-03 05:39:04
【问题描述】:
第一件事:
- 高山版本 3.9.0
- 性能[来自:http://dl-cdn.alpinelinux.org/alpine/edge/testing]4.18.13
- Docker 18.09.3 build 774a1f4
我的 Dockerfile
FROM alpine:latest
# Set the working directory to /app
WORKDIR /app/
# Install any needed packages specified in requirements.txt
RUN yes | apk add vim
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" | tee -a /etc/apk/repositories
RUN apk add --update perf
问题,这些是在容器内运行的命令:
/ # cat /proc/sys/kernel/perf_event_paranoid
-1
/ # perf stat -d sleep 1
Error:
No permission to enable task-clock event.
You may not have permission to collect stats.
Consider tweaking /proc/sys/kernel/perf_event_paranoid,
which controls use of the performance events system by
unprivileged users (without CAP_SYS_ADMIN).
The current value is -1:
-1: Allow use of (almost) all events by all users
Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK
>= 0: Disallow ftrace function tracepoint by users without CAP_SYS_ADMIN
Disallow raw tracepoint access by users without CAP_SYS_ADMIN
>= 1: Disallow CPU event access by users without CAP_SYS_ADMIN
>= 2: Disallow kernel profiling by users without CAP_SYS_ADMIN
To make this setting permanent, edit /etc/sysctl.conf too, e.g.:
kernel.perf_event_paranoid = -1
/ #
启动镜像的命令:
docker run -it --mount type=tmpfs,tmpfs-size=512M,destination=/app/ alpy
我与 perf 合作了很长时间。但是,这是第一次。有谁知道为什么 perf 知道我有权进行分析,但不让我这样做?
谢谢。
【问题讨论】:
-
谢谢。这回答了我的问题。我现在可以工作了。
-
如果该答案准确回答了您的问题,则可以将此问题标记为重复。否则,您可以发布问题的答案并展示您的不同做法。