Coder Social home page Coder Social logo

lepd's Introduction

linuxep

official website for Linux Easy Profiling introduction

lepd's People

Contributors

21cnbao avatar bo-liu avatar chensong2000 avatar kangyijie5473 avatar linuxep avatar merryyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lepd's Issues

support offline cpu frame graph

perf record -e sched:sched_stat_sleep -e sched:sched_switch -e sched:sched_process_exit -a -g -o perf.data.raw sleep 1

perf inject -s -i perf.data.raw -o perf.data

perf script

df -h returns wrong line seperate

$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 126G 0 126G 0% /dev
tmpfs 26G 52M 26G 1% /run
/dev/mapper/ubuntu--vg-root 573G 411G 134G 76% /
tmpfs 126G 220K 126G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 126G 0 126G 0% /sys/fs/cgroup
/dev/sda1 472M 169M 279M 38% /boot
tmpfs 26G 92K 26G 1% /run/user/1000

But the cmd_buff returned from busybox df_main is:
(gdb) p cmd_buff
$3 = "Filesystem", ' ' <repeats 16 times>, "Size Used Available Use% Mounted on\nudev", ' ' <repeats 20 times>, "125.9G 0 125.9G 0% /dev\ntmpfs", ' ' <repeats 20 times>, "25.2G 51.5M 25.1G 0% /run\n/dev/mapper/ubuntu--vg-root\n", ' ' <repeats 24 times>, "572.6G 410.3G 133.2G 75% /\ntmpfs", ' ' <repeats 19 times>, "125.9G 220.0K 125.9G 0% /dev/shm\ntmpfs", ' ' <repeats 21 times>, "5.0M 0 5.0M 0% /run/lock\ntmpfs", ' ' <repeats 19 times>, "125.9G 0 125.9G 0% /sys/fs/cgroup\n/dev/sda1", ' ' <repeats 15 times>, "471.6M 168.8M 278.4M 38% /boot\ntmpfs", ' ' <repeats 20 times>, "25.2G 92.0K 25.2G 0% /run/user/1000\n/dev/mapper/ubuntu--vg-root\n", ' ' <repeats 24 times>, "572.6G 410.3G 133.2G 75% /var/lib/docker/aufs\n", '\000' <repeats 7476 times>

There is unexpected \n after /dev/mapper/ubuntu--vg-root\n which results lepv parse error.

segment fault happens in rmlink when call cgtop

i stepped in with gdb, found something wrong in strjoin:

Program terminated with signal SIGABRT, Aborted.
#0 0x00007ffff7323428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7323428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff732502a in __GI_abort () at abort.c:89
#2 0x00007ffff736b2e8 in __malloc_assert (assertion=assertion@entry=0x7ffff747f398 "(unsigned long) (size) >= (unsigned long) (nb)", file=file@entry=0x7ffff747bb85 "malloc.c",
line=line@entry=3722, function=function@entry=0x7ffff747f9a8 <func.11733> "_int_malloc") at malloc.c:301
#3 0x00007ffff73709b3 in _int_malloc (av=av@entry=0x7ffff76b2b20 <main_arena>, bytes=bytes@entry=13) at malloc.c:3722
#4 0x00007ffff7372184 in __GI___libc_malloc (bytes=13) at malloc.c:2913
#5 0x0000000000408dfe in strjoin (x=0x43f330 "/") at src/cgtop.c:63
#6 0x0000000000409fc4 in cg_read_subgroup (controller=0x43f384 "cpuacct", path=0x43f330 "/", iteration=0, depth=0, d=0x92ea20) at src/cgtop.c:474
#7 0x0000000000409ed5 in refresh_one (controller=0x43f384 "cpuacct", path=0x43f330 "/", iteration=0, depth=0) at src/cgtop.c:446
#8 0x000000000040a083 in refresh (iteration=0) at src/cgtop.c:498
#9 0x000000000040a5e7 in cgtop_main (argc=1, argv=0x7fffffffe240) at src/cgtop.c:616
#10 0x00000000004081de in run_builtin_cmd (ctx=0x7fffffffe3a0, params=0x0, id=0x0) at /root/lepd/src/server.c:206
#11 0x000000000040465a in invoke_procedure (server=0x673940 <my_server>, conn=0x69d3d0, name=0x69d550 "GetCmdCgtop", params=0x0, id=0x0) at /root/lepd/src/jsonrpc-c.c:87
#12 0x000000000040482f in eval_request (server=0x673940 <my_server>, conn=0x69d3d0, root=0x69d4c0) at /root/lepd/src/jsonrpc-c.c:122
#13 0x0000000000404af3 in connection_cb (loop=0x7ffff7dd68e0, w=0x69d3d0, revents=1) at /root/lepd/src/jsonrpc-c.c:180
#14 0x00007ffff7bccd73 in ev_invoke_pending () from /usr/lib/x86_64-linux-gnu/libev.so.4
#15 0x00007ffff7bd03de in ev_run () from /usr/lib/x86_64-linux-gnu/libe

