Re: Performance Stats: Kernel patch

From: Valdis . Kletnieks
Date: Tue Apr 03 2007 - 19:02:16 EST


On Tue, 03 Apr 2007 16:54:43 +0400, Maxim Uvarov said:

> What do you think about it? Patch is bellow.

Was this patch actually compile and run tested?

> Index: linux-2.6.18/fs/proc/array.c
> ===================================================================
> --- linux-2.6.18.orig/fs/proc/array.c
> +++ linux-2.6.18/fs/proc/array.c
> @@ -295,6 +295,18 @@ static inline char *task_cap(struct task
> cap_t(p->cap_effective));
> }
>
> +#ifdef THREAD_PERF_STAT

This needs to be CONFIG_THREAD_PERF_STAT everyplace except the Kconfig stuff.

> +static inline char *task_perf(struct task_struct *p, char *buffer)
> +{
> + return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
> + "Nivcsw:\t%lu\n"
> + "Syscalls:\t%d\n",
> + cap_t(p->nvcsw),
> + cap_t(p->nivcsw),
> + cap_t(p->sysc_cnt));
> +}

You might want a #else that defines a null body for this inline, to
avoid a problem a bit later.

> +#endif /* THREAD_PERF_STAT */
> +
> #define get_blocked_on(t) (-1)
>
> static char *show_blocked_on(struct task_struct *task, char *buffer)
> @@ -327,6 +339,7 @@ int proc_pid_status(struct task_struct *
> buffer = task_show_regs(task, buffer);
> #endif
> buffer = show_blocked_on(task,buffer);
> + buffer = task_perf(task, buffer);

What will this call if you don't have THREAD_PERF_STAT defined?

Here's where you need the #else clause providing a null body for you....

I don't see how this could possibly have built cleanly, since the CONFIG_
issue above would have prevented you from defining a task_perf() function...


Attachment: pgp00000.pgp
Description: PGP signature