Linux??????????????????
???????????? ???????[ 2016/11/9 10:11:41 ] ?????????????? Linux
????1.???????
??????????????????MQ???????????????????????????????л?????????????MQ?????????????????????????????????????????????????????У????????′???
????2. ??????????????
???????????????????????????CPU?????硢IO??????????????????????????????????????????£???????slabtop –s c?????н??????????????ò????????
????????????????????????????????????????????????????????????????
????task_struct??????????????λ?????slub(slab???????棬??????slub??????????????????????????slab????)???н?????????????????????ó???task_struct??slub???????????????????????????????????????????????Linux?????????????????????λ???????????????????????????????????
???????????????????????????????????н?3????????????λ?????????????????????????????Review?????????????????BUG??????????????????????
????????ò??????????????????????????黳?????????????????????????黳???????????????????????????????????????????
????3. Linux???????????
????3.1 ??ò???????
#define MEMSIZE (1024 * 1024 * 256)
void thread(void)
{
sleep(100);
return;
}
int main()
{
pthread_t id;
int ret;
int num = 0;
while (1) {
ret = pthread_create(&id?? NULL?? (void*)thread?? NULL);
++num;
if (ret != 0)
break;
}
printf("pthread_create fail with ret=%d?? total num=%d
"?? ret?? num);
sleep(100);
return 0;
}
???????strace??????????????????copy_process??????????μ?????????copy_process??????????????
????3.2 ???????
???????????????????????????????λ?????????
???????????strace????????????????????????clone??????
????SYS_clone—>do_fork—>copy_process????????????????????????????systemtap????????????κ????е?stap????????????????
probe kernel.statement("*@kernel/fork.c:1184")
{
printf("In kernel/fork.c 1184
");
}
probe kernel.statement("*@kernel/fork.c:1197")
{
printf("In kernel/fork.c 1197
");
}
probe kernel.statement("*@kernel/fork.c:1206")
{
printf("In kernel/fork.c 1206
");
}
probe kernel.statement("*@kernel/fork.c:1338")
{
printf("In kernel/fork.c 1338
");
}
probe kernel.statement("*@kernel/fork.c:1342")
{
printf("In kernel/fork.c 1342
");
}
probe kernel.statement("*@kernel/fork.c:1363")
{
printf("In kernel/fork.c 1363
");
}
probe kernel.statement("*@kernel/fork.c:1369")
{
printf("In kernel/fork.c 1369
");
}
probe kernel.statement("*@kernel/fork.c:1373")
{
printf("In kernel/fork.c 1373
");
}
probe kernel.function("copy_process").return
{
printf("copy_process return %d
"?? $return)
}
function check_null_pid:long(addr:long)
{
struct pid *p;
p = (struct pid*)THIS->l_addr;
if (p == NULL)
THIS->__retvalue = 0;
else
THIS->__retvalue = 1;
}
probe kernel.function("alloc_pid")
{
printf("alloc_pid init
");
}
probe kernel.statement("*@kernel/pid.c:301")
{
printf("alloc_pid 301
");
}
probe kernel.statement("*@kernel/pid.c:312")
{
printf("alloc_pid 312
");
}
probe kernel.function("alloc_pid").return
{
printf("alloc_pid return %ld
"?? check_null_pid($return));
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11