support concurrent request, multithread

1, replace pipe with buffer
2, replace printf with sprintf
3,make run_builtin_cmd as a thread handler
4,a semaphore is needed to control the count of thread

make ARCH=arm failed

linuxep/lepd/libs/libsysstat.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
Makefile:65: recipe for target 'all' failed
make: *** [all] Error 1

perfcpuclock read 0 -- arm

browser connects lepd running on arm device with lepv, first time, got the data properly, second time, got 0 return.

log in arm:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.592 MB perf.data (8050 samples) ]
run_cmd:size 0:perf record -a -e cpu-clock sleep 1

Example in README.md not work on bash

echo "{"method":"GetProcMeminfo"}" | nc 10.10.10.145 12307
{
"error": {
"code": -32700,
"message": "Parse error. Invalid JSON was received by the server."
}
}

echo -n '{"method":"GetProcMeminfo"}' | nc 10.10.10.145 12307
{
"result": "MemTotal: 6103108 kB\nMemFree: 5172292 kB\nMemAvailable: 5195256 kB\nBuffers: 2080 kB\nCached: 78108 kB\nSwapCached:

segment fault happens in CPU STAT

lepd测试
一 运行环境
1.1 操作系统ubuntu,内核:
sam@brix:/data/lep/lepd$ uname -a
Linux brix 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
1.2 firefox

1.3 lepd和lepv都运行在同一台机器上
1.4 硬件设备为一台brix,Intel(R) Celeron(R) 2955U @ 1.40GHz
lepd和lepv都运行在同一台机器上,有一块有线网卡,地址为192.168.20.200,有一块无线网卡,网址为192.168.43.46(DHCP)
sam@brix:/data/lep/lepd$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 74:d4:35:69:c8:a8 brd ff:ff:ff:ff:ff:ff
inet 192.168.20.200/24 brd 192.168.20.255 scope global enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::b1e2:6be1:2841:3df1/64 scope link
valid_lft forever preferred_lft forever
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 6c:71:d9:b4:a8:ab brd ff:ff:ff:ff:ff:ff
inet 192.168.43.46/24 brd 192.168.43.255 scope global dynamic wlp2s0
valid_lft 2664sec preferred_lft 2664sec
inet6 fe80::a0cb:9f1b:5a34:2b1e/64 scope link
valid_lft forever preferred_lft forever
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:11:cc:39:24 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:11ff:fecc:3924/64 scope link
valid_lft forever preferred_lft forever
12: veth6d89cfe@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether d6:e7:f0:b2:6d:92 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::d4e7:f0ff:feb2:6d92/64 scope link
valid_lft forever preferred_lft forever

二 测试步骤
2.1 运行lepd
root@brix:/data/lep/lepd# ./lepd &
2.2 运行lepv
root@brix:/data/lep/lepv# ./runContainer.sh
2.3 打开浏览器,输入http://localhost:8889/,
lepd默认地址为www.rmlink.cn,点击右面的button按钮,

2.4 浏览器打开一个新标签页,输入http://localhost:8889/,
将lepd默认地址改为本机地址192.168.20.200,点击右面的button按钮,

反复实验,发现在CPU STAT结果出来之后,lepd才会段错误。
2.5 重复实验
因lepd已经退出,所以重新运行lepd
打开2.3的标签页,按F5刷新,点击右面的button按钮,待结果出来后,打开2.4的标签页,按F5刷新,点击右面的button按钮,待结果出来后,dmesg,发现lepd已经段错误。
重复实验,每次都能复现。
2.6 把main函数的//daemon(0, 1);注释掉,编译时加上-g选项,用gdb 运行lepd。
出现段错误后输入where,见下图:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.