Thanks for the fixes Mohammad.
On Mon, Jun 9, 2014 at 8:57 AM, Mohammad Merajul Islam Molla
<[email protected]> wrote:
> Patch to fix some minor issues in idlestat tool -
>
> - use USEC_PER_SEC instead of hardcoded value
> - replace 'f' with 'stderr'
> - check for root only if idlestat is run in trace mode
> - increase MAXCSTATE & MAXPSTATE to 16 as per Daniel's suggestion.
> Needs to be dynamically determined in future.
I've split these up into three different patches, made some cosmetic
changes and pushed to the git tree.
>
> diff --git a/idlestat.c b/idlestat.c
> index 787d7b0..e9f556b 100644
> --- a/idlestat.c
> +++ b/idlestat.c
> @@ -47,6 +47,7 @@
> #include "topology.h"
>
> #define IDLESTAT_VERSION "0.3"
> +#define USEC_PER_SEC 1000000
>
> static char irq_type_name[][8] = {
> "irq",
> @@ -193,7 +194,7 @@ static struct cpuidle_data *intersection(struct
> cpuidle_data *data1,
> data->begin = begin;
> data->end = end;
> data->duration = end - begin;
> - data->duration *= 1000000;
> + data->duration *= USEC_PER_SEC;
>
> return data;
> }
> @@ -510,7 +511,6 @@ static void open_next_pstate(struct
> cpufreq_pstates *ps, int s, double time)
> open_current_pstate(ps, time);
> }
>
> -#define USEC_PER_SEC 1000000
> static void close_current_pstate(struct cpufreq_pstates *ps, double time)
> {
> int c = ps->current;
> @@ -617,7 +617,7 @@ static int store_data(double time, int state, int cpu,
> return 0;
>
> /* convert to us */
> - data->duration *= 1000000;
> + data->duration *= USEC_PER_SEC;
>
> cstate->min_time = MIN(cstate->min_time, data->duration);
>
> @@ -1110,7 +1110,7 @@ static int idlestat_store(const char *path)
> f = fopen(path, "w+");
>
> if (!f) {
> - fprintf(f, "%s: failed to open '%s': %m\n", __func__, path);
> + fprintf(stderr, "%s: failed to open '%s': %m\n", __func__, path);
> return -1;
> }
>
> @@ -1230,7 +1230,7 @@ int main(int argc, char *argv[], char *const envp[])
> return 1;
>
> /* We have to manipulate some files only accessible to root */
> - if (getuid()) {
> + if ((options.mode == TRACE) && getuid()) {
> fprintf(stderr, "must be root to run the tool\n");
> return -1;
> }
> diff --git a/idlestat.h b/idlestat.h
> index 74238ff..1977ab4 100644
> --- a/idlestat.h
> +++ b/idlestat.h
> @@ -29,8 +29,8 @@
>
> #define BUFSIZE 256
> #define NAMELEN 16
> -#define MAXCSTATE 8
> -#define MAXPSTATE 8
> +#define MAXCSTATE 16
> +#define MAXPSTATE 16
> #define MAX(A, B) (A > B ? A : B)
> #define MIN(A, B) (A < B ? A : B)
> #define AVG(A, B, I) ((A) + ((B - A) / (I)))
>
> _______________________________________________
> linaro-dev mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/linaro-dev
_______________________________________________
linaro-dev mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/linaro-dev