Skip to content

Instantly share code, notes, and snippets.

View alwaysR9's full-sized avatar
🤔
On vacation

zhufangze alwaysR9

🤔
On vacation
View GitHub Profile

入口函数

kern/init.c

内核内存布局

[KERNBASE, +oo]: kernel space
KERNBASE: 0xF0000000
[KERNBASE-4MB, KERNBASE]: kernel stack

[MEMORY MAP IO]

方法一:yum安装

创建repo

>> vi /etc/yum.repos.d/CentOS-Debuginfo.repo
>> 输入以下内容:
# CentOS-Debug.repo
#
#! /usr/bin/env stap
# usage:
# stap tools/offcpu-cost.stp -x ${pid} -D MAXSKIPPED=1000000 -t -v -w -T 1
global MAX_PROBE_NUM = 10000 # max context-switch number
global cur_probe_num = 0
global begin_sleep_time
global delta
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stdint.h>
#include <sys/time.h>
using namespace std;
int main() {

学习

心理障碍

你可以成为任何领域的专家

行动

1. 是否刻意在练习? (比如:通过这个练习要培养什么?)
2. 是否形成快速反馈? (比如:快速知道练习的正确与否,问题出在哪里)

行为学

心理学猜想

  1. 0-6岁的经历,决定了人的性格! (我无法证明,只能从统计上验证)
  1. 查看top 20占用cpu线程
  • ps -eT -o%cpu,pid,tid,ppid,comm | grep -v CPU | sort -n -r | head -20
  1. 查看系统
  • top
  • uptime
  • vmstat 1 100
  • iostat 1 100

为什么写这个文档?

就像警察破案,查问题也是一项及有挑战性的事情。这篇文当用来总结我查问题时的一些方法论。

克服心理障碍

抛弃压力

  • 不要有压力,保持一个好心态

每次查问题,你兴奋吗?

  • 把每次查问题,看做一次思维锻炼的机会。你不能保证一定查出结果,但你可以看看你的思维能够走多远!

不要推卸

  • 不要看一眼,就把问题推卸给别人。
@alwaysR9
alwaysR9 / varwatch2.stp
Last active May 26, 2020 14:25
watch a var in linux kernel
#! /usr/bin/env stap
probe kernel.statement("do_generic_file_read@mm/filemap.c:1772") {
printf("%s[%d] %s %ld:\n", execname(), tid(), pp(), $index);
}
probe kernel.function("submit_bio@block/blk-core.c") {
printf("%s[%d] %s i_sector:%lu, size:%u\n", execname(), tid(), pp(), $bio->bi_sector, $bio->bi_size);
}

查看版本

lsb_release -a

LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

@alwaysR9
alwaysR9 / dd_test.sh
Last active January 19, 2020 15:45
test disk io with two read process
echo 1 > /proc/sys/vm/drop_caches
#dd if=data/cache.block.1 bs=4096k count=3000000 of=/dev/null iflag=direct &
#dd if=data/cache.block.2 bs=4096k count=3000000 of=/dev/null iflag=direct &
dd if=data/cache.block.1 bs=4096k count=3000000 of=/dev/null &
dd if=data/cache.block.2 bs=4096k count=3000000 of=/dev/null &