-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STAT code, fixes & review comments by Serge. #32
Conversation
On Nov 1, 2023, at 7:59 PM, Serge Hallyn ***@***.***> wrote:
@hallyn commented on this pull request.
In tests/STAT/stat_test.c:
> + all_cpu->idle,
+ all_cpu->iowait,
+ all_cpu->irq,
+ all_cpu->softirq,
+ all_cpu->steal,
+ all_cpu->guest,
+ all_cpu->guest_nice);
+ all_cpu++;
+ }
+ fprintf(fp, "intr %s\n", st->intr);
+ fprintf(fp, "ctxt %Lu\n",st->ctxt);
+ fprintf(fp, "btime %Lu\n", st->btime);
+ fprintf(fp, "processes %Lu\n", st->processes);
+ fprintf(fp, "procs_running %Lu\n", st->procs_running);
+ fprintf(fp, "procs_blocked %Lu\n", st->procs_blocked);
+ fprintf(fp, "softirq %s\n", st->softirq);
I don't see anything in the path of calling res_read() that ensures that st->softirq won't be either NULL or garbage memory. populate_statinfo() should make sure that if no softirq section is found, it intializes the softirq to something safe.
Yes, thank you, done and pushed above change into rev3.
… —
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hi Serge,
Any update on this? I submitted the changes you asked for below.
Anjali
… On Nov 1, 2023, at 7:59 PM, Serge Hallyn ***@***.***> wrote:
@hallyn commented on this pull request.
In tests/STAT/stat_test.c:
> + all_cpu->idle,
+ all_cpu->iowait,
+ all_cpu->irq,
+ all_cpu->softirq,
+ all_cpu->steal,
+ all_cpu->guest,
+ all_cpu->guest_nice);
+ all_cpu++;
+ }
+ fprintf(fp, "intr %s\n", st->intr);
+ fprintf(fp, "ctxt %Lu\n",st->ctxt);
+ fprintf(fp, "btime %Lu\n", st->btime);
+ fprintf(fp, "processes %Lu\n", st->processes);
+ fprintf(fp, "procs_running %Lu\n", st->procs_running);
+ fprintf(fp, "procs_blocked %Lu\n", st->procs_blocked);
+ fprintf(fp, "softirq %s\n", st->softirq);
I don't see anything in the path of calling res_read() that ensures that st->softirq won't be either NULL or garbage memory. populate_statinfo() should make sure that if no softirq section is found, it intializes the softirq to something safe.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
if (err != 0) | ||
printf("err is %d\n",err); | ||
st = &stats; | ||
fp = fopen ("./stat_info.txt", "w"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not checking fopen() return value. I know it's just a test, but it just looks bad :(
char *cstr1 = cstr + 5; | ||
while (*cstr1 != '\n') { | ||
cstr1++; | ||
bytes++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably check bytes against max size st->intr can support.
char *cstr1 = cstr + 8; | ||
while (*cstr1 != '\n') { | ||
cstr1++; | ||
bytes++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, check bytes length.
Signed-off-by: Anjali Kulkarni <[email protected]>
On Dec 5, 2023, at 11:48 AM, Serge Hallyn ***@***.***> wrote:
@hallyn commented on this pull request.
In stat.c:
> + if (cstr)
+ sscanf(cstr, "processes %Lu", &st->processes);
+ cstr = strstr(buffer, "procs_running ");
+ if (cstr)
+ sscanf(cstr, "procs_running %Lu", &st->procs_running);
+ cstr = strstr(buffer, "procs_blocked ");
+ if (cstr)
+ sscanf(cstr, "procs_blocked %Lu", &st->procs_blocked);
+ cstr = strstr(buffer, "softirq ");
+ memset(&st->softirq, '\0', sizeof(st->softirq));
+ if (cstr) {
+ unsigned int bytes = 0;
+ char *cstr1 = cstr + 8;
+ while (*cstr1 != '\n') {
+ cstr1++;
+ bytes++;
again, check bytes length.
Thanks, taken care of all 3 comments and did push to rev3.
Anjali
… —
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hi Serge, any update on this? |
It looks fine to me - but tests are failling? |
Yes, could you merge this review? Part of the fix is in this commit (for stat) and cpu I will submit as soon as you merge this one.
Anjali
… On Jan 17, 2024, at 3:16 PM, Serge Hallyn ***@***.***> wrote:
It looks fine to me - but tests are failling?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sure - but I approved it, does that not give you the ability to merge it? |
Ok, I did not know you expected me to merge it. Will do so next time.
Anjali
… On Jan 17, 2024, at 3:51 PM, Serge Hallyn ***@***.***> wrote:
Sure - but I approved it, does that not give you the ability to merge it?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Didnt expect, but it as intended to be an option :) |
No description provided.