Skip to content
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

lparstat doesn't report physc correctly. it's always 0.00. #5

Open
mmatsuya opened this issue Jun 17, 2016 · 0 comments
Open

lparstat doesn't report physc correctly. it's always 0.00. #5

mmatsuya opened this issue Jun 17, 2016 · 0 comments
Labels

Comments

@mmatsuya
Copy link

mmatsuya commented Jun 17, 2016

Hi,

physc value in the output of lparstat is always 0.00. This doesn't provide any correct data.
physc is calculated as below.

void get_cpu_physc(struct sysentry *unused_se, char *buf)
{
... snip ...
physc = (new_purr - old_purr)/timebase/elapsed;
sprintf(buf, "%.2f", physc);

purr is the value in /proc/ppc64/lparcfg. old one is the value collected in the last output.
timebase is the value in /proc/cpuinfo. It was 512000000 in my case.

It seems that elapsed's value was wrong. It should be a difference (in second) from the last output timestamp. The timestamp was collected in get_time().

void get_time()
{
struct timeval t;
struct sysentry *se;

    gettimeofday(&t, 0);

    se = get_sysentry("time");
    sprintf(se->value, "%ld", t.tv_sec + t.tv_usec);

}

t.tv_sec + t.tv_usec is wrong definitely. The unit doesn't same.
If the time is returned in second here, it may cause another problem.
I created a patch, and get_time() returns the time in usec in it.
And, it can be calculated properly with changing into second in get_cpu_physc().

--- ./src/lparstat.c.original   2016-06-15 16:55:02.209992105 +0900
+++ ./src/lparstat.c.original   2016-06-15 16:56:30.398554069 +0900
@@ -65,7 +65,7 @@ void get_time()
    gettimeofday(&t, 0);

    se = get_sysentry("time");
-   sprintf(se->value, "%ld", t.tv_sec + t.tv_usec);
+   sprintf(se->value, "%ld", t.tv_sec*1000000 + t.tv_usec);
 }

 long long elapsed_time()
@@ -120,7 +120,7 @@ void get_cpu_physc(struct sysentry *unus
    new_purr = strtoll(se->value, NULL, 0);
    old_purr = strtoll(se->old_value, NULL, 0);

-   physc = (new_purr - old_purr)/timebase/elapsed;
+   physc = (new_purr - old_purr)*1000000/(timebase*elapsed);
    sprintf(buf, "%.2f", physc);
 }

Regards,
Masahiro Matsuya

@tyreld tyreld added the bug label Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants