Skip to content

Commit

Permalink
Keep working with PID#1
Browse files Browse the repository at this point in the history
Do not skip the first sample for PID#1

The continue statement was introduced very early with commit 5da71e1
in the original reposiotory before bootchart was merged into systemd,
when there was little code at the end of the while loop and apparently
skipping it didn't hurt. Specifically commit 9b004a7 introduces
still_runnig flag which is never set for PID#1 which makes it subject
to garbage collection in garbage_collect_dead_processes().
  • Loading branch information
Łukasz Stelmach authored and bluca committed Jan 16, 2025
1 parent 6fbc82c commit a15bcaf
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/store.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,37 +356,37 @@ int log_sample(DIR *proc,
* these are used to paint the tree coherently later
* each parent has a LL of children, and a LL of siblings
*/
if (pid == 1)
continue; /* nothing to do for init atm */

/* kthreadd has ppid=0, which breaks our tree ordering */
if (ps->ppid == 0)
ps->ppid = 1;

parent = ps_first;
while ((parent->next_ps && parent->pid != ps->ppid))
parent = parent->next_ps;

if (parent->pid != ps->ppid) {
/* orphan */
ps->ppid = 1;
parent = ps_first->next_ps;
}

ps->parent = parent;

/*
* append ourselves to the list of children
* TODO: consider if prepending is OK for efficiency here.
*/
{
struct ps_struct **children = &parent->children;
while (*children)
children = &(*children)->next;
*children = ps;
if (pid != 1) {
/* nothing to do for init atm */

/* kthreadd has ppid=0, which breaks our tree ordering */
if (ps->ppid == 0)
ps->ppid = 1;

parent = ps_first;
while ((parent->next_ps && parent->pid != ps->ppid))
parent = parent->next_ps;

if (parent->pid != ps->ppid) {
/* orphan */
ps->ppid = 1;
parent = ps_first->next_ps;
}

ps->parent = parent;

/*
* append ourselves to the list of children
* TODO: consider if prepending is OK for efficiency here.
*/
{
struct ps_struct **children = &parent->children;
while (*children)
children = &(*children)->next;
*children = ps;
}
}
}

/* else -> found pid, append data in ps */

/* below here is all continuous logging parts - we get here on every
Expand Down

0 comments on commit a15bcaf

Please sign in to comment.