Re: [PATCH] Performance Stats: Kernel patch

2007-06-06 Thread Jay Lan
Andrew Morton wrote:
> On Tue, 05 Jun 2007 14:43:50 + Maxim Uvarov <[EMAIL PROTECTED]> wrote:
> 
>> Patch makes available to the user the following
>> task and process performance statistics:
>>  * Involuntary Context Switches (task_struct->nivcsw)
>>  * Voluntary Context Switches (task_struct->nvcsw)
>> 
>> Statistics information is available from:
>>  1. taskstats interface (Documentation/accounting/)
>>  2. /proc/PID/status (task only).
>>
>> This data is useful for detecting hyperactivity
>> patterns between processes.
>> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
> 
> Thanks.
> 
> Please retain suitable cc's when discussing a patch.  I keep on having to
> find your updates on the mailing list, and then adding all the same cc's
> when I reply.
> 
> Your patch seemed to be against some horridly prehistoric kernel, so I had
> a few things to fix up.
> 
> I disagree with the term "rates" for these things.  They are counters, not
> rates.  Adjustments are below.
> 
> We still need to think about whether we missed any other fields.

My initial cut of bringing in general accounting fields was to cover
the "struct acct" in linux/acct.h. It was done so that at least data
needed by BSD accounting is in "struct taskstats".

We need to poll other interested parties into this subject, or we can
add more fields later when users of other accounting fields decide
to take advantage of the taskstats interface.

Thanks,
 - jay


> 
> 
> diff -puN 
> Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
>  Documentation/accounting/getdelays.c
> --- 
> a/Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
> +++ a/Documentation/accounting/getdelays.c
> @@ -49,7 +49,7 @@ char name[100];
>  int dbg;
>  int print_delays;
>  int print_io_accounting;
> -int print_task_context_switch_rates;
> +int print_task_context_switch_counts;
>  __u64 stime, utime;
>  
>  #define PRINTF(fmt, arg...) {\
> @@ -205,7 +205,7 @@ void print_delayacct(struct taskstats *t
>  "count", "delay total", t->swapin_count, t->swapin_delay_total);
>  }
>  
> -void task_context_switch_rates(struct taskstats *t)
> +void task_context_switch_counts(struct taskstats *t)
>  {
>   printf("\n\nTask   %15s%15s\n"
>  "   %15lu%15lu\n",
> @@ -259,7 +259,7 @@ int main(int argc, char *argv[])
>   break;
>   case 'q':
>   printf("printing task/process context switch rates\n");
> - print_task_context_switch_rates = 1;
> + print_task_context_switch_counts = 1;
>   break;
>   case 'w':
>   logfile = strdup(optarg);
> @@ -402,8 +402,8 @@ int main(int argc, char *argv[])
>   print_delayacct((struct 
> taskstats *) NLA_DATA(na));
>   if (print_io_accounting)
>   print_ioacct((struct 
> taskstats *) NLA_DATA(na));
> - if 
> (print_task_context_switch_rates)
> - 
> task_context_switch_rates((struct taskstats *) NLA_DATA(na));
> + if 
> (print_task_context_switch_counts)
> + 
> task_context_switch_counts((struct taskstats *) NLA_DATA(na));
>   if (fd) {
>   if (write(fd, 
> NLA_DATA(na), na->nla_len) < 0) {
>   err(1,"write 
> error\n");
> diff -puN 
> Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
>  Documentation/accounting/taskstats-struct.txt
> --- 
> a/Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
> +++ a/Documentation/accounting/taskstats-struct.txt
> @@ -22,7 +22,7 @@ There are three different groups of fiel
>  /* Extended accounting fields end */
>  Their values are collected if CONFIG_TASK_XACCT is set.
>  
> -4) Per-task and per-thread context switch rates statistics
> +4) Per-task and per-thread context switch count statistics
>  
>  Future extension should add fields to the end of the taskstats struct, and
>  should not change the relative position of each field within the struct.
> diff -puN fs/proc/array.c~taskstats-add-context-switch-counters-fix 
> fs/proc/array.c
> --- a/fs/proc/array.c~taskstats-add-context-switch-counters-fix
> +++ a/fs/proc/array.c
> @@ -290,7 +290,9 @@ static inline char *task_cap(struct task
>   cap_t(p->cap_permitted),
>   cap_t(p->cap_effective));
>  }
> -static inline char *task_context_switch_rates(struct task_struct *p, char 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-06 Thread Andrew Morton
On Tue, 05 Jun 2007 14:43:50 + Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> Patch makes available to the user the following
> task and process performance statistics:
>   * Involuntary Context Switches (task_struct->nivcsw)
>   * Voluntary Context Switches (task_struct->nvcsw)
>  
> Statistics information is available from:
>   1. taskstats interface (Documentation/accounting/)
>   2. /proc/PID/status (task only).
> 
> This data is useful for detecting hyperactivity
> patterns between processes.
> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>

Thanks.

Please retain suitable cc's when discussing a patch.  I keep on having to
find your updates on the mailing list, and then adding all the same cc's
when I reply.

Your patch seemed to be against some horridly prehistoric kernel, so I had
a few things to fix up.

I disagree with the term "rates" for these things.  They are counters, not
rates.  Adjustments are below.

We still need to think about whether we missed any other fields.


diff -puN 
Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix 
Documentation/accounting/getdelays.c
--- 
a/Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
+++ a/Documentation/accounting/getdelays.c
@@ -49,7 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
-int print_task_context_switch_rates;
+int print_task_context_switch_counts;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -205,7 +205,7 @@ void print_delayacct(struct taskstats *t
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
-void task_context_switch_rates(struct taskstats *t)
+void task_context_switch_counts(struct taskstats *t)
 {
printf("\n\nTask   %15s%15s\n"
   "   %15lu%15lu\n",
@@ -259,7 +259,7 @@ int main(int argc, char *argv[])
break;
case 'q':
printf("printing task/process context switch rates\n");
-   print_task_context_switch_rates = 1;
+   print_task_context_switch_counts = 1;
break;
case 'w':
logfile = strdup(optarg);
@@ -402,8 +402,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
-   if 
(print_task_context_switch_rates)
-   
task_context_switch_rates((struct taskstats *) NLA_DATA(na));
+   if 
(print_task_context_switch_counts)
+   
task_context_switch_counts((struct taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {
err(1,"write 
error\n");
diff -puN 
Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
 Documentation/accounting/taskstats-struct.txt
--- 
a/Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
+++ a/Documentation/accounting/taskstats-struct.txt
@@ -22,7 +22,7 @@ There are three different groups of fiel
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
-4) Per-task and per-thread context switch rates statistics
+4) Per-task and per-thread context switch count statistics
 
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
diff -puN fs/proc/array.c~taskstats-add-context-switch-counters-fix 
fs/proc/array.c
--- a/fs/proc/array.c~taskstats-add-context-switch-counters-fix
+++ a/fs/proc/array.c
@@ -290,7 +290,9 @@ static inline char *task_cap(struct task
cap_t(p->cap_permitted),
cap_t(p->cap_effective));
 }
-static inline char *task_context_switch_rates(struct task_struct *p, char 
*buffer)
+
+static inline char *task_context_switch_counts(struct task_struct *p,
+   char *buffer)
 {
return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n"
"nonvoluntary_ctxt_switches:\t%lu\n",
@@ -316,7 +318,7 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
-   buffer = task_context_switch_rates(task, buffer);
+   buffer = task_context_switch_counts(task, buffer);
return 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-06 Thread Andrew Morton
On Tue, 05 Jun 2007 14:43:50 + Maxim Uvarov [EMAIL PROTECTED] wrote:

 Patch makes available to the user the following
 task and process performance statistics:
   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
  
 Statistics information is available from:
   1. taskstats interface (Documentation/accounting/)
   2. /proc/PID/status (task only).
 
 This data is useful for detecting hyperactivity
 patterns between processes.
 Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

Thanks.

Please retain suitable cc's when discussing a patch.  I keep on having to
find your updates on the mailing list, and then adding all the same cc's
when I reply.

Your patch seemed to be against some horridly prehistoric kernel, so I had
a few things to fix up.

I disagree with the term rates for these things.  They are counters, not
rates.  Adjustments are below.

We still need to think about whether we missed any other fields.


diff -puN 
Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix 
Documentation/accounting/getdelays.c
--- 
a/Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
+++ a/Documentation/accounting/getdelays.c
@@ -49,7 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
-int print_task_context_switch_rates;
+int print_task_context_switch_counts;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -205,7 +205,7 @@ void print_delayacct(struct taskstats *t
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
-void task_context_switch_rates(struct taskstats *t)
+void task_context_switch_counts(struct taskstats *t)
 {
printf(\n\nTask   %15s%15s\n
  %15lu%15lu\n,
@@ -259,7 +259,7 @@ int main(int argc, char *argv[])
break;
case 'q':
printf(printing task/process context switch rates\n);
-   print_task_context_switch_rates = 1;
+   print_task_context_switch_counts = 1;
break;
case 'w':
logfile = strdup(optarg);
@@ -402,8 +402,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
-   if 
(print_task_context_switch_rates)
-   
task_context_switch_rates((struct taskstats *) NLA_DATA(na));
+   if 
(print_task_context_switch_counts)
+   
task_context_switch_counts((struct taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 
error\n);
diff -puN 
Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
 Documentation/accounting/taskstats-struct.txt
--- 
a/Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
+++ a/Documentation/accounting/taskstats-struct.txt
@@ -22,7 +22,7 @@ There are three different groups of fiel
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
-4) Per-task and per-thread context switch rates statistics
+4) Per-task and per-thread context switch count statistics
 
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
diff -puN fs/proc/array.c~taskstats-add-context-switch-counters-fix 
fs/proc/array.c
--- a/fs/proc/array.c~taskstats-add-context-switch-counters-fix
+++ a/fs/proc/array.c
@@ -290,7 +290,9 @@ static inline char *task_cap(struct task
cap_t(p-cap_permitted),
cap_t(p-cap_effective));
 }
-static inline char *task_context_switch_rates(struct task_struct *p, char 
*buffer)
+
+static inline char *task_context_switch_counts(struct task_struct *p,
+   char *buffer)
 {
return buffer + sprintf(buffer, voluntary_ctxt_switches:\t%lu\n
nonvoluntary_ctxt_switches:\t%lu\n,
@@ -316,7 +318,7 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
-   buffer = task_context_switch_rates(task, buffer);
+   buffer = task_context_switch_counts(task, buffer);
return buffer - orig;
 }
 
_

-
To unsubscribe from 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-06 Thread Jay Lan
Andrew Morton wrote:
 On Tue, 05 Jun 2007 14:43:50 + Maxim Uvarov [EMAIL PROTECTED] wrote:
 
 Patch makes available to the user the following
 task and process performance statistics:
  * Involuntary Context Switches (task_struct-nivcsw)
  * Voluntary Context Switches (task_struct-nvcsw)
 
 Statistics information is available from:
  1. taskstats interface (Documentation/accounting/)
  2. /proc/PID/status (task only).

 This data is useful for detecting hyperactivity
 patterns between processes.
 Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
 
 Thanks.
 
 Please retain suitable cc's when discussing a patch.  I keep on having to
 find your updates on the mailing list, and then adding all the same cc's
 when I reply.
 
 Your patch seemed to be against some horridly prehistoric kernel, so I had
 a few things to fix up.
 
 I disagree with the term rates for these things.  They are counters, not
 rates.  Adjustments are below.
 
 We still need to think about whether we missed any other fields.

My initial cut of bringing in general accounting fields was to cover
the struct acct in linux/acct.h. It was done so that at least data
needed by BSD accounting is in struct taskstats.

We need to poll other interested parties into this subject, or we can
add more fields later when users of other accounting fields decide
to take advantage of the taskstats interface.

Thanks,
 - jay


 
 
 diff -puN 
 Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
  Documentation/accounting/getdelays.c
 --- 
 a/Documentation/accounting/getdelays.c~taskstats-add-context-switch-counters-fix
 +++ a/Documentation/accounting/getdelays.c
 @@ -49,7 +49,7 @@ char name[100];
  int dbg;
  int print_delays;
  int print_io_accounting;
 -int print_task_context_switch_rates;
 +int print_task_context_switch_counts;
  __u64 stime, utime;
  
  #define PRINTF(fmt, arg...) {\
 @@ -205,7 +205,7 @@ void print_delayacct(struct taskstats *t
  count, delay total, t-swapin_count, t-swapin_delay_total);
  }
  
 -void task_context_switch_rates(struct taskstats *t)
 +void task_context_switch_counts(struct taskstats *t)
  {
   printf(\n\nTask   %15s%15s\n
 %15lu%15lu\n,
 @@ -259,7 +259,7 @@ int main(int argc, char *argv[])
   break;
   case 'q':
   printf(printing task/process context switch rates\n);
 - print_task_context_switch_rates = 1;
 + print_task_context_switch_counts = 1;
   break;
   case 'w':
   logfile = strdup(optarg);
 @@ -402,8 +402,8 @@ int main(int argc, char *argv[])
   print_delayacct((struct 
 taskstats *) NLA_DATA(na));
   if (print_io_accounting)
   print_ioacct((struct 
 taskstats *) NLA_DATA(na));
 - if 
 (print_task_context_switch_rates)
 - 
 task_context_switch_rates((struct taskstats *) NLA_DATA(na));
 + if 
 (print_task_context_switch_counts)
 + 
 task_context_switch_counts((struct taskstats *) NLA_DATA(na));
   if (fd) {
   if (write(fd, 
 NLA_DATA(na), na-nla_len)  0) {
   err(1,write 
 error\n);
 diff -puN 
 Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
  Documentation/accounting/taskstats-struct.txt
 --- 
 a/Documentation/accounting/taskstats-struct.txt~taskstats-add-context-switch-counters-fix
 +++ a/Documentation/accounting/taskstats-struct.txt
 @@ -22,7 +22,7 @@ There are three different groups of fiel
  /* Extended accounting fields end */
  Their values are collected if CONFIG_TASK_XACCT is set.
  
 -4) Per-task and per-thread context switch rates statistics
 +4) Per-task and per-thread context switch count statistics
  
  Future extension should add fields to the end of the taskstats struct, and
  should not change the relative position of each field within the struct.
 diff -puN fs/proc/array.c~taskstats-add-context-switch-counters-fix 
 fs/proc/array.c
 --- a/fs/proc/array.c~taskstats-add-context-switch-counters-fix
 +++ a/fs/proc/array.c
 @@ -290,7 +290,9 @@ static inline char *task_cap(struct task
   cap_t(p-cap_permitted),
   cap_t(p-cap_effective));
  }
 -static inline char *task_context_switch_rates(struct task_struct *p, char 
 *buffer)
 +
 +static inline char *task_context_switch_counts(struct task_struct *p,
 + char *buffer)
  

[PATCH] Performance Stats: Kernel patch

2007-06-05 Thread Maxim Uvarov

Changes:

Names are renamed to task_context_switch_rates.




Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.
Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
  
---

 Documentation/accounting/getdelays.c  |   19 +--
 Documentation/accounting/taskstats-struct.txt |6 ++
 fs/proc/array.c   |8 
 include/linux/taskstats.h |5 -
 kernel/taskstats.c|4 
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..fcfe796 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_context_switch_rates;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   "IO%15s%15s\n"
   "  %15llu%15llu\n"
   "MEM   %15s%15s\n"
-  "  %15llu%15llu\n\n",
+  "  %15llu%15llu\n"
   "count", "real total", "virtual total", "delay total",
   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
   t->cpu_delay_total,
@@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void task_context_switch_rates(struct taskstats *t)
+{
+   printf("\n\nTask   %15s%15s\n"
+  "   %15lu%15lu\n",
+  "voluntary", "nonvoluntary",
+  t->nvcsw, t->nivcsw);
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +236,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+   c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
if (c < 0)
break;
 
@@ -240,6 +249,10 @@ int main(int argc, char *argv[])
printf("printing IO accounting\n");
print_io_accounting = 1;
break;
+   case 'q':
+   printf("printing task/process context switch rates\n");
+   print_task_context_switch_rates = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf("write to file %s\n", logfile);
@@ -381,6 +394,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if 
(print_task_context_switch_rates)
+   
task_context_switch_rates((struct taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {
err(1,"write 
error\n");
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..dc2a7a1 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
+4) Per-task and per-thread context switch rates statistics
+
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
 
@@ -158,4 +160,8 @@ struct taskstats {
 
/* Extended accounting fields end */
 
+4) Per-task and per-thread statistics
+   __u64   nvcsw;  /* Context voluntary switch counter */
+   __u64   nivcsw; /* Context involuntary switch counter */
+
 }
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 70e4fab..cf406e8 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-05 Thread Balbir Singh
Andrew Morton wrote:
> On Wed, 30 May 2007 18:49:46 +
> Maxim Uvarov <[EMAIL PROTECTED]> wrote:
> 
>> +void print_taskstats(struct taskstats *t)
>> +{
>> +printf("\n\nTask   %15s%15s\n"
>> +   "   %15lu%15lu\n",
>> +   "voluntary", "nonvoluntary",
>> +   t->nvcsw, t->nivcsw);
>> +}
> 
> print_task_stats versus print_taskstats is a bit confusing, but I guess it
> doesn't matter.
> 
> More significantly, the whole idea of calling it "task stats" isn't a good
> one: it's far too general.  The whole kernel interface is called taskstats,
> but the additions here are a tiny part of that.
> 
> Perhaps task_context_switch_rates would be more appropriate, although
> rather a lot to type.
>

I agree, taskstats is the name given to the genetlink interface.

 
> The patch otherwise seems OK.  Thoughts:
> 
> - Do we need to increment TASKSTATS_VERSION for this?  I forget the rules
>   there.

Any ABI change should result in a version bump. So the bump is ok

> 
> - The lack of context-switch accounting in taskstats is, I think, a
>   simple oversight.  It should have been included on day one.  
> 

Yes, it should have been included

>   There are perhaps other things which _should_ be in taskstats, but we
>   forgot to add them.  Can we think of any such things?
>

I think it's worth reviewing the data exported. I thought CSA filled
out the gaps, but it's definitely worth revisiting.

 
>   We shouldn't just toss any old random stuff in there: it should be
>   things which make sense, and which Unix or Linux accounting traditionally
>   provides, and it should be something which we expect won't suddenly
>   become unsupportable if people make internal kernel changes.
> 

Yes, agreed. The interface must also be open for changes to accounting 
information
that might be useful as a result of new features, like containers, etc.

-- 
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Performance Stats: Kernel patch

2007-06-05 Thread Balbir Singh
Andrew Morton wrote:
 On Wed, 30 May 2007 18:49:46 +
 Maxim Uvarov [EMAIL PROTECTED] wrote:
 
 +void print_taskstats(struct taskstats *t)
 +{
 +printf(\n\nTask   %15s%15s\n
 +  %15lu%15lu\n,
 +   voluntary, nonvoluntary,
 +   t-nvcsw, t-nivcsw);
 +}
 
 print_task_stats versus print_taskstats is a bit confusing, but I guess it
 doesn't matter.
 
 More significantly, the whole idea of calling it task stats isn't a good
 one: it's far too general.  The whole kernel interface is called taskstats,
 but the additions here are a tiny part of that.
 
 Perhaps task_context_switch_rates would be more appropriate, although
 rather a lot to type.


I agree, taskstats is the name given to the genetlink interface.

 
 The patch otherwise seems OK.  Thoughts:
 
 - Do we need to increment TASKSTATS_VERSION for this?  I forget the rules
   there.

Any ABI change should result in a version bump. So the bump is ok

 
 - The lack of context-switch accounting in taskstats is, I think, a
   simple oversight.  It should have been included on day one.  
 

Yes, it should have been included

   There are perhaps other things which _should_ be in taskstats, but we
   forgot to add them.  Can we think of any such things?


I think it's worth reviewing the data exported. I thought CSA filled
out the gaps, but it's definitely worth revisiting.

 
   We shouldn't just toss any old random stuff in there: it should be
   things which make sense, and which Unix or Linux accounting traditionally
   provides, and it should be something which we expect won't suddenly
   become unsupportable if people make internal kernel changes.
 

Yes, agreed. The interface must also be open for changes to accounting 
information
that might be useful as a result of new features, like containers, etc.

-- 
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-06-05 Thread Maxim Uvarov

Changes:

Names are renamed to task_context_switch_rates.




Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.
Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
  
---

 Documentation/accounting/getdelays.c  |   19 +--
 Documentation/accounting/taskstats-struct.txt |6 ++
 fs/proc/array.c   |8 
 include/linux/taskstats.h |5 -
 kernel/taskstats.c|4 
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..fcfe796 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_context_switch_rates;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   IO%15s%15s\n
 %15llu%15llu\n
   MEM   %15s%15s\n
-%15llu%15llu\n\n,
+%15llu%15llu\n
   count, real total, virtual total, delay total,
   t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
   t-cpu_delay_total,
@@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
+void task_context_switch_rates(struct taskstats *t)
+{
+   printf(\n\nTask   %15s%15s\n
+ %15lu%15lu\n,
+  voluntary, nonvoluntary,
+  t-nvcsw, t-nivcsw);
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
@@ -227,7 +236,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, diw:r:m:t:p:v:l);
+   c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
if (c  0)
break;
 
@@ -240,6 +249,10 @@ int main(int argc, char *argv[])
printf(printing IO accounting\n);
print_io_accounting = 1;
break;
+   case 'q':
+   printf(printing task/process context switch rates\n);
+   print_task_context_switch_rates = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf(write to file %s\n, logfile);
@@ -381,6 +394,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if 
(print_task_context_switch_rates)
+   
task_context_switch_rates((struct taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 
error\n);
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..dc2a7a1 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
+4) Per-task and per-thread context switch rates statistics
+
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
 
@@ -158,4 +160,8 @@ struct taskstats {
 
/* Extended accounting fields end */
 
+4) Per-task and per-thread statistics
+   __u64   nvcsw;  /* Context voluntary switch counter */
+   __u64   nivcsw; /* Context involuntary switch counter */
+
 }
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 70e4fab..cf406e8 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -290,6 +290,13 @@ static inline char *task_cap(struct 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jay Lan
Andrew Morton wrote:
> On Wed, 30 May 2007 18:49:46 +
> Maxim Uvarov <[EMAIL PROTECTED]> wrote:
> 
>> Removed syscall counters from patch.
>>
>>
>>
>>
>> Patch makes available to the user the following
>> task and process performance statistics:
>>  * Involuntary Context Switches (task_struct->nivcsw)
>>  * Voluntary Context Switches (task_struct->nvcsw)
>> 
>> Statistics information is available from:
>> 1. taskstats interface (Documentation/accounting/)
>>  2. /proc/PID/status (task only).
>>
>> This data is useful for detecting hyperactivity
>> patterns between processes.
>> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
>>   
> 
> A few little things:
> 
>> diff --git a/Documentation/accounting/getdelays.c 
>> b/Documentation/accounting/getdelays.c
>> index e9126e7..18d22ad 100644
>> --- a/Documentation/accounting/getdelays.c
>> +++ b/Documentation/accounting/getdelays.c
>> @@ -49,6 +49,7 @@ char name[100];
>>  int dbg;
>>  int print_delays;
>>  int print_io_accounting;
>> +int print_task_stats;
>>  __u64 stime, utime;
>>  
>>  #define PRINTF(fmt, arg...) {   \
>> @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
>> "IO%15s%15s\n"
>> "  %15llu%15llu\n"
>> "MEM   %15s%15s\n"
>> -   "  %15llu%15llu\n\n",
>> +   "  %15llu%15llu\n"
>> "count", "real total", "virtual total", "delay total",
>> t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
>> t->cpu_delay_total,
>> @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
>> "count", "delay total", t->swapin_count, t->swapin_delay_total);
>>  }
>>  
>> +void print_taskstats(struct taskstats *t)
>> +{
>> +printf("\n\nTask   %15s%15s\n"
>> +   "   %15lu%15lu\n",
>> +   "voluntary", "nonvoluntary",
>> +   t->nvcsw, t->nivcsw);
>> +}
> 
> print_task_stats versus print_taskstats is a bit confusing, but I guess it
> doesn't matter.
> 
> More significantly, the whole idea of calling it "task stats" isn't a good
> one: it's far too general.  The whole kernel interface is called taskstats,
> but the additions here are a tiny part of that.
> 
> Perhaps task_context_switch_rates would be more appropriate, although
> rather a lot to type.
> 
>>  void print_ioacct(struct taskstats *t)
>>  {
>>  printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
>> @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
>>  struct msgtemplate msg;
>>  
>>  while (1) {
>> -c = getopt(argc, argv, "diw:r:m:t:p:v:l");
>> +c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
>>  if (c < 0)
>>  break;
>>  
>> @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
>>  printf("printing IO accounting\n");
>>  print_io_accounting = 1;
>>  break;
>> +case 'q':
>> +printf("printing task/process stasistics:\n");
>> +print_task_stats = 1;
>> +break;
>>  case 'w':
>>  strncpy(logfile, optarg, MAX_FILENAME);
>>  printf("write to file %s\n", logfile);
>> @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
>>  print_delayacct((struct 
>> taskstats *) NLA_DATA(na));
>>  if (print_io_accounting)
>>  print_ioacct((struct 
>> taskstats *) NLA_DATA(na));
>> +if (print_task_stats)
>> +print_taskstats((struct 
>> taskstats *) NLA_DATA(na));
>>  if (fd) {
>>  if (write(fd, 
>> NLA_DATA(na), na->nla_len) < 0) {
>>  err(1,"write 
>> error\n");
>> diff --git a/Documentation/accounting/taskstats-struct.txt 
>> b/Documentation/accounting/taskstats-struct.txt
>> index 661c797..c3ae6a9 100644
>> --- a/Documentation/accounting/taskstats-struct.txt
>> +++ b/Documentation/accounting/taskstats-struct.txt
>> @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
>> taskstats:
>>  /* Extended accounting fields end */
>>  Their values are collected if CONFIG_TASK_XACCT is set.
>>  
>> +4) Per-task and per-thread statistics
>> +
>>  Future extension should add fields to the end of the taskstats struct, and
>>  should not change the relative position of each field within the struct.
>>  
>> @@ -158,4 +160,8 @@ struct taskstats {
>>  
>>  /* Extended accounting fields end */
>>  
>> +4) Per-task and per-thread statistics
>> +__u64   nvcsw;  /* Context 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jonathan Lim
Looking at the diffs below, I see context switch counters added.  What is
actually being removed?

Jonathan

On Mon Jun  4 12:33:15 2007, [EMAIL PROTECTED] wrote:
> 
> Add Jonathan Lim to cc, who is working on CSA userland implementation
> to use the taskstats data that this patch is going to remove.
> 
> Thanks,
>  - jay
> 
> Andrew Morton wrote:
> > On Wed, 30 May 2007 18:49:46 +
> > Maxim Uvarov <[EMAIL PROTECTED]> wrote:
> > 
> >> Removed syscall counters from patch.
> >>
> >> Patch makes available to the user the following
> >> task and process performance statistics:
> >>* Involuntary Context Switches (task_struct->nivcsw)
> >>* Voluntary Context Switches (task_struct->nvcsw)
> >>   
> >> Statistics information is available from:
> >> 1. taskstats interface (Documentation/accounting/)
> >>2. /proc/PID/status (task only).
> >>
> >> This data is useful for detecting hyperactivity
> >> patterns between processes.
> >> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
> > 
> > A few little things:
> > 
> >> diff --git a/Documentation/accounting/getdelays.c 
> >> b/Documentation/accounting/getdelays.c
> >> index e9126e7..18d22ad 100644
> >> --- a/Documentation/accounting/getdelays.c
> >> +++ b/Documentation/accounting/getdelays.c
> >> @@ -49,6 +49,7 @@ char name[100];
> >>  int dbg;
> >>  int print_delays;
> >>  int print_io_accounting;
> >> +int print_task_stats;
> >>  __u64 stime, utime;
> >>  
> >>  #define PRINTF(fmt, arg...) { \
> >> @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
> >>   "IO%15s%15s\n"
> >>   "  %15llu%15llu\n"
> >>   "MEM   %15s%15s\n"
> >> - "  %15llu%15llu\n\n",
> >> + "  %15llu%15llu\n"
> >>   "count", "real total", "virtual total", "delay total",
> >>   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
> >>   t->cpu_delay_total,
> >> @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
> >>   "count", "delay total", t->swapin_count, t->swapin_delay_total);
> >>  }
> >>  
> >> +void print_taskstats(struct taskstats *t)
> >> +{
> >> +  printf("\n\nTask   %15s%15s\n"
> >> + "   %15lu%15lu\n",
> >> + "voluntary", "nonvoluntary",
> >> + t->nvcsw, t->nivcsw);
> >> +}
> > 
> > print_task_stats versus print_taskstats is a bit confusing, but I guess it
> > doesn't matter.
> > 
> > More significantly, the whole idea of calling it "task stats" isn't a good
> > one: it's far too general.  The whole kernel interface is called taskstats,
> > but the additions here are a tiny part of that.
> > 
> > Perhaps task_context_switch_rates would be more appropriate, although
> > rather a lot to type.
> > 
> >>  void print_ioacct(struct taskstats *t)
> >>  {
> >>printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
> >> @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
> >>struct msgtemplate msg;
> >>  
> >>while (1) {
> >> -  c = getopt(argc, argv, "diw:r:m:t:p:v:l");
> >> +  c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
> >>if (c < 0)
> >>break;
> >>  
> >> @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
> >>printf("printing IO accounting\n");
> >>print_io_accounting = 1;
> >>break;
> >> +  case 'q':
> >> +  printf("printing task/process stasistics:\n");
> >> +  print_task_stats = 1;
> >> +  break;
> >>case 'w':
> >>strncpy(logfile, optarg, MAX_FILENAME);
> >>printf("write to file %s\n", logfile);
> >> @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
> >>print_delayacct((struct 
> >> taskstats *) NLA_DATA(na));
> >>if (print_io_accounting)
> >>print_ioacct((struct 
> >> taskstats *) NLA_DATA(na));
> >> +  if (print_task_stats)
> >> +  print_taskstats((struct 
> >> taskstats *) NLA_DATA(na));
> >>if (fd) {
> >>if (write(fd, 
> >> NLA_DATA(na), na->nla_len) < 0) {
> >>err(1,"write 
> >> error\n");
> >> diff --git a/Documentation/accounting/taskstats-struct.txt 
> >> b/Documentation/accounting/taskstats-struct.txt
> >> index 661c797..c3ae6a9 100644
> >> --- a/Documentation/accounting/taskstats-struct.txt
> >> +++ b/Documentation/accounting/taskstats-struct.txt
> >> @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
> >> taskstats:
> >>  /* Extended accounting fields end */
> >>  Their values are collected if CONFIG_TASK_XACCT is set.
> >>  
> 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jay Lan
Add Jonathan Lim to cc, who is working on CSA userland implementation
to use the taskstats data that this patch is going to remove.

Thanks,
 - jay



Andrew Morton wrote:
> On Wed, 30 May 2007 18:49:46 +
> Maxim Uvarov <[EMAIL PROTECTED]> wrote:
> 
>> Removed syscall counters from patch.
>>
>>
>>
>>
>> Patch makes available to the user the following
>> task and process performance statistics:
>>  * Involuntary Context Switches (task_struct->nivcsw)
>>  * Voluntary Context Switches (task_struct->nvcsw)
>> 
>> Statistics information is available from:
>> 1. taskstats interface (Documentation/accounting/)
>>  2. /proc/PID/status (task only).
>>
>> This data is useful for detecting hyperactivity
>> patterns between processes.
>> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
>>   
> 
> A few little things:
> 
>> diff --git a/Documentation/accounting/getdelays.c 
>> b/Documentation/accounting/getdelays.c
>> index e9126e7..18d22ad 100644
>> --- a/Documentation/accounting/getdelays.c
>> +++ b/Documentation/accounting/getdelays.c
>> @@ -49,6 +49,7 @@ char name[100];
>>  int dbg;
>>  int print_delays;
>>  int print_io_accounting;
>> +int print_task_stats;
>>  __u64 stime, utime;
>>  
>>  #define PRINTF(fmt, arg...) {   \
>> @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
>> "IO%15s%15s\n"
>> "  %15llu%15llu\n"
>> "MEM   %15s%15s\n"
>> -   "  %15llu%15llu\n\n",
>> +   "  %15llu%15llu\n"
>> "count", "real total", "virtual total", "delay total",
>> t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
>> t->cpu_delay_total,
>> @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
>> "count", "delay total", t->swapin_count, t->swapin_delay_total);
>>  }
>>  
>> +void print_taskstats(struct taskstats *t)
>> +{
>> +printf("\n\nTask   %15s%15s\n"
>> +   "   %15lu%15lu\n",
>> +   "voluntary", "nonvoluntary",
>> +   t->nvcsw, t->nivcsw);
>> +}
> 
> print_task_stats versus print_taskstats is a bit confusing, but I guess it
> doesn't matter.
> 
> More significantly, the whole idea of calling it "task stats" isn't a good
> one: it's far too general.  The whole kernel interface is called taskstats,
> but the additions here are a tiny part of that.
> 
> Perhaps task_context_switch_rates would be more appropriate, although
> rather a lot to type.
> 
>>  void print_ioacct(struct taskstats *t)
>>  {
>>  printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
>> @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
>>  struct msgtemplate msg;
>>  
>>  while (1) {
>> -c = getopt(argc, argv, "diw:r:m:t:p:v:l");
>> +c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
>>  if (c < 0)
>>  break;
>>  
>> @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
>>  printf("printing IO accounting\n");
>>  print_io_accounting = 1;
>>  break;
>> +case 'q':
>> +printf("printing task/process stasistics:\n");
>> +print_task_stats = 1;
>> +break;
>>  case 'w':
>>  strncpy(logfile, optarg, MAX_FILENAME);
>>  printf("write to file %s\n", logfile);
>> @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
>>  print_delayacct((struct 
>> taskstats *) NLA_DATA(na));
>>  if (print_io_accounting)
>>  print_ioacct((struct 
>> taskstats *) NLA_DATA(na));
>> +if (print_task_stats)
>> +print_taskstats((struct 
>> taskstats *) NLA_DATA(na));
>>  if (fd) {
>>  if (write(fd, 
>> NLA_DATA(na), na->nla_len) < 0) {
>>  err(1,"write 
>> error\n");
>> diff --git a/Documentation/accounting/taskstats-struct.txt 
>> b/Documentation/accounting/taskstats-struct.txt
>> index 661c797..c3ae6a9 100644
>> --- a/Documentation/accounting/taskstats-struct.txt
>> +++ b/Documentation/accounting/taskstats-struct.txt
>> @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
>> taskstats:
>>  /* Extended accounting fields end */
>>  Their values are collected if CONFIG_TASK_XACCT is set.
>>  
>> +4) Per-task and per-thread statistics
>> +
>>  Future extension should add fields to the end of the taskstats struct, and
>>  should not change the relative position of each field within the struct.
>>  
>> @@ -158,4 +160,8 @@ struct taskstats 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Andrew Morton
On Wed, 30 May 2007 18:49:46 +
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> 
> Removed syscall counters from patch.
> 
> 
> 
> 
> Patch makes available to the user the following
> task and process performance statistics:
>   * Involuntary Context Switches (task_struct->nivcsw)
>   * Voluntary Context Switches (task_struct->nvcsw)
>  
> Statistics information is available from:
> 1. taskstats interface (Documentation/accounting/)
>   2. /proc/PID/status (task only).
> 
> This data is useful for detecting hyperactivity
> patterns between processes.
> Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
>   

A few little things:

> 
> diff --git a/Documentation/accounting/getdelays.c 
> b/Documentation/accounting/getdelays.c
> index e9126e7..18d22ad 100644
> --- a/Documentation/accounting/getdelays.c
> +++ b/Documentation/accounting/getdelays.c
> @@ -49,6 +49,7 @@ char name[100];
>  int dbg;
>  int print_delays;
>  int print_io_accounting;
> +int print_task_stats;
>  __u64 stime, utime;
>  
>  #define PRINTF(fmt, arg...) {\
> @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
>  "IO%15s%15s\n"
>  "  %15llu%15llu\n"
>  "MEM   %15s%15s\n"
> -"  %15llu%15llu\n\n",
> +"  %15llu%15llu\n"
>  "count", "real total", "virtual total", "delay total",
>  t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
>  t->cpu_delay_total,
> @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
>  "count", "delay total", t->swapin_count, t->swapin_delay_total);
>  }
>  
> +void print_taskstats(struct taskstats *t)
> +{
> + printf("\n\nTask   %15s%15s\n"
> +"   %15lu%15lu\n",
> +"voluntary", "nonvoluntary",
> +t->nvcsw, t->nivcsw);
> +}

print_task_stats versus print_taskstats is a bit confusing, but I guess it
doesn't matter.

More significantly, the whole idea of calling it "task stats" isn't a good
one: it's far too general.  The whole kernel interface is called taskstats,
but the additions here are a tiny part of that.

Perhaps task_context_switch_rates would be more appropriate, although
rather a lot to type.

>  void print_ioacct(struct taskstats *t)
>  {
>   printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
> @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
>   struct msgtemplate msg;
>  
>   while (1) {
> - c = getopt(argc, argv, "diw:r:m:t:p:v:l");
> + c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
>   if (c < 0)
>   break;
>  
> @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
>   printf("printing IO accounting\n");
>   print_io_accounting = 1;
>   break;
> + case 'q':
> + printf("printing task/process stasistics:\n");
> + print_task_stats = 1;
> + break;
>   case 'w':
>   strncpy(logfile, optarg, MAX_FILENAME);
>   printf("write to file %s\n", logfile);
> @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
>   print_delayacct((struct 
> taskstats *) NLA_DATA(na));
>   if (print_io_accounting)
>   print_ioacct((struct 
> taskstats *) NLA_DATA(na));
> + if (print_task_stats)
> + print_taskstats((struct 
> taskstats *) NLA_DATA(na));
>   if (fd) {
>   if (write(fd, 
> NLA_DATA(na), na->nla_len) < 0) {
>   err(1,"write 
> error\n");
> diff --git a/Documentation/accounting/taskstats-struct.txt 
> b/Documentation/accounting/taskstats-struct.txt
> index 661c797..c3ae6a9 100644
> --- a/Documentation/accounting/taskstats-struct.txt
> +++ b/Documentation/accounting/taskstats-struct.txt
> @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
> taskstats:
>  /* Extended accounting fields end */
>  Their values are collected if CONFIG_TASK_XACCT is set.
>  
> +4) Per-task and per-thread statistics
> +
>  Future extension should add fields to the end of the taskstats struct, and
>  should not change the relative position of each field within the struct.
>  
> @@ -158,4 +160,8 @@ struct taskstats {
>  
>   /* Extended accounting fields end */
>  
> +4) Per-task and per-thread statistics
> + __u64   nvcsw;  /* Context voluntary switch counter */
> + __u64   nivcsw; /* Context involuntary switch counter */

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Andrew Morton
On Wed, 30 May 2007 18:49:46 +
Maxim Uvarov [EMAIL PROTECTED] wrote:

 
 Removed syscall counters from patch.
 
 
 
 
 Patch makes available to the user the following
 task and process performance statistics:
   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
  
 Statistics information is available from:
 1. taskstats interface (Documentation/accounting/)
   2. /proc/PID/status (task only).
 
 This data is useful for detecting hyperactivity
 patterns between processes.
 Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
   

A few little things:

 
 diff --git a/Documentation/accounting/getdelays.c 
 b/Documentation/accounting/getdelays.c
 index e9126e7..18d22ad 100644
 --- a/Documentation/accounting/getdelays.c
 +++ b/Documentation/accounting/getdelays.c
 @@ -49,6 +49,7 @@ char name[100];
  int dbg;
  int print_delays;
  int print_io_accounting;
 +int print_task_stats;
  __u64 stime, utime;
  
  #define PRINTF(fmt, arg...) {\
 @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
  IO%15s%15s\n
%15llu%15llu\n
  MEM   %15s%15s\n
 -  %15llu%15llu\n\n,
 +  %15llu%15llu\n
  count, real total, virtual total, delay total,
  t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
  t-cpu_delay_total,
 @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
  count, delay total, t-swapin_count, t-swapin_delay_total);
  }
  
 +void print_taskstats(struct taskstats *t)
 +{
 + printf(\n\nTask   %15s%15s\n
 +   %15lu%15lu\n,
 +voluntary, nonvoluntary,
 +t-nvcsw, t-nivcsw);
 +}

print_task_stats versus print_taskstats is a bit confusing, but I guess it
doesn't matter.

More significantly, the whole idea of calling it task stats isn't a good
one: it's far too general.  The whole kernel interface is called taskstats,
but the additions here are a tiny part of that.

Perhaps task_context_switch_rates would be more appropriate, although
rather a lot to type.

  void print_ioacct(struct taskstats *t)
  {
   printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
 @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
   struct msgtemplate msg;
  
   while (1) {
 - c = getopt(argc, argv, diw:r:m:t:p:v:l);
 + c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
   if (c  0)
   break;
  
 @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
   printf(printing IO accounting\n);
   print_io_accounting = 1;
   break;
 + case 'q':
 + printf(printing task/process stasistics:\n);
 + print_task_stats = 1;
 + break;
   case 'w':
   strncpy(logfile, optarg, MAX_FILENAME);
   printf(write to file %s\n, logfile);
 @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
   print_delayacct((struct 
 taskstats *) NLA_DATA(na));
   if (print_io_accounting)
   print_ioacct((struct 
 taskstats *) NLA_DATA(na));
 + if (print_task_stats)
 + print_taskstats((struct 
 taskstats *) NLA_DATA(na));
   if (fd) {
   if (write(fd, 
 NLA_DATA(na), na-nla_len)  0) {
   err(1,write 
 error\n);
 diff --git a/Documentation/accounting/taskstats-struct.txt 
 b/Documentation/accounting/taskstats-struct.txt
 index 661c797..c3ae6a9 100644
 --- a/Documentation/accounting/taskstats-struct.txt
 +++ b/Documentation/accounting/taskstats-struct.txt
 @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
 taskstats:
  /* Extended accounting fields end */
  Their values are collected if CONFIG_TASK_XACCT is set.
  
 +4) Per-task and per-thread statistics
 +
  Future extension should add fields to the end of the taskstats struct, and
  should not change the relative position of each field within the struct.
  
 @@ -158,4 +160,8 @@ struct taskstats {
  
   /* Extended accounting fields end */
  
 +4) Per-task and per-thread statistics
 + __u64   nvcsw;  /* Context voluntary switch counter */
 + __u64   nivcsw; /* Context involuntary switch counter */
 +
  }
 diff --git a/fs/proc/array.c b/fs/proc/array.c
 index 70e4fab..52e2bd9 100644
 --- a/fs/proc/array.c
 +++ b/fs/proc/array.c
 @@ -290,6 +290,13 @@ static inline char 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jay Lan
Add Jonathan Lim to cc, who is working on CSA userland implementation
to use the taskstats data that this patch is going to remove.

Thanks,
 - jay



Andrew Morton wrote:
 On Wed, 30 May 2007 18:49:46 +
 Maxim Uvarov [EMAIL PROTECTED] wrote:
 
 Removed syscall counters from patch.




 Patch makes available to the user the following
 task and process performance statistics:
  * Involuntary Context Switches (task_struct-nivcsw)
  * Voluntary Context Switches (task_struct-nvcsw)
 
 Statistics information is available from:
 1. taskstats interface (Documentation/accounting/)
  2. /proc/PID/status (task only).

 This data is useful for detecting hyperactivity
 patterns between processes.
 Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
   
 
 A few little things:
 
 diff --git a/Documentation/accounting/getdelays.c 
 b/Documentation/accounting/getdelays.c
 index e9126e7..18d22ad 100644
 --- a/Documentation/accounting/getdelays.c
 +++ b/Documentation/accounting/getdelays.c
 @@ -49,6 +49,7 @@ char name[100];
  int dbg;
  int print_delays;
  int print_io_accounting;
 +int print_task_stats;
  __u64 stime, utime;
  
  #define PRINTF(fmt, arg...) {   \
 @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
 IO%15s%15s\n
   %15llu%15llu\n
 MEM   %15s%15s\n
 - %15llu%15llu\n\n,
 + %15llu%15llu\n
 count, real total, virtual total, delay total,
 t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
 t-cpu_delay_total,
 @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
 count, delay total, t-swapin_count, t-swapin_delay_total);
  }
  
 +void print_taskstats(struct taskstats *t)
 +{
 +printf(\n\nTask   %15s%15s\n
 +  %15lu%15lu\n,
 +   voluntary, nonvoluntary,
 +   t-nvcsw, t-nivcsw);
 +}
 
 print_task_stats versus print_taskstats is a bit confusing, but I guess it
 doesn't matter.
 
 More significantly, the whole idea of calling it task stats isn't a good
 one: it's far too general.  The whole kernel interface is called taskstats,
 but the additions here are a tiny part of that.
 
 Perhaps task_context_switch_rates would be more appropriate, although
 rather a lot to type.
 
  void print_ioacct(struct taskstats *t)
  {
  printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
 @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
  struct msgtemplate msg;
  
  while (1) {
 -c = getopt(argc, argv, diw:r:m:t:p:v:l);
 +c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
  if (c  0)
  break;
  
 @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
  printf(printing IO accounting\n);
  print_io_accounting = 1;
  break;
 +case 'q':
 +printf(printing task/process stasistics:\n);
 +print_task_stats = 1;
 +break;
  case 'w':
  strncpy(logfile, optarg, MAX_FILENAME);
  printf(write to file %s\n, logfile);
 @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
  print_delayacct((struct 
 taskstats *) NLA_DATA(na));
  if (print_io_accounting)
  print_ioacct((struct 
 taskstats *) NLA_DATA(na));
 +if (print_task_stats)
 +print_taskstats((struct 
 taskstats *) NLA_DATA(na));
  if (fd) {
  if (write(fd, 
 NLA_DATA(na), na-nla_len)  0) {
  err(1,write 
 error\n);
 diff --git a/Documentation/accounting/taskstats-struct.txt 
 b/Documentation/accounting/taskstats-struct.txt
 index 661c797..c3ae6a9 100644
 --- a/Documentation/accounting/taskstats-struct.txt
 +++ b/Documentation/accounting/taskstats-struct.txt
 @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
 taskstats:
  /* Extended accounting fields end */
  Their values are collected if CONFIG_TASK_XACCT is set.
  
 +4) Per-task and per-thread statistics
 +
  Future extension should add fields to the end of the taskstats struct, and
  should not change the relative position of each field within the struct.
  
 @@ -158,4 +160,8 @@ struct taskstats {
  
  /* Extended accounting fields end */
  
 +4) Per-task and per-thread statistics
 +__u64   nvcsw;  /* Context voluntary switch counter */
 +__u64   nivcsw; /* Context involuntary switch counter */
 +
  }
 diff --git a/fs/proc/array.c 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jonathan Lim
Looking at the diffs below, I see context switch counters added.  What is
actually being removed?

Jonathan

On Mon Jun  4 12:33:15 2007, [EMAIL PROTECTED] wrote:
 
 Add Jonathan Lim to cc, who is working on CSA userland implementation
 to use the taskstats data that this patch is going to remove.
 
 Thanks,
  - jay
 
 Andrew Morton wrote:
  On Wed, 30 May 2007 18:49:46 +
  Maxim Uvarov [EMAIL PROTECTED] wrote:
  
  Removed syscall counters from patch.
 
  Patch makes available to the user the following
  task and process performance statistics:
 * Involuntary Context Switches (task_struct-nivcsw)
 * Voluntary Context Switches (task_struct-nvcsw)

  Statistics information is available from:
  1. taskstats interface (Documentation/accounting/)
 2. /proc/PID/status (task only).
 
  This data is useful for detecting hyperactivity
  patterns between processes.
  Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
  
  A few little things:
  
  diff --git a/Documentation/accounting/getdelays.c 
  b/Documentation/accounting/getdelays.c
  index e9126e7..18d22ad 100644
  --- a/Documentation/accounting/getdelays.c
  +++ b/Documentation/accounting/getdelays.c
  @@ -49,6 +49,7 @@ char name[100];
   int dbg;
   int print_delays;
   int print_io_accounting;
  +int print_task_stats;
   __u64 stime, utime;
   
   #define PRINTF(fmt, arg...) { \
  @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
IO%15s%15s\n
  %15llu%15llu\n
MEM   %15s%15s\n
  -   %15llu%15llu\n\n,
  +   %15llu%15llu\n
count, real total, virtual total, delay total,
t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
t-cpu_delay_total,
  @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
count, delay total, t-swapin_count, t-swapin_delay_total);
   }
   
  +void print_taskstats(struct taskstats *t)
  +{
  +  printf(\n\nTask   %15s%15s\n
  +%15lu%15lu\n,
  + voluntary, nonvoluntary,
  + t-nvcsw, t-nivcsw);
  +}
  
  print_task_stats versus print_taskstats is a bit confusing, but I guess it
  doesn't matter.
  
  More significantly, the whole idea of calling it task stats isn't a good
  one: it's far too general.  The whole kernel interface is called taskstats,
  but the additions here are a tiny part of that.
  
  Perhaps task_context_switch_rates would be more appropriate, although
  rather a lot to type.
  
   void print_ioacct(struct taskstats *t)
   {
 printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
  @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
 struct msgtemplate msg;
   
 while (1) {
  -  c = getopt(argc, argv, diw:r:m:t:p:v:l);
  +  c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
 if (c  0)
 break;
   
  @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
 printf(printing IO accounting\n);
 print_io_accounting = 1;
 break;
  +  case 'q':
  +  printf(printing task/process stasistics:\n);
  +  print_task_stats = 1;
  +  break;
 case 'w':
 strncpy(logfile, optarg, MAX_FILENAME);
 printf(write to file %s\n, logfile);
  @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
 print_delayacct((struct 
  taskstats *) NLA_DATA(na));
 if (print_io_accounting)
 print_ioacct((struct 
  taskstats *) NLA_DATA(na));
  +  if (print_task_stats)
  +  print_taskstats((struct 
  taskstats *) NLA_DATA(na));
 if (fd) {
 if (write(fd, 
  NLA_DATA(na), na-nla_len)  0) {
 err(1,write 
  error\n);
  diff --git a/Documentation/accounting/taskstats-struct.txt 
  b/Documentation/accounting/taskstats-struct.txt
  index 661c797..c3ae6a9 100644
  --- a/Documentation/accounting/taskstats-struct.txt
  +++ b/Documentation/accounting/taskstats-struct.txt
  @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
  taskstats:
   /* Extended accounting fields end */
   Their values are collected if CONFIG_TASK_XACCT is set.
   
  +4) Per-task and per-thread statistics
  +
   Future extension should add fields to the end of the taskstats struct, and
   should not change the relative position of each field within the struct.
   
  @@ -158,4 +160,8 @@ struct taskstats {
   
 /* Extended accounting fields end */
   
  +4) Per-task and per-thread statistics
  +  __u64   nvcsw;  /* Context 

Re: [PATCH] Performance Stats: Kernel patch

2007-06-04 Thread Jay Lan
Andrew Morton wrote:
 On Wed, 30 May 2007 18:49:46 +
 Maxim Uvarov [EMAIL PROTECTED] wrote:
 
 Removed syscall counters from patch.




 Patch makes available to the user the following
 task and process performance statistics:
  * Involuntary Context Switches (task_struct-nivcsw)
  * Voluntary Context Switches (task_struct-nvcsw)
 
 Statistics information is available from:
 1. taskstats interface (Documentation/accounting/)
  2. /proc/PID/status (task only).

 This data is useful for detecting hyperactivity
 patterns between processes.
 Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
   
 
 A few little things:
 
 diff --git a/Documentation/accounting/getdelays.c 
 b/Documentation/accounting/getdelays.c
 index e9126e7..18d22ad 100644
 --- a/Documentation/accounting/getdelays.c
 +++ b/Documentation/accounting/getdelays.c
 @@ -49,6 +49,7 @@ char name[100];
  int dbg;
  int print_delays;
  int print_io_accounting;
 +int print_task_stats;
  __u64 stime, utime;
  
  #define PRINTF(fmt, arg...) {   \
 @@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
 IO%15s%15s\n
   %15llu%15llu\n
 MEM   %15s%15s\n
 - %15llu%15llu\n\n,
 + %15llu%15llu\n
 count, real total, virtual total, delay total,
 t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
 t-cpu_delay_total,
 @@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
 count, delay total, t-swapin_count, t-swapin_delay_total);
  }
  
 +void print_taskstats(struct taskstats *t)
 +{
 +printf(\n\nTask   %15s%15s\n
 +  %15lu%15lu\n,
 +   voluntary, nonvoluntary,
 +   t-nvcsw, t-nivcsw);
 +}
 
 print_task_stats versus print_taskstats is a bit confusing, but I guess it
 doesn't matter.
 
 More significantly, the whole idea of calling it task stats isn't a good
 one: it's far too general.  The whole kernel interface is called taskstats,
 but the additions here are a tiny part of that.
 
 Perhaps task_context_switch_rates would be more appropriate, although
 rather a lot to type.
 
  void print_ioacct(struct taskstats *t)
  {
  printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
 @@ -227,7 +236,7 @@ int main(int argc, char *argv[])
  struct msgtemplate msg;
  
  while (1) {
 -c = getopt(argc, argv, diw:r:m:t:p:v:l);
 +c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
  if (c  0)
  break;
  
 @@ -240,6 +249,10 @@ int main(int argc, char *argv[])
  printf(printing IO accounting\n);
  print_io_accounting = 1;
  break;
 +case 'q':
 +printf(printing task/process stasistics:\n);
 +print_task_stats = 1;
 +break;
  case 'w':
  strncpy(logfile, optarg, MAX_FILENAME);
  printf(write to file %s\n, logfile);
 @@ -381,6 +394,8 @@ int main(int argc, char *argv[])
  print_delayacct((struct 
 taskstats *) NLA_DATA(na));
  if (print_io_accounting)
  print_ioacct((struct 
 taskstats *) NLA_DATA(na));
 +if (print_task_stats)
 +print_taskstats((struct 
 taskstats *) NLA_DATA(na));
  if (fd) {
  if (write(fd, 
 NLA_DATA(na), na-nla_len)  0) {
  err(1,write 
 error\n);
 diff --git a/Documentation/accounting/taskstats-struct.txt 
 b/Documentation/accounting/taskstats-struct.txt
 index 661c797..c3ae6a9 100644
 --- a/Documentation/accounting/taskstats-struct.txt
 +++ b/Documentation/accounting/taskstats-struct.txt
 @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
 taskstats:
  /* Extended accounting fields end */
  Their values are collected if CONFIG_TASK_XACCT is set.
  
 +4) Per-task and per-thread statistics
 +
  Future extension should add fields to the end of the taskstats struct, and
  should not change the relative position of each field within the struct.
  
 @@ -158,4 +160,8 @@ struct taskstats {
  
  /* Extended accounting fields end */
  
 +4) Per-task and per-thread statistics
 +__u64   nvcsw;  /* Context voluntary switch counter */
 +__u64   nivcsw; /* Context involuntary switch counter */
 +
  }
 diff --git a/fs/proc/array.c b/fs/proc/array.c
 index 70e4fab..52e2bd9 100644
 --- a/fs/proc/array.c
 +++ b/fs/proc/array.c
 @@ -290,6 +290,13 @@ static inline char *task_cap(struct 

[PATCH] Performance Stats: Kernel patch

2007-05-30 Thread Maxim Uvarov

Removed syscall counters from patch.




Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.
Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
  
---

 Documentation/accounting/getdelays.c  |   19 +--
 Documentation/accounting/taskstats-struct.txt |6 ++
 fs/proc/array.c   |8 
 include/linux/taskstats.h |5 -
 kernel/taskstats.c|4 
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..18d22ad 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   "IO%15s%15s\n"
   "  %15llu%15llu\n"
   "MEM   %15s%15s\n"
-  "  %15llu%15llu\n\n",
+  "  %15llu%15llu\n"
   "count", "real total", "virtual total", "delay total",
   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
   t->cpu_delay_total,
@@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf("\n\nTask   %15s%15s\n"
+  "   %15lu%15lu\n",
+  "voluntary", "nonvoluntary",
+  t->nvcsw, t->nivcsw);
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +236,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+   c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
if (c < 0)
break;
 
@@ -240,6 +249,10 @@ int main(int argc, char *argv[])
printf("printing IO accounting\n");
print_io_accounting = 1;
break;
+   case 'q':
+   printf("printing task/process stasistics:\n");
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf("write to file %s\n", logfile);
@@ -381,6 +394,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {
err(1,"write 
error\n");
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..c3ae6a9 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
+4) Per-task and per-thread statistics
+
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
 
@@ -158,4 +160,8 @@ struct taskstats {
 
/* Extended accounting fields end */
 
+4) Per-task and per-thread statistics
+   __u64   nvcsw;  /* Context voluntary switch counter */
+   __u64   nivcsw; /* Context involuntary switch counter */
+
 }
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 70e4fab..52e2bd9 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -290,6 +290,13 @@ static inline char *task_cap(struct task_struct *p, char 
*buffer)

[PATCH] Performance Stats: Kernel patch

2007-05-30 Thread Maxim Uvarov

Removed syscall counters from patch.




Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.
Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
  
---

 Documentation/accounting/getdelays.c  |   19 +--
 Documentation/accounting/taskstats-struct.txt |6 ++
 fs/proc/array.c   |8 
 include/linux/taskstats.h |5 -
 kernel/taskstats.c|4 
 5 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..18d22ad 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   IO%15s%15s\n
 %15llu%15llu\n
   MEM   %15s%15s\n
-%15llu%15llu\n\n,
+%15llu%15llu\n
   count, real total, virtual total, delay total,
   t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
   t-cpu_delay_total,
@@ -196,6 +197,14 @@ void print_delayacct(struct taskstats *t)
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf(\n\nTask   %15s%15s\n
+ %15lu%15lu\n,
+  voluntary, nonvoluntary,
+  t-nvcsw, t-nivcsw);
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
@@ -227,7 +236,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, diw:r:m:t:p:v:l);
+   c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
if (c  0)
break;
 
@@ -240,6 +249,10 @@ int main(int argc, char *argv[])
printf(printing IO accounting\n);
print_io_accounting = 1;
break;
+   case 'q':
+   printf(printing task/process stasistics:\n);
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf(write to file %s\n, logfile);
@@ -381,6 +394,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 
error\n);
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..c3ae6a9 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
 /* Extended accounting fields end */
 Their values are collected if CONFIG_TASK_XACCT is set.
 
+4) Per-task and per-thread statistics
+
 Future extension should add fields to the end of the taskstats struct, and
 should not change the relative position of each field within the struct.
 
@@ -158,4 +160,8 @@ struct taskstats {
 
/* Extended accounting fields end */
 
+4) Per-task and per-thread statistics
+   __u64   nvcsw;  /* Context voluntary switch counter */
+   __u64   nivcsw; /* Context involuntary switch counter */
+
 }
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 70e4fab..52e2bd9 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -290,6 +290,13 @@ static inline char *task_cap(struct task_struct *p, char 
*buffer)
cap_t(p-cap_permitted),

Re: [PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Andrew Morton
On Tue, 22 May 2007 17:19:52 +
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> Sorry for bothering you. I know you are very busy but could 
> you please tell me what is situation of this patch?

I'd like to add the context-switch accounting to the taskstats payload.

As we'd then need to uprev the taskstats payload and version it makes sense
to have a look around, see if there's anything else which should be in
there but got missed.



I don't think we can accept the number-of-syscalls accounting feature.  It
adds a memory increment into the kernel's number-one hotpath.  Something
which people like to obsessively microbenchmark.

And as I said earlier, a 32-bit counter can be overflowed in mere seconds,
so that needs to become 64-bit, in which case we add a memory increment and
a test-n-branch to that hottest path.


There _is_ some cumulative overhead here, and I don't see how the value of
the syscall counter can justify it.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Dave Jones
On Tue, May 22, 2007 at 05:19:52PM +, Maxim Uvarov wrote:

 > diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
 > index 4b187bb..bccfd6a 100644
 > --- a/include/asm-i386/thread_info.h
 > +++ b/include/asm-i386/thread_info.h
 > @@ -33,6 +33,7 @@ struct thread_info {
 >  int preempt_count;  /* 0 => preemptable, <0 => BUG 
 > */
 >  
 >  
 > +unsigned long   syscall_count;  /* Syscall counter */
 >  mm_segment_taddr_limit; /* thread address space:
 > 0-0xBFFF for user-thead
 > 0-0x for 
 > kernel-thread

It seems a bit unkind to bloat up the thread_info for every process
of every user when the common case will be people that don't care about
this feature at all.

Especially when the same information could be got from ptrace.

Dave

-- 
http://www.codemonkey.org.uk
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Maxim Uvarov
Hello Andrew,

Sorry for bothering you. I know you are very busy but could 
you please tell me what is situation of this patch? You wrote 
me you'll discuss  it with someone about it and say can it be 
accepted or not and in which form.  As I understand the 
situation all problems now are in syscall counter.  What 
about other counters?

I changed headers and re-resent patch as you asked. Are there any new?

If it could be accepted I can do fast syscalls  counting  too.


Thank you very much,
Maxim.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
* Number of system calls (added new counter
  thread_info->sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>
  
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   "IO%15s%15s\n"
   "  %15llu%15llu\n"
   "MEM   %15s%15s\n"
-  "  %15llu%15llu\n\n",
+  "  %15llu%15llu\n"
   "count", "real total", "virtual total", "delay total",
   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
   t->cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf("\n\nTask  %15s%15s%15s\n"
+  "  %15lu%15lu%15lu\n",
+  "syscalls", "voluntary", "nonvoluntary",
+  t->syscall_counter, t->nvcsw, t->nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+   c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
if (c < 0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf("printing IO accounting\n");
print_io_accounting = 1;
break;
+   case 'q':
+   printf("printing task/process stasistics:\n");
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf("write to file %s\n", logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {

Re: [PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Dave Jones
On Tue, May 22, 2007 at 05:19:52PM +, Maxim Uvarov wrote:

  diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
  index 4b187bb..bccfd6a 100644
  --- a/include/asm-i386/thread_info.h
  +++ b/include/asm-i386/thread_info.h
  @@ -33,6 +33,7 @@ struct thread_info {
   int preempt_count;  /* 0 = preemptable, 0 = BUG 
  */
   
   
  +unsigned long   syscall_count;  /* Syscall counter */
   mm_segment_taddr_limit; /* thread address space:
  0-0xBFFF for user-thead
  0-0x for 
  kernel-thread

It seems a bit unkind to bloat up the thread_info for every process
of every user when the common case will be people that don't care about
this feature at all.

Especially when the same information could be got from ptrace.

Dave

-- 
http://www.codemonkey.org.uk
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Andrew Morton
On Tue, 22 May 2007 17:19:52 +
Maxim Uvarov [EMAIL PROTECTED] wrote:

 Sorry for bothering you. I know you are very busy but could 
 you please tell me what is situation of this patch?

I'd like to add the context-switch accounting to the taskstats payload.

As we'd then need to uprev the taskstats payload and version it makes sense
to have a look around, see if there's anything else which should be in
there but got missed.



I don't think we can accept the number-of-syscalls accounting feature.  It
adds a memory increment into the kernel's number-one hotpath.  Something
which people like to obsessively microbenchmark.

And as I said earlier, a 32-bit counter can be overflowed in mere seconds,
so that needs to become 64-bit, in which case we add a memory increment and
a test-n-branch to that hottest path.


There _is_ some cumulative overhead here, and I don't see how the value of
the syscall counter can justify it.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-05-22 Thread Maxim Uvarov
Hello Andrew,

Sorry for bothering you. I know you are very busy but could 
you please tell me what is situation of this patch? You wrote 
me you'll discuss  it with someone about it and say can it be 
accepted or not and in which form.  As I understand the 
situation all problems now are in syscall counter.  What 
about other counters?

I changed headers and re-resent patch as you asked. Are there any new?

If it could be accepted I can do fast syscalls  counting  too.


Thank you very much,
Maxim.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)
* Number of system calls (added new counter
  thread_info-sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]
  
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   IO%15s%15s\n
 %15llu%15llu\n
   MEM   %15s%15s\n
-%15llu%15llu\n\n,
+%15llu%15llu\n
   count, real total, virtual total, delay total,
   t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
   t-cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf(\n\nTask  %15s%15s%15s\n
+%15lu%15lu%15lu\n,
+  syscalls, voluntary, nonvoluntary,
+  t-syscall_counter, t-nvcsw, t-nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, diw:r:m:t:p:v:l);
+   c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
if (c  0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf(printing IO accounting\n);
print_io_accounting = 1;
break;
+   case 'q':
+   printf(printing task/process stasistics:\n);
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf(write to file %s\n, logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 

Re: [PATCH] Performance Stats: Kernel patch

2007-05-12 Thread Andrea Righi
Maxim Uvarov wrote:
> diff --git a/Documentation/accounting/taskstats-struct.txt 
> b/Documentation/accounting/taskstats-struct.txt
> index 661c797..606aef6 100644
> --- a/Documentation/accounting/taskstats-struct.txt
> +++ b/Documentation/accounting/taskstats-struct.txt
> @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
> taskstats:
>  /* Extended accounting fields end */
>  Their values are collected if CONFIG_TASK_XACCT is set.
>  
> +4) Per-task and per-thread statistics
> +
>  Future extension should add fields to the end of the taskstats struct, and
>  should not change the relative position of each field within the struct.
>  
> @@ -158,4 +160,9 @@ struct taskstats {
>  
>   /* Extended accounting fields end */
>  
> +4) Per-task and per-thread statiscits

...a small typo in the documentation: s/statiscits/statistics/

-Andrea
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Performance Stats: Kernel patch

2007-05-12 Thread Andrea Righi
Maxim Uvarov wrote:
 diff --git a/Documentation/accounting/taskstats-struct.txt 
 b/Documentation/accounting/taskstats-struct.txt
 index 661c797..606aef6 100644
 --- a/Documentation/accounting/taskstats-struct.txt
 +++ b/Documentation/accounting/taskstats-struct.txt
 @@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
 taskstats:
  /* Extended accounting fields end */
  Their values are collected if CONFIG_TASK_XACCT is set.
  
 +4) Per-task and per-thread statistics
 +
  Future extension should add fields to the end of the taskstats struct, and
  should not change the relative position of each field within the struct.
  
 @@ -158,4 +160,9 @@ struct taskstats {
  
   /* Extended accounting fields end */
  
 +4) Per-task and per-thread statiscits

...a small typo in the documentation: s/statiscits/statistics/

-Andrea
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-05-11 Thread Maxim Uvarov

Hello,

Thanks all for very useful comments. 
Please review this version.


Best regards,
Maxim.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
* Number of system calls (added new counter
  thread_info->sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>


  
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   "IO%15s%15s\n"
   "  %15llu%15llu\n"
   "MEM   %15s%15s\n"
-  "  %15llu%15llu\n\n",
+  "  %15llu%15llu\n"
   "count", "real total", "virtual total", "delay total",
   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
   t->cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf("\n\nTask  %15s%15s%15s\n"
+  "  %15lu%15lu%15lu\n",
+  "syscalls", "voluntary", "nonvoluntary",
+  t->syscall_counter, t->nvcsw, t->nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+   c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
if (c < 0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf("printing IO accounting\n");
print_io_accounting = 1;
break;
+   case 'q':
+   printf("printing task/process stasistics:\n");
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf("write to file %s\n", logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {
err(1,"write 
error\n");
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..606aef6 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 

Re: [PATCH] Performance Stats: Kernel patch

2007-05-11 Thread Maxim Uvarov

Andi Kleen wrote:


Maxim Uvarov <[EMAIL PROTECTED]> writes:
 


This data is useful for detecting hyperactivity
patterns between processes.
   



You need a lot better rationale to slow down these important
fast paths. Particularly the syscall path is very hot.

Is this something that is really generally useful? The context
switch counters might be occasionally useful, but strace can
you just give the syscall count anyways. Still not sure 
it really should go into the standard kernel. Perhaps just keep it 
as a systemtap script?


-Andi
 


It is difficult to use strace for multi thread applications to
verify which thread is doing what.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Performance Stats: Kernel patch

2007-05-11 Thread Maxim Uvarov

Andi Kleen wrote:


Maxim Uvarov [EMAIL PROTECTED] writes:
 


This data is useful for detecting hyperactivity
patterns between processes.
   



You need a lot better rationale to slow down these important
fast paths. Particularly the syscall path is very hot.

Is this something that is really generally useful? The context
switch counters might be occasionally useful, but strace can
you just give the syscall count anyways. Still not sure 
it really should go into the standard kernel. Perhaps just keep it 
as a systemtap script?


-Andi
 


It is difficult to use strace for multi thread applications to
verify which thread is doing what.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-05-11 Thread Maxim Uvarov

Hello,

Thanks all for very useful comments. 
Please review this version.


Best regards,
Maxim.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)
* Number of system calls (added new counter
  thread_info-sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]


  
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   IO%15s%15s\n
 %15llu%15llu\n
   MEM   %15s%15s\n
-%15llu%15llu\n\n,
+%15llu%15llu\n
   count, real total, virtual total, delay total,
   t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
   t-cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf(\n\nTask  %15s%15s%15s\n
+%15lu%15lu%15lu\n,
+  syscalls, voluntary, nonvoluntary,
+  t-syscall_counter, t-nvcsw, t-nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, diw:r:m:t:p:v:l);
+   c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
if (c  0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf(printing IO accounting\n);
print_io_accounting = 1;
break;
+   case 'q':
+   printf(printing task/process stasistics:\n);
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf(write to file %s\n, logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 
error\n);
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..606aef6 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
 /* Extended accounting fields end */
 Their values 

Re: [PATCH] Performance Stats: Kernel patch

2007-05-10 Thread Andi Kleen
Maxim Uvarov <[EMAIL PROTECTED]> writes:
> 
> This data is useful for detecting hyperactivity
> patterns between processes.

You need a lot better rationale to slow down these important
fast paths. Particularly the syscall path is very hot.

Is this something that is really generally useful? The context
switch counters might be occasionally useful, but strace can
you just give the syscall count anyways. Still not sure 
it really should go into the standard kernel. Perhaps just keep it 
as a systemtap script?

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Performance Stats: Kernel patch

2007-05-10 Thread Maxim Uvarov

I'm sending here the latest version of this patch.
Seems it was not on lkml mail list.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct->nivcsw)
* Voluntary Context Switches (task_struct->nvcsw)
* Number of system calls (added new counter
  thread_info->sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]>

Signed-off-by: Maxim Uvarov <[EMAIL PROTECTED]> 
 
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   "IO%15s%15s\n"
   "  %15llu%15llu\n"
   "MEM   %15s%15s\n"
-  "  %15llu%15llu\n\n",
+  "  %15llu%15llu\n"
   "count", "real total", "virtual total", "delay total",
   t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
   t->cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf("\n\nTask  %15s%15s%15s\n"
+  "  %15lu%15lu%15lu\n",
+  "syscalls", "voluntary", "nonvoluntary",
+  t->syscall_counter, t->nvcsw, t->nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, "diw:r:m:t:p:v:l");
+   c = getopt(argc, argv, "qdiw:r:m:t:p:v:l");
if (c < 0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf("printing IO accounting\n");
print_io_accounting = 1;
break;
+   case 'q':
+   printf("printing task/process stasistics:\n");
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf("write to file %s\n", logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na->nla_len) < 0) {
err(1,"write 
error\n");
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..5dac173 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There 

[PATCH] Performance Stats: Kernel patch

2007-05-10 Thread Maxim Uvarov

I'm sending here the latest version of this patch.
Seems it was not on lkml mail list.

Patch makes available to the user the following
task and process performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)
* Number of system calls (added new counter
  thread_info-sysall_count)
   
Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).

This data is useful for detecting hyperactivity
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED] 
 
---

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |3 +++
 kernel/taskstats.c|6 ++
 16 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/Documentation/accounting/getdelays.c 
b/Documentation/accounting/getdelays.c
index e9126e7..1be7d65 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_stats;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {  \
@@ -187,7 +188,7 @@ void print_delayacct(struct taskstats *t)
   IO%15s%15s\n
 %15llu%15llu\n
   MEM   %15s%15s\n
-%15llu%15llu\n\n,
+%15llu%15llu\n
   count, real total, virtual total, delay total,
   t-cpu_count, t-cpu_run_real_total, t-cpu_run_virtual_total,
   t-cpu_delay_total,
@@ -196,6 +197,15 @@ void print_delayacct(struct taskstats *t)
   count, delay total, t-swapin_count, t-swapin_delay_total);
 }
 
+void print_taskstats(struct taskstats *t)
+{
+   printf(\n\nTask  %15s%15s%15s\n
+%15lu%15lu%15lu\n,
+  syscalls, voluntary, nonvoluntary,
+  t-syscall_counter, t-nvcsw, t-nivcsw);
+
+}
+
 void print_ioacct(struct taskstats *t)
 {
printf(%s: read=%llu, write=%llu, cancelled_write=%llu\n,
@@ -227,7 +237,7 @@ int main(int argc, char *argv[])
struct msgtemplate msg;
 
while (1) {
-   c = getopt(argc, argv, diw:r:m:t:p:v:l);
+   c = getopt(argc, argv, qdiw:r:m:t:p:v:l);
if (c  0)
break;
 
@@ -240,6 +250,10 @@ int main(int argc, char *argv[])
printf(printing IO accounting\n);
print_io_accounting = 1;
break;
+   case 'q':
+   printf(printing task/process stasistics:\n);
+   print_task_stats = 1;
+   break;
case 'w':
strncpy(logfile, optarg, MAX_FILENAME);
printf(write to file %s\n, logfile);
@@ -381,6 +395,8 @@ int main(int argc, char *argv[])
print_delayacct((struct 
taskstats *) NLA_DATA(na));
if (print_io_accounting)
print_ioacct((struct 
taskstats *) NLA_DATA(na));
+   if (print_task_stats)
+   print_taskstats((struct 
taskstats *) NLA_DATA(na));
if (fd) {
if (write(fd, 
NLA_DATA(na), na-nla_len)  0) {
err(1,write 
error\n);
diff --git a/Documentation/accounting/taskstats-struct.txt 
b/Documentation/accounting/taskstats-struct.txt
index 661c797..5dac173 100644
--- a/Documentation/accounting/taskstats-struct.txt
+++ b/Documentation/accounting/taskstats-struct.txt
@@ -22,6 +22,8 @@ There are three different groups of fields in the struct 
taskstats:
   

Re: [PATCH] Performance Stats: Kernel patch

2007-05-10 Thread Andi Kleen
Maxim Uvarov [EMAIL PROTECTED] writes:
 
 This data is useful for detecting hyperactivity
 patterns between processes.

You need a lot better rationale to slow down these important
fast paths. Particularly the syscall path is very hot.

Is this something that is really generally useful? The context
switch counters might be occasionally useful, but strace can
you just give the syscall count anyways. Still not sure 
it really should go into the standard kernel. Perhaps just keep it 
as a systemtap script?

-Andi
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch] Performance Stats: Kernel patch

2007-04-25 Thread Maxim Uvarov

Hello Andrew,

I've added taskstats interface to that. Patch is attached.
Please also see my answers bellow.

Andrew Morton wrote:


(re-added lklml)

 

Patch makes available to the user the following 
thread performance statistics:

  * Involuntary Context Switches (task_struct->nivcsw)
  * Voluntary Context Switches (task_struct->nvcsw)
   



I suppose they might be useful, but I'd be interested in hearing what
the uses of this information are - why is it valuable?

 


We have had a customer request this feature.  I'm not sure exactly why they
want this feature, but in a telecom system it is very common to monitor
statistical information about various parts of the system and watch for
anomalies and trends.  If one of these statistics has a sudden spike or 
has a

gradual trend, the operator knows they need to take action before a problem
occurs or can go back and analyze why a spike occurred.

  * Number of system calls (added new counter 
thread_info->sysc_cnt)
   



eek.  syscall entry is a really hot hotpath, and, perhaps worse, it's the
sort of thing which people often measure ;)

I agree that this is a potentially interesting piece of instrumentation,
but it would need to be _super_ interesting to justify just the single
instruction overhead, and the cacheline touch.

So, again, please provide justification for this additional overhead.

 


Overhead is too small. And it is difficult to measure this difference.
I tried to measure syscall execution time with lat_syscall program
from lmbench package. I run each tests for 2-3 hours  with different
syscalls on qemu UP machine.

Test is:
./lat_syscall -N 1000 null
./lat_syscall -N 1000 read
./lat_syscall -N 1000 write
./lat_syscall -N 1000 stat
./lat_syscall -N 1000 fstat
./lat_syscall -N 1000 open

Result is  that  syscall patch is in the middle of  3 execution
without patch.

without patch:

Simple syscall: 1.0660 microseconds
Simple read: 3.5032 microseconds
Simple write: 2.6576 microseconds
Simple stat: 41.0829 microseconds
Simple fstat: 10.1343 microseconds
Simple open/close: 904.6792 microseconds

Simple syscall: 0.9961 microseconds
Simple read: 3.0027 microseconds
Simple write: 2.1600 microseconds
Simple stat: 47.7678 microseconds
Simple fstat: 10.8242 microseconds
Simple open/close: 905.9916 microseconds

Simple syscall: 1.0035 microseconds
Simple read: 3.0627 microseconds
Simple write: 2.1435 microseconds
Simple stat: 39.1947 microseconds
Simple fstat: 10.2982 microseconds
Simple open/close: 849.1624 microseconds


with patch:

Simple syscall: 1.0013 microseconds
Simple read: 3.6981 microseconds
Simple write: 2.6216 microseconds
Simple stat: 43.5101 microseconds
Simple fstat: 11.1318 microseconds
Simple open/close: 925.4793 microseconds

Because this measurement will be used with taskstats interface
I left it under ifdef CONFIG_TASKSTATS.

Best regards,
Maxim.

---

Patch makes available to the user the following 
task and process performance statistics:
   * Involuntary Context Switches (task_struct->nivcsw)
   * Voluntary Context Switches (task_struct->nvcsw)
   * Number of system calls (added new counter 
 thread_info->sysall_count)

Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |1 +
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|1 +
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |4 
 kernel/taskstats.c|6 ++
 16 files changed, 73 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -290,6 +290,19 @@ static inline char *task_cap(struct task
cap_t(p->cap_permitted),
cap_t(p->cap_effective));
 }
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+   /* Syscall counter adds 1 line overhead on each syscall 

Re: [patch] Performance Stats: Kernel patch

2007-04-25 Thread Maxim Uvarov

Hello Andrew,

I've added taskstats interface to that. Patch is attached.
Please also see my answers bellow.

Andrew Morton wrote:


(re-added lklml)

 

Patch makes available to the user the following 
thread performance statistics:

  * Involuntary Context Switches (task_struct-nivcsw)
  * Voluntary Context Switches (task_struct-nvcsw)
   



I suppose they might be useful, but I'd be interested in hearing what
the uses of this information are - why is it valuable?

 


We have had a customer request this feature.  I'm not sure exactly why they
want this feature, but in a telecom system it is very common to monitor
statistical information about various parts of the system and watch for
anomalies and trends.  If one of these statistics has a sudden spike or 
has a

gradual trend, the operator knows they need to take action before a problem
occurs or can go back and analyze why a spike occurred.

  * Number of system calls (added new counter 
thread_info-sysc_cnt)
   



eek.  syscall entry is a really hot hotpath, and, perhaps worse, it's the
sort of thing which people often measure ;)

I agree that this is a potentially interesting piece of instrumentation,
but it would need to be _super_ interesting to justify just the single
instruction overhead, and the cacheline touch.

So, again, please provide justification for this additional overhead.

 


Overhead is too small. And it is difficult to measure this difference.
I tried to measure syscall execution time with lat_syscall program
from lmbench package. I run each tests for 2-3 hours  with different
syscalls on qemu UP machine.

Test is:
./lat_syscall -N 1000 null
./lat_syscall -N 1000 read
./lat_syscall -N 1000 write
./lat_syscall -N 1000 stat
./lat_syscall -N 1000 fstat
./lat_syscall -N 1000 open

Result is  that  syscall patch is in the middle of  3 execution
without patch.

without patch:

Simple syscall: 1.0660 microseconds
Simple read: 3.5032 microseconds
Simple write: 2.6576 microseconds
Simple stat: 41.0829 microseconds
Simple fstat: 10.1343 microseconds
Simple open/close: 904.6792 microseconds

Simple syscall: 0.9961 microseconds
Simple read: 3.0027 microseconds
Simple write: 2.1600 microseconds
Simple stat: 47.7678 microseconds
Simple fstat: 10.8242 microseconds
Simple open/close: 905.9916 microseconds

Simple syscall: 1.0035 microseconds
Simple read: 3.0627 microseconds
Simple write: 2.1435 microseconds
Simple stat: 39.1947 microseconds
Simple fstat: 10.2982 microseconds
Simple open/close: 849.1624 microseconds


with patch:

Simple syscall: 1.0013 microseconds
Simple read: 3.6981 microseconds
Simple write: 2.6216 microseconds
Simple stat: 43.5101 microseconds
Simple fstat: 11.1318 microseconds
Simple open/close: 925.4793 microseconds

Because this measurement will be used with taskstats interface
I left it under ifdef CONFIG_TASKSTATS.

Best regards,
Maxim.

---

Patch makes available to the user the following 
task and process performance statistics:
   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
   * Number of system calls (added new counter 
 thread_info-sysall_count)

Statistics information is available from:
1. taskstats interface (Documentation/accounting/)
2. /proc/PID/status (task only).
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 Documentation/accounting/getdelays.c  |   20 ++--
 Documentation/accounting/taskstats-struct.txt |7 +++
 arch/i386/kernel/asm-offsets.c|1 +
 arch/i386/kernel/entry.S  |1 +
 arch/powerpc/kernel/asm-offsets.c |2 ++
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |1 +
 arch/x86_64/kernel/entry.S|1 +
 fs/proc/array.c   |   14 ++
 include/asm-i386/thread_info.h|1 +
 include/asm-powerpc/thread_info.h |1 +
 include/asm-x86_64/thread_info.h  |1 +
 include/linux/taskstats.h |6 +-
 kernel/fork.c |4 
 kernel/taskstats.c|6 ++
 16 files changed, 73 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -290,6 +290,19 @@ static inline char *task_cap(struct task
cap_t(p-cap_permitted),
cap_t(p-cap_effective));
 }
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+   /* Syscall counter adds 1 line overhead on each syscall execution
+  

Re: [patch] Performance Stats: Kernel patch

2007-04-19 Thread Andrew Morton
(re-added lklml)

> Patch makes available to the user the following 
> thread performance statistics:
>* Involuntary Context Switches (task_struct->nivcsw)
>* Voluntary Context Switches (task_struct->nvcsw)

I suppose they might be useful, but I'd be interested in hearing what
the uses of this information are - why is it valuable?

>* Number of system calls (added new counter 
>  thread_info->sysc_cnt)

eek.  syscall entry is a really hot hotpath, and, perhaps worse, it's the
sort of thing which people often measure ;)

I agree that this is a potentially interesting piece of instrumentation,
but it would need to be _super_ interesting to justify just the single
instruction overhead, and the cacheline touch.

So, again, please provide justification for this additional overhead.

> Statistics information is available from
> /proc/PID/status

No, /prod/pid is very lame.  If we're going to do this then we'll need to
deliver the information via taskstats.  And update getdelays.c and the
documentation, too.  We could also make it visible in /proc I guess, if
that's cheap to do.  But taskstats is the primary means of delivery - using
/proc is daft when we have that.

>  arch/powerpc/kernel/entry_32.S|5 +
>  arch/powerpc/kernel/entry_64.S|5 +
>  arch/x86_64/kernel/asm-offsets.c  |3 +++
>  arch/x86_64/kernel/entry.S|3 +++
>  fs/proc/array.c   |   17 +
>  include/asm-i386/thread_info.h|5 +++--
>  include/asm-powerpc/thread_info.h |3 +++
>  include/asm-x86_64/thread_info.h  |4 +++-
>  kernel/fork.c |4 
>  lib/Kconfig.debug |   15 +++
>  13 files changed, 71 insertions(+), 3 deletions(-)
> 

The patch adds far too many ifdefs to core C files.

> +#ifdef CONFIG_THREAD_PERF_STAT
> +static inline char *task_perf(struct task_struct *p, char *buffer)
> +{
> +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> +   buffer += sprintf(buffer, "Syscalls:\t%lu\n", 
> p->thread_info->sysc_cnt);
> +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
> +
> +   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
> +   "Nivcsw:\t%lu\n",
> +   p->nvcsw,
> +   p->nivcsw);
> +}

Here, you can put

#else
static inline char *task_perf(struct task_struct *p, char *buffer)
{
return buffer;
}

> +#endif /* CONFIG_THREAD_PERF_STAT */
> +
>  int proc_pid_status(struct task_struct *task, char * buffer)
>  {
>   char * orig = buffer;
> @@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
>  #if defined(CONFIG_S390)
>   buffer = task_show_regs(task, buffer);
>  #endif
> +#ifdef CONFIG_THREAD_PERF_STAT
> + buffer = task_perf(task, buffer);
> +#endif /* CONFIG_THREAD_PERF_STAT */

so these ifdefs go away

>   return buffer - orig;
>  }
>  
> Index: linux-2.6.21-rc5/kernel/fork.c
> ===
> --- linux-2.6.21-rc5.orig/kernel/fork.c
> +++ linux-2.6.21-rc5/kernel/fork.c
> @@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
>   p->syscr = 0;   /* I/O counter: read syscalls */
>   p->syscw = 0;   /* I/O counter: write syscalls */
>  #endif
> +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> +p->thread_info->sysc_cnt = 0;   /* Syscall counter: total numbers of 
> syscalls */
> +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */

And this can be removed via

#ifdef CONFIG_THREAD_PERF_STAT_SYSC
static inline thread_perf_stat_init(struct task_struct *p)
{
p->thread_info->sysc_cnt = 0;
}
#else
static inline thread_perf_stat_init(struct task_struct *p)
{
}
#endif

in a header file somewhere.

But I expect that you'll find that all your ifdefs can be removed, and you
can piggyback the whole feature on top of one of the existing taskstats
config items.

>   task_io_accounting_init(p);

So sysc_cnt will then get initialised in task_io_accounting_init() (perhaps
after suitably renaming task_io_accounting_init())

> +config THREAD_PERF_STAT
> +   bool "Thread performance statistics"
> +   help
> + Make available to the user the following per-thread performance 
> statistics:
> +* Number of involuntary context switches
> +* Number of voluntary context switches
> +* Number of system calls (optional)
> + This information is available via /proc/PID/status.
> +
> +config THREAD_PERF_STAT_SYSC
> +   bool "Enable syscall counter"
> +   depends on THREAD_PERF_STAT && (X86 || PPC)
> +   help
> + This option adds a syscall counter to /proc/PID/status.

I'm dubious about the configurability.

I think this is the sort of feature which we'd want to have generally
available, and to discourage people from disabling it.  I mean, if it's
useful enough to justify the runtime overhead, then it's pretty darn useful
and a lot of people will want it.

Probably making this a 

Re: [patch] Performance Stats: Kernel patch

2007-04-19 Thread Andrew Morton
(re-added lklml)

 Patch makes available to the user the following 
 thread performance statistics:
* Involuntary Context Switches (task_struct-nivcsw)
* Voluntary Context Switches (task_struct-nvcsw)

I suppose they might be useful, but I'd be interested in hearing what
the uses of this information are - why is it valuable?

* Number of system calls (added new counter 
  thread_info-sysc_cnt)

eek.  syscall entry is a really hot hotpath, and, perhaps worse, it's the
sort of thing which people often measure ;)

I agree that this is a potentially interesting piece of instrumentation,
but it would need to be _super_ interesting to justify just the single
instruction overhead, and the cacheline touch.

So, again, please provide justification for this additional overhead.

 Statistics information is available from
 /proc/PID/status

No, /prod/pid is very lame.  If we're going to do this then we'll need to
deliver the information via taskstats.  And update getdelays.c and the
documentation, too.  We could also make it visible in /proc I guess, if
that's cheap to do.  But taskstats is the primary means of delivery - using
/proc is daft when we have that.

  arch/powerpc/kernel/entry_32.S|5 +
  arch/powerpc/kernel/entry_64.S|5 +
  arch/x86_64/kernel/asm-offsets.c  |3 +++
  arch/x86_64/kernel/entry.S|3 +++
  fs/proc/array.c   |   17 +
  include/asm-i386/thread_info.h|5 +++--
  include/asm-powerpc/thread_info.h |3 +++
  include/asm-x86_64/thread_info.h  |4 +++-
  kernel/fork.c |4 
  lib/Kconfig.debug |   15 +++
  13 files changed, 71 insertions(+), 3 deletions(-)
 

The patch adds far too many ifdefs to core C files.

 +#ifdef CONFIG_THREAD_PERF_STAT
 +static inline char *task_perf(struct task_struct *p, char *buffer)
 +{
 +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
 +   buffer += sprintf(buffer, Syscalls:\t%lu\n, 
 p-thread_info-sysc_cnt);
 +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
 +
 +   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
 +   Nivcsw:\t%lu\n,
 +   p-nvcsw,
 +   p-nivcsw);
 +}

Here, you can put

#else
static inline char *task_perf(struct task_struct *p, char *buffer)
{
return buffer;
}

 +#endif /* CONFIG_THREAD_PERF_STAT */
 +
  int proc_pid_status(struct task_struct *task, char * buffer)
  {
   char * orig = buffer;
 @@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
  #if defined(CONFIG_S390)
   buffer = task_show_regs(task, buffer);
  #endif
 +#ifdef CONFIG_THREAD_PERF_STAT
 + buffer = task_perf(task, buffer);
 +#endif /* CONFIG_THREAD_PERF_STAT */

so these ifdefs go away

   return buffer - orig;
  }
  
 Index: linux-2.6.21-rc5/kernel/fork.c
 ===
 --- linux-2.6.21-rc5.orig/kernel/fork.c
 +++ linux-2.6.21-rc5/kernel/fork.c
 @@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
   p-syscr = 0;   /* I/O counter: read syscalls */
   p-syscw = 0;   /* I/O counter: write syscalls */
  #endif
 +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
 +p-thread_info-sysc_cnt = 0;   /* Syscall counter: total numbers of 
 syscalls */
 +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */

And this can be removed via

#ifdef CONFIG_THREAD_PERF_STAT_SYSC
static inline thread_perf_stat_init(struct task_struct *p)
{
p-thread_info-sysc_cnt = 0;
}
#else
static inline thread_perf_stat_init(struct task_struct *p)
{
}
#endif

in a header file somewhere.

But I expect that you'll find that all your ifdefs can be removed, and you
can piggyback the whole feature on top of one of the existing taskstats
config items.

   task_io_accounting_init(p);

So sysc_cnt will then get initialised in task_io_accounting_init() (perhaps
after suitably renaming task_io_accounting_init())

 +config THREAD_PERF_STAT
 +   bool Thread performance statistics
 +   help
 + Make available to the user the following per-thread performance 
 statistics:
 +* Number of involuntary context switches
 +* Number of voluntary context switches
 +* Number of system calls (optional)
 + This information is available via /proc/PID/status.
 +
 +config THREAD_PERF_STAT_SYSC
 +   bool Enable syscall counter
 +   depends on THREAD_PERF_STAT  (X86 || PPC)
 +   help
 + This option adds a syscall counter to /proc/PID/status.

I'm dubious about the configurability.

I think this is the sort of feature which we'd want to have generally
available, and to discourage people from disabling it.  I mean, if it's
useful enough to justify the runtime overhead, then it's pretty darn useful
and a lot of people will want it.

Probably making this a part of the taskstats suite would cover this well
enough.

 Index: 

Re: Performance Stats: Kernel patch

2007-04-16 Thread Maxim Uvarov

William Lee Irwin III wrote:


On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
 


nvcsw and nivcsw are conventional variable names for these quantities.
 



On Sun, Apr 15, 2007 at 08:10:24PM +, Pavel Machek wrote:
 


I can't decipher them and would not want users see them in /proc.
Would nonvoluntary_ctxt_switch be that much worse?
   



I'm not too attached to a particular name. I just think that the
traditional counter names should pass readability/etc. criteria on
account of the very strong historical precedent. I'd consider more
verbose affairs for the sake of putative legibility as equivalent
in quality. Maybe that means others voting for the more verbose
names should result in an aggregate decision in favor of verbosity.


-- wli
 


The standard /proc output is:
[EMAIL PROTECTED]:~# cat /proc/$$/status
Name:   bash
State:  S (sleeping)
SleepAVG:   88%
Tgid:   836
Pid:836
PPid:   1
TracerPid:  0
Uid:0   0   0   0
Gid:0   0   0   0
FDSize: 256
Groups: 0 1 2 4
VmPeak: 2360 kB
VmSize: 2360 kB
VmLck: 0 kB
VmHWM:  1400 kB
VmRSS:  1400 kB
VmData:  196 kB
VmStk:88 kB
VmExe:   564 kB
VmLib:  1412 kB
VmPTE:12 kB
Threads:1
SigQ:   0/1024
SigPnd: 
ShdPnd: 
SigBlk: 0001
SigIgn: 00384004
SigCgt: 4b813efb
CapInh: 
CapPrm: feff
CapEff: feff

I can't say that "Nvcsw" and "Nivcsw" is something less verbose as 
output above.

It is more usual  so it is more clear for you. But if you need this counters
you should know what are they and how to use them.

As for me "nonvoluntary_ctxt_switch" and "voluntary_ctxt_switch" is more 
verbose,

and it is not big deal to change names. But I think that information about
this counters and verbose name should be in user space tools, like ps.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-16 Thread Maxim Uvarov

William Lee Irwin III wrote:


On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
 


nvcsw and nivcsw are conventional variable names for these quantities.
 



On Sun, Apr 15, 2007 at 08:10:24PM +, Pavel Machek wrote:
 


I can't decipher them and would not want users see them in /proc.
Would nonvoluntary_ctxt_switch be that much worse?
   



I'm not too attached to a particular name. I just think that the
traditional counter names should pass readability/etc. criteria on
account of the very strong historical precedent. I'd consider more
verbose affairs for the sake of putative legibility as equivalent
in quality. Maybe that means others voting for the more verbose
names should result in an aggregate decision in favor of verbosity.


-- wli
 


The standard /proc output is:
[EMAIL PROTECTED]:~# cat /proc/$$/status
Name:   bash
State:  S (sleeping)
SleepAVG:   88%
Tgid:   836
Pid:836
PPid:   1
TracerPid:  0
Uid:0   0   0   0
Gid:0   0   0   0
FDSize: 256
Groups: 0 1 2 4
VmPeak: 2360 kB
VmSize: 2360 kB
VmLck: 0 kB
VmHWM:  1400 kB
VmRSS:  1400 kB
VmData:  196 kB
VmStk:88 kB
VmExe:   564 kB
VmLib:  1412 kB
VmPTE:12 kB
Threads:1
SigQ:   0/1024
SigPnd: 
ShdPnd: 
SigBlk: 0001
SigIgn: 00384004
SigCgt: 4b813efb
CapInh: 
CapPrm: feff
CapEff: feff

I can't say that Nvcsw and Nivcsw is something less verbose as 
output above.

It is more usual  so it is more clear for you. But if you need this counters
you should know what are they and how to use them.

As for me nonvoluntary_ctxt_switch and voluntary_ctxt_switch is more 
verbose,

and it is not big deal to change names. But I think that information about
this counters and verbose name should be in user space tools, like ps.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread William Lee Irwin III
On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
>> nvcsw and nivcsw are conventional variable names for these quantities.

On Sun, Apr 15, 2007 at 08:10:24PM +, Pavel Machek wrote:
> I can't decipher them and would not want users see them in /proc.
> Would nonvoluntary_ctxt_switch be that much worse?

I'm not too attached to a particular name. I just think that the
traditional counter names should pass readability/etc. criteria on
account of the very strong historical precedent. I'd consider more
verbose affairs for the sake of putative legibility as equivalent
in quality. Maybe that means others voting for the more verbose
names should result in an aggregate decision in favor of verbosity.


-- wli
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread Pavel Machek
Hi!

On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
> At some point in the past, someone's attribution was stripped from:

Maxim's.

> >> +   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
> >> +   "Nivcsw:\t%lu\n",
> >> +   p->nvcsw,
> >> +   p->nivcsw);
> 
> On Sun, Apr 15, 2007 at 09:47:07AM +, Pavel Machek wrote:
> > We don't encrypt variable names like this.
> 
> nvcsw and nivcsw are conventional variable names for these quantities.

I can't decipher them and would not want users see them in /proc.


Would nonvoluntary_ctxt_switch be that much worse?

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread William Lee Irwin III
At some point in the past, someone's attribution was stripped from:
>> +   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
>> +   "Nivcsw:\t%lu\n",
>> +   p->nvcsw,
>> +   p->nivcsw);

On Sun, Apr 15, 2007 at 09:47:07AM +, Pavel Machek wrote:
> We don't encrypt variable names like this.

nvcsw and nivcsw are conventional variable names for these quantities.


-- wli
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread Pavel Machek
Hi!

> +   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
> +   "Nivcsw:\t%lu\n",
> +   p->nvcsw,
> +   p->nivcsw);

We don't encrypt variable names like this.
Pavel


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread William Lee Irwin III
On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
 nvcsw and nivcsw are conventional variable names for these quantities.

On Sun, Apr 15, 2007 at 08:10:24PM +, Pavel Machek wrote:
 I can't decipher them and would not want users see them in /proc.
 Would nonvoluntary_ctxt_switch be that much worse?

I'm not too attached to a particular name. I just think that the
traditional counter names should pass readability/etc. criteria on
account of the very strong historical precedent. I'd consider more
verbose affairs for the sake of putative legibility as equivalent
in quality. Maybe that means others voting for the more verbose
names should result in an aggregate decision in favor of verbosity.


-- wli
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread Pavel Machek
Hi!

 +   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
 +   Nivcsw:\t%lu\n,
 +   p-nvcsw,
 +   p-nivcsw);

We don't encrypt variable names like this.
Pavel


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread William Lee Irwin III
At some point in the past, someone's attribution was stripped from:
 +   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
 +   Nivcsw:\t%lu\n,
 +   p-nvcsw,
 +   p-nivcsw);

On Sun, Apr 15, 2007 at 09:47:07AM +, Pavel Machek wrote:
 We don't encrypt variable names like this.

nvcsw and nivcsw are conventional variable names for these quantities.


-- wli
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-15 Thread Pavel Machek
Hi!

On Sun 2007-04-15 03:21:57, William Lee Irwin III wrote:
 At some point in the past, someone's attribution was stripped from:

Maxim's.

  +   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
  +   Nivcsw:\t%lu\n,
  +   p-nvcsw,
  +   p-nivcsw);
 
 On Sun, Apr 15, 2007 at 09:47:07AM +, Pavel Machek wrote:
  We don't encrypt variable names like this.
 
 nvcsw and nivcsw are conventional variable names for these quantities.

I can't decipher them and would not want users see them in /proc.


Would nonvoluntary_ctxt_switch be that much worse?

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-12 Thread Maxim Uvarov

Eric Dumazet wrote:


[snip]
What I meant is : You falsely speak of 'PROCESS performance statistics'.

Your implementation only cares about threads, not processes.
There is a slight difference, that getrusage() can do.

So if you do "cat /proc/PID/status", you'll get counters not for the 
PROCESS, only the main thread of the process.


If you want an analogy, imagine a "ps aux" that doesnt show the cpu 
time of all threads of a process, but only the cpu time of the main 
thread. Quite meaningless isnt it ?


So either :

1) You change all your description to mention 'thread' instead of 
'process'.


2) You change your implementation to match your claim.



Thanks again Eric, very useful notes. 


Important information is per-thread counters. So I changed only description.
Seems no issues now?

Patch is attached.

Best regards,
Maxim.
Patch makes available to the user the following 
thread performance statistics:
   * Involuntary Context Switches (task_struct->nivcsw)
   * Voluntary Context Switches (task_struct->nvcsw)
   * Number of system calls (added new counter 
 thread_info->sysc_cnt)

Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p->cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%lu\n", p->thread_info->sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   p->nvcsw,
+   p->nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p->syscr = 0;   /* I/O counter: read syscalls */
p->syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p->thread_info->sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool "Thread performance statistics"
+   help
+ Make available to the user the following per-thread performance 
statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool "Enable syscall counter"
+   depends on THREAD_PERF_STAT && (X86 || PPC)
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ 

Re: Performance Stats: Kernel patch

2007-04-12 Thread Maxim Uvarov

Eric Dumazet wrote:


[snip]
What I meant is : You falsely speak of 'PROCESS performance statistics'.

Your implementation only cares about threads, not processes.
There is a slight difference, that getrusage() can do.

So if you do cat /proc/PID/status, you'll get counters not for the 
PROCESS, only the main thread of the process.


If you want an analogy, imagine a ps aux that doesnt show the cpu 
time of all threads of a process, but only the cpu time of the main 
thread. Quite meaningless isnt it ?


So either :

1) You change all your description to mention 'thread' instead of 
'process'.


2) You change your implementation to match your claim.



Thanks again Eric, very useful notes. 


Important information is per-thread counters. So I changed only description.
Seems no issues now?

Patch is attached.

Best regards,
Maxim.
Patch makes available to the user the following 
thread performance statistics:
   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
   * Number of system calls (added new counter 
 thread_info-sysc_cnt)

Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p-cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%lu\n, p-thread_info-sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   p-nvcsw,
+   p-nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p-syscr = 0;   /* I/O counter: read syscalls */
p-syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p-thread_info-sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool Thread performance statistics
+   help
+ Make available to the user the following per-thread performance 
statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool Enable syscall counter
+   depends on THREAD_PERF_STAT  (X86 || PPC)
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ sysenter_past_esp:

Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet

Maxim Uvarov a écrit :

Eric Dumazet wrote:

 >Please check kernel/sys.c:k_getrusage() to see how getrusage() has to 
sum *lot* of individual fields to get precise process numbers (even 
counting stats for dead threads)




Thanks for helping me and for this link. But it is not enough clear for 
me what do you mean at this time.  Inside of patch I am using 2 default 
counters
task_struct->nivcsw and task_struct->nvcsw. And also one new syscall 
counter. And there is only one way to increment this counter, it is from 
entry.S.


If you are speaking about locks,  in my point of view, they are not 
needed in this code. Because increment syscall counter is atomic for X86 
(just one assembly instruction) and in case with PPC (3 instructions) 
there 1) nothing wrong will not happen in any case 2) only own thread 
can increase it's syscall counter. So here should be not any race 
conditions.


I was not speaking about locks.



I've tested this patch on x86,x86_64,and ppc_32. And I should work now 
with ppc_64 (I didn't check).

And  also updated description.

Best regards,
Maxim Uvarov.




Patch adds Process Performance Statistics.
It make available to the user the following 
thread performance statistics:

   * Involuntary Context Switches (task_struct->nivcsw)
   * Voluntary Context Switches (task_struct->nvcsw)
   * Number of system calls (added new counter 
 thread_info->sysc_cnt)


Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.




What I meant is : You falsely speak of 'PROCESS performance statistics'.

Your implementation only cares about threads, not processes.
There is a slight difference, that getrusage() can do.

So if you do "cat /proc/PID/status", you'll get counters not for the PROCESS, 
only the main thread of the process.


If you want an analogy, imagine a "ps aux" that doesnt show the cpu time of 
all threads of a process, but only the cpu time of the main thread. Quite 
meaningless isnt it ?


So either :

1) You change all your description to mention 'thread' instead of 'process'.

2) You change your implementation to match your claim.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Bill Davidsen wrote:


[snip]



Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you 
claimed)
  


I'm not sure if you were confused by his use of thread in parenthesis, 
but isn't the whole point of this to see which threads are doing what? 
Or am I misreading his result as intentional?


Yes the point is to get some statistics from thread in other words to 
see which threads are doing what.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:

>Please check kernel/sys.c:k_getrusage() to see how getrusage() has to 
sum *lot* of individual fields to get precise process numbers (even 
counting stats for dead threads)




Thanks for helping me and for this link. But it is not enough clear for 
me what do you mean at this time.  Inside of patch I am using 2 default 
counters
task_struct->nivcsw and task_struct->nvcsw. And also one new syscall 
counter. And there is only one way to increment this counter, it is from 
entry.S.


If you are speaking about locks,  in my point of view, they are not 
needed in this code. Because increment syscall counter is atomic for X86 
(just one assembly instruction) and in case with PPC (3 instructions) 
there 1) nothing wrong will not happen in any case 2) only own thread 
can increase it's syscall counter. So here should be not any race 
conditions.


I've tested this patch on x86,x86_64,and ppc_32. And I should work now 
with ppc_64 (I didn't check).

And  also updated description.

Best regards,
Maxim Uvarov.
Patch adds Process Performance Statistics.
It make available to the user the following 
thread performance statistics:
   * Involuntary Context Switches (task_struct->nivcsw)
   * Voluntary Context Switches (task_struct->nvcsw)
   * Number of system calls (added new counter 
 thread_info->sysc_cnt)

Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p->cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%lu\n", p->thread_info->sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   p->nvcsw,
+   p->nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p->syscr = 0;   /* I/O counter: read syscalls */
p->syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p->thread_info->sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool "Per-process (thread) performance statistics"
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool "Enable syscall counter"
+   depends on THREAD_PERF_STAT && (X86 || PPC)
+   help
+ This option adds a syscall counter to 

Re: Performance Stats: Kernel patch

2007-04-11 Thread Bill Davidsen

Eric Dumazet wrote:

On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

  

Patch adds Process Performance Statistics.
It make available to the user the following 
new per-process (thread) performance statistics:

   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls
   
This data is useful for detecting hyperactivity 
patterns between processes.



Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you claimed)
  
I'm not sure if you were confused by his use of thread in parenthesis, 
but isn't the whole point of this to see which threads are doing what? 
Or am I misreading his result as intentional?

Please check kernel/sys.c:k_getrusage() to see how getrusage() has to sum *lot* 
of individual fields to get precise process numbers (even counting stats for 
dead threads)

  

--
bill davidsen <[EMAIL PROTECTED]>
 CTO TMR Associates, Inc
 Doing interesting things with small computers since 1979

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet
On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> Patch adds Process Performance Statistics.
> It make available to the user the following 
> new per-process (thread) performance statistics:
>* Involuntary Context Switches
>* Voluntary Context Switches
>* Number of system calls
>
> This data is useful for detecting hyperactivity 
> patterns between processes.

Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you claimed)

Please check kernel/sys.c:k_getrusage() to see how getrusage() has to sum *lot* 
of individual fields to get precise process numbers (even counting stats for 
dead threads)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:



sysc_cnt being an 'unsigned long', its a 64 bits long integer...
So you probably need ld/std instructions instead of lwz/stw

 


Seems you are right again :(
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet
On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> Thanks Eric, I's really better. I have done changes. Do you have any 
> others objections now?
> All is in attached perf_stat.patch.

Hi Maxim

I know *nothing* about powerpc assembly, but I think there is a problem :

Index: linux-2.6.21-rc5/arch/powerpc/kernel/entry_64.S
===
--- linux-2.6.21-rc5.orig/arch/powerpc/kernel/entry_64.S
+++ linux-2.6.21-rc5/arch/powerpc/kernel/entry_64.S
@@ -115,6 +115,11 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISER
addir9,r1,STACK_FRAME_OVERHEAD
 #endif
clrrdi  r11,r1,THREAD_SHIFT
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   lwz r10,TI_SYSC_CNT(r11)
+   addi r10,r10,1
+   stw r10,TI_SYSC_CNT(r11)
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
ld  r10,TI_FLAGS(r11)
andi.   r11,r10,_TIF_SYSCALL_T_OR_A
bne-syscall_dotrace

sysc_cnt being an 'unsigned long', its a 64 bits long integer...
So you probably need ld/std instructions instead of lwz/stw

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:
[snip]

Please reorganize the code so that you dont duplicate 
GET_THREAD_INFO() stuff



Thanks Eric, I's really better. I have done changes. Do you have any 
others objections now?

All is in attached perf_stat.patch.

Best regards,
Maxim Uvarov.
Patch adds Process Performance Statistics.
It make available to the user the following 
new per-process (thread) performance statistics:
   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p->cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%lu\n", p->thread_info->sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   p->nvcsw,
+   p->nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p->syscr = 0;   /* I/O counter: read syscalls */
p->syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p->thread_info->sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool "Per-process (thread) performance statistics"
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool "Enable syscall counter"
+   depends on THREAD_PERF_STAT && (X86 || PPC)
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ sysenter_past_esp:
CFI_ADJUST_CFA_OFFSET 4
SAVE_ALL
GET_THREAD_INFO(%ebp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
 
/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not 
testb */
testw 
$(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Index: linux-2.6.21-rc5/arch/i386/kernel/asm-offsets.c
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/asm-offsets.c
+++ 

Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:
[snip]

Please reorganize the code so that you dont duplicate 
GET_THREAD_INFO() stuff



Thanks Eric, I's really better. I have done changes. Do you have any 
others objections now?

All is in attached perf_stat.patch.

Best regards,
Maxim Uvarov.
Patch adds Process Performance Statistics.
It make available to the user the following 
new per-process (thread) performance statistics:
   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p-cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%lu\n, p-thread_info-sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   p-nvcsw,
+   p-nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p-syscr = 0;   /* I/O counter: read syscalls */
p-syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p-thread_info-sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool Per-process (thread) performance statistics
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool Enable syscall counter
+   depends on THREAD_PERF_STAT  (X86 || PPC)
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ sysenter_past_esp:
CFI_ADJUST_CFA_OFFSET 4
SAVE_ALL
GET_THREAD_INFO(%ebp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
 
/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not 
testb */
testw 
$(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
Index: linux-2.6.21-rc5/arch/i386/kernel/asm-offsets.c
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/asm-offsets.c
+++ linux-2.6.21-rc5/arch/i386/kernel/asm-offsets.c
@@ -56,6 

Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet
On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:

 Thanks Eric, I's really better. I have done changes. Do you have any 
 others objections now?
 All is in attached perf_stat.patch.

Hi Maxim

I know *nothing* about powerpc assembly, but I think there is a problem :

Index: linux-2.6.21-rc5/arch/powerpc/kernel/entry_64.S
===
--- linux-2.6.21-rc5.orig/arch/powerpc/kernel/entry_64.S
+++ linux-2.6.21-rc5/arch/powerpc/kernel/entry_64.S
@@ -115,6 +115,11 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISER
addir9,r1,STACK_FRAME_OVERHEAD
 #endif
clrrdi  r11,r1,THREAD_SHIFT
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   lwz r10,TI_SYSC_CNT(r11)
+   addi r10,r10,1
+   stw r10,TI_SYSC_CNT(r11)
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
ld  r10,TI_FLAGS(r11)
andi.   r11,r10,_TIF_SYSCALL_T_OR_A
bne-syscall_dotrace

sysc_cnt being an 'unsigned long', its a 64 bits long integer...
So you probably need ld/std instructions instead of lwz/stw

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:



sysc_cnt being an 'unsigned long', its a 64 bits long integer...
So you probably need ld/std instructions instead of lwz/stw

 


Seems you are right again :(
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet
On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:

 Patch adds Process Performance Statistics.
 It make available to the user the following 
 new per-process (thread) performance statistics:
* Involuntary Context Switches
* Voluntary Context Switches
* Number of system calls

 This data is useful for detecting hyperactivity 
 patterns between processes.

Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you claimed)

Please check kernel/sys.c:k_getrusage() to see how getrusage() has to sum *lot* 
of individual fields to get precise process numbers (even counting stats for 
dead threads)

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Bill Davidsen

Eric Dumazet wrote:

On Wed, 11 Apr 2007 15:59:16 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:

  

Patch adds Process Performance Statistics.
It make available to the user the following 
new per-process (thread) performance statistics:

   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls
   
This data is useful for detecting hyperactivity 
patterns between processes.



Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you claimed)
  
I'm not sure if you were confused by his use of thread in parenthesis, 
but isn't the whole point of this to see which threads are doing what? 
Or am I misreading his result as intentional?

Please check kernel/sys.c:k_getrusage() to see how getrusage() has to sum *lot* 
of individual fields to get precise process numbers (even counting stats for 
dead threads)

  

--
bill davidsen [EMAIL PROTECTED]
 CTO TMR Associates, Inc
 Doing interesting things with small computers since 1979

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Eric Dumazet wrote:

Please check kernel/sys.c:k_getrusage() to see how getrusage() has to 
sum *lot* of individual fields to get precise process numbers (even 
counting stats for dead threads)




Thanks for helping me and for this link. But it is not enough clear for 
me what do you mean at this time.  Inside of patch I am using 2 default 
counters
task_struct-nivcsw and task_struct-nvcsw. And also one new syscall 
counter. And there is only one way to increment this counter, it is from 
entry.S.


If you are speaking about locks,  in my point of view, they are not 
needed in this code. Because increment syscall counter is atomic for X86 
(just one assembly instruction) and in case with PPC (3 instructions) 
there 1) nothing wrong will not happen in any case 2) only own thread 
can increase it's syscall counter. So here should be not any race 
conditions.


I've tested this patch on x86,x86_64,and ppc_32. And I should work now 
with ppc_64 (I didn't check).

And  also updated description.

Best regards,
Maxim Uvarov.
Patch adds Process Performance Statistics.
It make available to the user the following 
thread performance statistics:
   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
   * Number of system calls (added new counter 
 thread_info-sysc_cnt)

Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.

Signed-off-by: Maxim Uvarov [EMAIL PROTECTED]

 arch/i386/kernel/asm-offsets.c|3 +++
 arch/i386/kernel/entry.S  |3 +++
 arch/powerpc/kernel/asm-offsets.c |4 
 arch/powerpc/kernel/entry_32.S|5 +
 arch/powerpc/kernel/entry_64.S|5 +
 arch/x86_64/kernel/asm-offsets.c  |3 +++
 arch/x86_64/kernel/entry.S|3 +++
 fs/proc/array.c   |   17 +
 include/asm-i386/thread_info.h|5 +++--
 include/asm-powerpc/thread_info.h |3 +++
 include/asm-x86_64/thread_info.h  |4 +++-
 kernel/fork.c |4 
 lib/Kconfig.debug |   15 +++
 13 files changed, 71 insertions(+), 3 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p-cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%lu\n, p-thread_info-sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   p-nvcsw,
+   p-nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p-syscr = 0;   /* I/O counter: read syscalls */
p-syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p-thread_info-sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool Per-process (thread) performance statistics
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool Enable syscall counter
+   depends on THREAD_PERF_STAT  (X86 || PPC)
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: 

Re: Performance Stats: Kernel patch

2007-04-11 Thread Maxim Uvarov

Bill Davidsen wrote:


[snip]



Your description is not very clear about the semantic of your stats.

You currently returns stats only for thread(s) (not process as you 
claimed)
  


I'm not sure if you were confused by his use of thread in parenthesis, 
but isn't the whole point of this to see which threads are doing what? 
Or am I misreading his result as intentional?


Yes the point is to get some statistics from thread in other words to 
see which threads are doing what.

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-11 Thread Eric Dumazet

Maxim Uvarov a écrit :

Eric Dumazet wrote:

 Please check kernel/sys.c:k_getrusage() to see how getrusage() has to 
sum *lot* of individual fields to get precise process numbers (even 
counting stats for dead threads)




Thanks for helping me and for this link. But it is not enough clear for 
me what do you mean at this time.  Inside of patch I am using 2 default 
counters
task_struct-nivcsw and task_struct-nvcsw. And also one new syscall 
counter. And there is only one way to increment this counter, it is from 
entry.S.


If you are speaking about locks,  in my point of view, they are not 
needed in this code. Because increment syscall counter is atomic for X86 
(just one assembly instruction) and in case with PPC (3 instructions) 
there 1) nothing wrong will not happen in any case 2) only own thread 
can increase it's syscall counter. So here should be not any race 
conditions.


I was not speaking about locks.



I've tested this patch on x86,x86_64,and ppc_32. And I should work now 
with ppc_64 (I didn't check).

And  also updated description.

Best regards,
Maxim Uvarov.




Patch adds Process Performance Statistics.
It make available to the user the following 
thread performance statistics:

   * Involuntary Context Switches (task_struct-nivcsw)
   * Voluntary Context Switches (task_struct-nvcsw)
   * Number of system calls (added new counter 
 thread_info-sysc_cnt)


Statistics information is available from
/proc/PID/status
   
This data is useful for detecting hyperactivity 
patterns between processes.




What I meant is : You falsely speak of 'PROCESS performance statistics'.

Your implementation only cares about threads, not processes.
There is a slight difference, that getrusage() can do.

So if you do cat /proc/PID/status, you'll get counters not for the PROCESS, 
only the main thread of the process.


If you want an analogy, imagine a ps aux that doesnt show the cpu time of 
all threads of a process, but only the cpu time of the main thread. Quite 
meaningless isnt it ?


So either :

1) You change all your description to mention 'thread' instead of 'process'.

2) You change your implementation to match your claim.

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-10 Thread Pavel Machek
Hi!

> Yes I have tested it on PPC, X86, X86_64, Mips targets.
> It works.

> >>+   cap_t(p->nvcsw),
> >>+   cap_t(p->nivcsw),

Nvcsw? W dn't s ncrptd dntfrs lk nvcsw n krnl. (:-)

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-10 Thread Eric Dumazet
On Mon, 09 Apr 2007 18:22:22 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:



> --- linux-2.6.21-rc5.orig/arch/x86_64/kernel/entry.S
> +++ linux-2.6.21-rc5/arch/x86_64/kernel/entry.S
> @@ -236,6 +236,11 @@ ENTRY(system_call)
>   movq %r10,%rcx
>   call *sys_call_table(,%rax,8)  # XXX:rip relative
>   movq %rax,RAX-ARGOFFSET(%rsp)
> +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> + GET_THREAD_INFO(%rcx)
> + addq $1, threadinfo_sysc_cnt(%rcx)   # Increment syscalls counter
> +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
> +

Please reorganize the code so that you dont duplicate GET_THREAD_INFO() stuff
You can do this for example before calling the syscall, not after.

   ja badsys
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+  incq threadinfo_sysc_cnt(%rcx)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   movq %r10,%rcx
   call *sys_call_table(,%rax,8)  # XXX:rip relative
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-10 Thread Eric Dumazet
On Mon, 09 Apr 2007 18:22:22 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:



 --- linux-2.6.21-rc5.orig/arch/x86_64/kernel/entry.S
 +++ linux-2.6.21-rc5/arch/x86_64/kernel/entry.S
 @@ -236,6 +236,11 @@ ENTRY(system_call)
   movq %r10,%rcx
   call *sys_call_table(,%rax,8)  # XXX:rip relative
   movq %rax,RAX-ARGOFFSET(%rsp)
 +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
 + GET_THREAD_INFO(%rcx)
 + addq $1, threadinfo_sysc_cnt(%rcx)   # Increment syscalls counter
 +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
 +

Please reorganize the code so that you dont duplicate GET_THREAD_INFO() stuff
You can do this for example before calling the syscall, not after.

   ja badsys
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+  incq threadinfo_sysc_cnt(%rcx)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   movq %r10,%rcx
   call *sys_call_table(,%rax,8)  # XXX:rip relative
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-10 Thread Pavel Machek
Hi!

 Yes I have tested it on PPC, X86, X86_64, Mips targets.
 It works.

 +   cap_t(p-nvcsw),
 +   cap_t(p-nivcsw),

Nvcsw? W dn't s ncrptd dntfrs lk nvcsw n krnl. (:-)

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Performance Stats: Kernel patch

2007-04-09 Thread Maxim Uvarov

Hello collogues,

Patches make available to the user the following new per-process 
(thread) performance statistics:


   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls

This data is useful for detecting hyperactivity patterns between processes.

I have attached 3 patches  perf_stat.patch, perf_stat_x86_64.patch and 
perf_stat_ppc.patch for linux-2.6.21-rc5
and corrected all notes which were before.  Do you have any objections? 
I need your opinion again.


Best regards,
Maxim Uvarov.









Patch adds Process Performance Statistics.

 arch/i386/kernel/asm-offsets.c |3 +++
 arch/i386/kernel/entry.S   |6 ++
 fs/proc/array.c|   17 +
 include/asm-i386/thread_info.h |5 +++--
 kernel/fork.c  |4 
 lib/Kconfig.debug  |   15 +++
 6 files changed, 48 insertions(+), 2 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p->cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%lu\n", p->thread_info->sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   p->nvcsw,
+   p->nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p->syscr = 0;   /* I/O counter: read syscalls */
p->syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p->thread_info->sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool "Per-process (thread) performance statistics"
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool "Enable syscall counter"
+   depends on THREAD_PERF_STAT && X86_32
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -342,6 +342,9 @@ sysenter_past_esp:
jae syscall_badsys
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
DISABLE_INTERRUPTS(CLBR_ECX|CLBR_EDX)
TRACE_IRQS_OFF
movl TI_flags(%ebp), %ecx
@@ -385,6 +388,9 @@ syscall_call:
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp)  # store the return value
 syscall_exit:
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter 
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
DISABLE_INTERRUPTS(CLBR_ANY)# make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
Index: linux-2.6.21-rc5/arch/i386/kernel/asm-offsets.c
===
--- 

Performance Stats: Kernel patch

2007-04-09 Thread Maxim Uvarov

Hello collogues,

Patches make available to the user the following new per-process 
(thread) performance statistics:


   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls

This data is useful for detecting hyperactivity patterns between processes.

I have attached 3 patches  perf_stat.patch, perf_stat_x86_64.patch and 
perf_stat_ppc.patch for linux-2.6.21-rc5
and corrected all notes which were before.  Do you have any objections? 
I need your opinion again.


Best regards,
Maxim Uvarov.









Patch adds Process Performance Statistics.

 arch/i386/kernel/asm-offsets.c |3 +++
 arch/i386/kernel/entry.S   |6 ++
 fs/proc/array.c|   17 +
 include/asm-i386/thread_info.h |5 +++--
 kernel/fork.c  |4 
 lib/Kconfig.debug  |   15 +++
 6 files changed, 48 insertions(+), 2 deletions(-)

Index: linux-2.6.21-rc5/fs/proc/array.c
===
--- linux-2.6.21-rc5.orig/fs/proc/array.c
+++ linux-2.6.21-rc5/fs/proc/array.c
@@ -291,6 +291,20 @@ static inline char *task_cap(struct task
cap_t(p-cap_effective));
 }
 
+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%lu\n, p-thread_info-sysc_cnt);
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   p-nvcsw,
+   p-nivcsw);
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
char * orig = buffer;
@@ -309,6 +323,9 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_S390)
buffer = task_show_regs(task, buffer);
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
return buffer - orig;
 }
 
Index: linux-2.6.21-rc5/kernel/fork.c
===
--- linux-2.6.21-rc5.orig/kernel/fork.c
+++ linux-2.6.21-rc5/kernel/fork.c
@@ -1044,6 +1044,10 @@ static struct task_struct *copy_process(
p-syscr = 0;   /* I/O counter: read syscalls */
p-syscw = 0;   /* I/O counter: write syscalls */
 #endif
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+p-thread_info-sysc_cnt = 0;   /* Syscall counter: total numbers of 
syscalls */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
task_io_accounting_init(p);
acct_clear_integrals(p);
 
Index: linux-2.6.21-rc5/lib/Kconfig.debug
===
--- linux-2.6.21-rc5.orig/lib/Kconfig.debug
+++ linux-2.6.21-rc5/lib/Kconfig.debug
@@ -446,3 +446,18 @@ config FAULT_INJECTION_STACKTRACE_FILTER
select FRAME_POINTER
help
  Provide stacktrace filter for fault-injection capabilities
+
+config THREAD_PERF_STAT
+   bool Per-process (thread) performance statistics
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:
+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool Enable syscall counter
+   depends on THREAD_PERF_STAT  X86_32
+   help
+ This option adds a syscall counter to /proc/PID/status.
Index: linux-2.6.21-rc5/arch/i386/kernel/entry.S
===
--- linux-2.6.21-rc5.orig/arch/i386/kernel/entry.S
+++ linux-2.6.21-rc5/arch/i386/kernel/entry.S
@@ -342,6 +342,9 @@ sysenter_past_esp:
jae syscall_badsys
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
DISABLE_INTERRUPTS(CLBR_ECX|CLBR_EDX)
TRACE_IRQS_OFF
movl TI_flags(%ebp), %ecx
@@ -385,6 +388,9 @@ syscall_call:
call *sys_call_table(,%eax,4)
movl %eax,PT_EAX(%esp)  # store the return value
 syscall_exit:
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+inclTI_sysc_cnt(%ebp)   # Increment syscalls counter 
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
DISABLE_INTERRUPTS(CLBR_ANY)# make sure we don't miss an interrupt
# setting need_resched or sigpending
# between sampling and the iret
Index: linux-2.6.21-rc5/arch/i386/kernel/asm-offsets.c
===
--- 

Re: Performance Stats: Kernel patch

2007-04-06 Thread Bill Davidsen

[EMAIL PROTECTED] wrote:


2) It arrived here with some line-wrapping damage, most likely to the fact
that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
to make it not do that, but I have no idea what it is - it's in the list
archives someplace.


I don't use TBird (seamonkey fan) but I assume the patch can just be 
attached rather than inlined. Some mailers are pretty arcane otherwise.


But I do like the idea, but the issue of things which parse 
/proc/PID/status hasn't had comments. A good parser would ignore what it 
didn't understand, or take everything, not everyone has a good parser. ;-)


--
Bill Davidsen <[EMAIL PROTECTED]>
  "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-06 Thread Bill Davidsen

[EMAIL PROTECTED] wrote:


2) It arrived here with some line-wrapping damage, most likely to the fact
that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
to make it not do that, but I have no idea what it is - it's in the list
archives someplace.


I don't use TBird (seamonkey fan) but I assume the patch can just be 
attached rather than inlined. Some mailers are pretty arcane otherwise.


But I do like the idea, but the issue of things which parse 
/proc/PID/status hasn't had comments. A good parser would ignore what it 
didn't understand, or take everything, not everyone has a good parser. ;-)


--
Bill Davidsen [EMAIL PROTECTED]
  We have more to fear from the bungling of the incompetent than from
the machinations of the wicked.  - from Slashdot
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Randy Dunlap
On Wed, 04 Apr 2007 17:50:50 -0400 [EMAIL PROTECTED] wrote:

> Other random comments:
> 
> 1) You probably want to rebase against something more recent 
> (2.6.21-rc
> or the final .21 when it's released).
> 
> 2) It arrived here with some line-wrapping damage, most likely to the fact
> that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
> to make it not do that, but I have no idea what it is - it's in the list
> archives someplace.

This may help (or not):
  http://mbligh.org/linuxdocs/Email/Clients/Thunderbird

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Valdis . Kletnieks
On Wed, 04 Apr 2007 15:46:24 +0200, Eric Dumazet said:
> On Wed, 04 Apr 2007 17:15:43 +0400
> Maxim Uvarov <[EMAIL PROTECTED]> wrote:

> > +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> > +   call inc_syscallcnt # Increment syscalls counter 
> > current->sysc_cnt
> > +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
> 
> Please dont call a function to do one increment !
> 
> You are touching one of the most critical part of the kernel...

Obviously Eric and I looked at this looking for totally different things. :)

Thanks for spotting that, I totally failed to notice that part



pgpwFN1WBqjUI.pgp
Description: PGP signature


Re: Performance Stats: Kernel patch

2007-04-04 Thread Valdis . Kletnieks
On Wed, 04 Apr 2007 17:15:43 +0400, Maxim Uvarov said:

> New version of this patch. Please flay it.
> 
> 
> Signed-off-by: Max Uvarov <[EMAIL PROTECTED]>

> 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,20 @@ static inline char *task_cap(struct task
> cap_t(p->cap_effective));
>  }
> 
> +#ifdef CONFIG_THREAD_PERF_STAT
> +static inline char *task_perf(struct task_struct *p, char *buffer)
> +{
> +#ifdef THREAD_PERF_STAT_SYSC

Missed the CONFIG_ here.

> +   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
> +   "Nivcsw:\t%lu\n",
> +   cap_t(p->nvcsw),
> +   cap_t(p->nivcsw));

cap_t()??!?  That's from include/linux/capability.h, and looks something like:

#ifdef STRICT_CAP_T_TYPECHECKS
#define cap_t(x) (x).cap
#else
#define cap_t(x) (x)
#endif

and you're probably picking up the second part, making it a no-op.  And if you
ever hit the first part of that ifdef, you'll throw a compile error.

Somebody else can comment on the use of #ifdef - we tend to frown on it inside
open C code, but I'm not seeing a really brilliant way to avoid them entirely
(the 'static inline task_perf' can probably move to a .h, but it's hard to
find a clean way to avoid the ifdefs given that we have Kconfig variables
to select it. array.c already has a CONFIG_S390 in it, anyhow. :)

There's a mostly-hypothetical race between inc_syscall() and the places that
increment the context switch counters, and where we read the values - but at
worst, we'll output a stale off-by-one-ish value.  Certainly not worth
grabbing a lock on the task struct for *this* usage, but the sort of thing you
want to keep in mind as you write other code.

Other random comments:

1) You probably want to rebase against something more recent (2.6.21-rc
or the final .21 when it's released).

2) It arrived here with some line-wrapping damage, most likely to the fact
that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
to make it not do that, but I have no idea what it is - it's in the list
archives someplace.


pgprOong3K6a3.pgp
Description: PGP signature


Re: Performance Stats: Kernel patch

2007-04-04 Thread Eric Dumazet
On Wed, 04 Apr 2007 20:52:34 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:


> Index: linux-2.6.18/include/asm/thread_info.h
> ===
> --- linux-2.6.18.orig/include/asm/thread_info.h
> +++ linux-2.6.18/include/asm/thread_info.h
> @@ -44,6 +44,9 @@ struct thread_info {
>of nested (IRQ) stacks
> */
> __u8supervisor_stack[0];
> +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> +   unsigned long   sysc_cnt;   /* Syscall counter */
> +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
>  };
> 
>  #else /* !__ASSEMBLY__ */

You probably meant include/asm-i386/thread_info.h, not include/asm/thread_info.h

Then, you should not place sysc_cnt after supervisor_stack[0], since 
supervisor_stack[0] should be the last element of struct thread_info.

Better to put sysc_cnt right after preempt_count for example.

Also, is there any reason your patches are against 2.6.18, and not current 
kernel ?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Maxim Uvarov

Hello Eric,

I changed patch according to your comments.
Could you please take a look at it?

Eric Dumazet wrote:


On Wed, 04 Apr 2007 17:15:43 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

 


--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -394,6 +394,9 @@ syscall_exit:
   cli # make sure we don't miss an 
interrupt

   # setting need_resched or sigpending
   # between sampling and the iret
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   call inc_syscallcnt # Increment syscalls counter 
current->sysc_cnt

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   



Please dont call a function to do one increment !
 


Yes, you are right. I have changed it.


You are touching one of the most critical part of the kernel...

Also, dont do this while interrupts are masked, this is not necessary.

Maybe better to place sysc_cnt in 'struct thread_info' because %ebp point to it.
 




Also you missed the fact that syscalls on i386 can use sysenter (around line 
343)

 


   TRACE_IRQS_OFF
   movl TI_flags(%ebp), %ecx
   testw $_TIF_ALLWORK_MASK, %cx   # current->work

   


I rewrote this patch for x86.   And I have question. Should /proc/PID/status
be used for these counters and this option be selectable or it will 
better to

create another file in /proc/PID/  directory?

I will include syscall counters for other arches later.

P.S.
Jesper Juhl, thank you.

Best regards,
Maxim.

Signed-off-by: Max Uvarov <[EMAIL PROTECTED]>
Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/asm-offsets.c |3 +++
arch/i386/kernel/entry.S   |6 ++
fs/proc/array.c|   14 ++
include/asm/thread_info.h  |3 +++
kernel/fork.c  |3 +++
lib/Kconfig.debug  |   16 
6 files changed, 45 insertions(+)

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,20 @@ static inline char *task_cap(struct task
   cap_t(p->cap_effective));
}

+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%lu\n", 
cap_t(p->thread_info->sysc_cnt));

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   cap_t(p->nvcsw),
+   cap_t(p->nivcsw));
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
#define get_blocked_on(t)  (-1)

static char *show_blocked_on(struct task_struct *task, char *buffer)
Index: linux-2.6.18/arch/i386/kernel/entry.S
===
--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ sysenter_past_esp:
   jae syscall_badsys
   call *sys_call_table(,%eax,4)
   movl %eax,EAX(%esp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
#ifdef CONFIG_MICROSTATE
   call msa_end_syscall
#endif
@@ -388,6 +391,9 @@ syscall_call:
   call *sys_call_table(,%eax,4)
   movl %eax,EAX(%esp) # store the return value
syscall_exit:
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   inclTI_sysc_cnt(%ebp)   # Increment syscalls counter 
current->sysc_cnt

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
#ifdef CONFIG_MICROSTATE
   call msa_end_syscall
#endif
Index: linux-2.6.18/lib/Kconfig.debug
===
--- linux-2.6.18.orig/lib/Kconfig.debug
+++ linux-2.6.18/lib/Kconfig.debug
@@ -539,4 +539,20 @@ config RCU_TORTURE_TEST
 Say M if you want the RCU torture tests to build as a module.
 Say N if you are unsure.

+config THREAD_PERF_STAT
+   bool "Per-process (thread) performance statistics"
+   depends on X86
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:

+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool "Enable syscall counter"
+   depends on THREAD_PERF_STAT
+   help
+ This option adds a syscall counter to /proc/PID/status.
+
source "lib/Kconfig.kgdb"
Index: linux-2.6.18/include/asm/thread_info.h
===
--- linux-2.6.18.orig/include/asm/thread_info.h
+++ linux-2.6.18/include/asm/thread_info.h
@@ 

Re: Performance Stats: Kernel patch

2007-04-04 Thread Jesper Juhl

On 04/04/07, Maxim Uvarov <[EMAIL PROTECTED]> wrote:

Hello again,


[snip]

New version of this patch. Please flay it.



A few small comments below.



+config THREAD_PERF_STAT
+   bool "Per-process (thread) performance statistics"
+   depends on (X86 || PPC || MIPS)
+   help
+ Make available to the user the following new per-process
(thread) performance statistics:


Get rid of the word "new" - it won't continue to be a "new" feature forever :-)


+   * Involuntary Context Switches
+   * Voluntary Context Switches
+   * Number of system calls (option)


In the first two lines you Capitalize Each Word, but in the last line
you don't - why?
Shouldn't the first two have "Number of" prepended?
Perhaps it's just me, but I would write "(optional)" instead of "(option)".

In short, I'd suggest this :

  * Number of involuntary context switches
  * Number of voluntary context switches
  * Number of system calls (optional)


+ This information is available via /proc/PID/status.


What about tools that currently parse /proc/PID/status ?  Don't you
risk breaking userland stuff by changing this file?   Wouldn't it be
better to use a new file?


+
+config THREAD_PERF_STAT_SYSC
+   bool "enable syscall counter"


Capitalize the first word; "Enable syscall counter" .


+   depends on THREAD_PERF_STAT
+   help
+  This option add syscalls counter to  /proc/PID/status.


I'd probably have written "This option adds a syscall counter to
/proc/PID/status."


--
Jesper Juhl <[EMAIL PROTECTED]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please  http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Eric Dumazet
On Wed, 04 Apr 2007 17:15:43 +0400
Maxim Uvarov <[EMAIL PROTECTED]> wrote:

>
> --- linux-2.6.18.orig/arch/i386/kernel/entry.S
> +++ linux-2.6.18/arch/i386/kernel/entry.S
> @@ -394,6 +394,9 @@ syscall_exit:
> cli # make sure we don't miss an 
> interrupt
> # setting need_resched or sigpending
> # between sampling and the iret
> +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
> +   call inc_syscallcnt # Increment syscalls counter 
> current->sysc_cnt
> +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */

Please dont call a function to do one increment !

You are touching one of the most critical part of the kernel...

Also, dont do this while interrupts are masked, this is not necessary.

Maybe better to place sysc_cnt in 'struct thread_info' because %ebp point to it.

Also you missed the fact that syscalls on i386 can use sysenter (around line 
343)

> TRACE_IRQS_OFF
> movl TI_flags(%ebp), %ecx
> testw $_TIF_ALLWORK_MASK, %cx   # current->work
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Maxim Uvarov

Hello again,

Please see my answers bellow:

[EMAIL PROTECTED] wrote:


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?
 


Yes I have tested it on PPC, X86, X86_64, Mips targets.
It works.

 


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.
 


Yes you are right. I have not check it after adding ifdef :(

 


+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...


 


New version of this patch. Please flay it.


Signed-off-by: Max Uvarov <[EMAIL PROTECTED]>
Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/entry.S   |3 +++
arch/mips/kernel/entry.S   |3 +++
arch/powerpc/kernel/entry_32.S |3 +++
arch/x86_64/kernel/entry.S |3 +++
fs/proc/array.c|   17 +
include/linux/sched.h  |3 +++
kernel/fork.c  |3 +++
kernel/sys.c   |8 
lib/Kconfig.debug  |   17 +
9 files changed, 60 insertions(+)

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,20 @@ static inline char *task_cap(struct task
   cap_t(p->cap_effective));
}

+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, "Syscalls:\t%d\n", cap_t(p->sysc_cnt));
+#endif /* THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, "Nvcsw:\t%lu\n"
+   "Nivcsw:\t%lu\n",
+   cap_t(p->nvcsw),
+   cap_t(p->nivcsw));
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
#define get_blocked_on(t)  (-1)

static char *show_blocked_on(struct task_struct *task, char *buffer)
@@ -327,6 +341,9 @@ int proc_pid_status(struct task_struct *
   buffer = task_show_regs(task, buffer);
#endif
   buffer = show_blocked_on(task,buffer);
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
   return buffer - orig;
}

Index: linux-2.6.18/include/linux/sched.h
===
--- linux-2.6.18.orig/include/linux/sched.h
+++ linux-2.6.18/include/linux/sched.h
@@ -1193,6 +1193,9 @@ struct task_struct {
   ltt_facility_t ltt_facilities[LTT_FAC_PER_PROCESS];
#endif //CONFIG_LTT_USERSPACE_GENERIC

+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   int sysc_cnt;   /* Syscall counter */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   /*
* task-specic data
* XXX: for a future release, MontaVista-only
Index: linux-2.6.18/kernel/sys.c
===
--- linux-2.6.18.orig/kernel/sys.c
+++ linux-2.6.18/kernel/sys.c
@@ -2071,3 +2071,11 @@ asmlinkage long sys_prctl(int option, un
   }
   return error;
}
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+asmlinkage void inc_syscallcnt(void)
+{
+   current->sysc_cnt += 1;
+   return;
+}
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
Index: linux-2.6.18/kernel/fork.c
===
--- linux-2.6.18.orig/kernel/fork.c
+++ linux-2.6.18/kernel/fork.c
@@ -1079,6 +1079,9 @@ static struct task_struct *copy_process(
   p->wchar = 0;   /* I/O counter: bytes written */
   p->syscr = 0;   /* 

Re: Performance Stats: Kernel patch

2007-04-04 Thread Maxim Uvarov

Hello again,

Please see my answers bellow:

[EMAIL PROTECTED] wrote:


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?
 


Yes I have tested it on PPC, X86, X86_64, Mips targets.
It works.

 


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.
 


Yes you are right. I have not check it after adding ifdef :(

 


+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...


 


New version of this patch. Please flay it.


Signed-off-by: Max Uvarov [EMAIL PROTECTED]
Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/entry.S   |3 +++
arch/mips/kernel/entry.S   |3 +++
arch/powerpc/kernel/entry_32.S |3 +++
arch/x86_64/kernel/entry.S |3 +++
fs/proc/array.c|   17 +
include/linux/sched.h  |3 +++
kernel/fork.c  |3 +++
kernel/sys.c   |8 
lib/Kconfig.debug  |   17 +
9 files changed, 60 insertions(+)

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,20 @@ static inline char *task_cap(struct task
   cap_t(p-cap_effective));
}

+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%d\n, cap_t(p-sysc_cnt));
+#endif /* THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   cap_t(p-nvcsw),
+   cap_t(p-nivcsw));
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
#define get_blocked_on(t)  (-1)

static char *show_blocked_on(struct task_struct *task, char *buffer)
@@ -327,6 +341,9 @@ int proc_pid_status(struct task_struct *
   buffer = task_show_regs(task, buffer);
#endif
   buffer = show_blocked_on(task,buffer);
+#ifdef CONFIG_THREAD_PERF_STAT
+   buffer = task_perf(task, buffer);
+#endif /* CONFIG_THREAD_PERF_STAT */
   return buffer - orig;
}

Index: linux-2.6.18/include/linux/sched.h
===
--- linux-2.6.18.orig/include/linux/sched.h
+++ linux-2.6.18/include/linux/sched.h
@@ -1193,6 +1193,9 @@ struct task_struct {
   ltt_facility_t ltt_facilities[LTT_FAC_PER_PROCESS];
#endif //CONFIG_LTT_USERSPACE_GENERIC

+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   int sysc_cnt;   /* Syscall counter */
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   /*
* task-specic data
* XXX: for a future release, MontaVista-only
Index: linux-2.6.18/kernel/sys.c
===
--- linux-2.6.18.orig/kernel/sys.c
+++ linux-2.6.18/kernel/sys.c
@@ -2071,3 +2071,11 @@ asmlinkage long sys_prctl(int option, un
   }
   return error;
}
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+asmlinkage void inc_syscallcnt(void)
+{
+   current-sysc_cnt += 1;
+   return;
+}
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
Index: linux-2.6.18/kernel/fork.c
===
--- linux-2.6.18.orig/kernel/fork.c
+++ linux-2.6.18/kernel/fork.c
@@ -1079,6 +1079,9 @@ static struct task_struct *copy_process(
   p-wchar = 0;   /* I/O counter: bytes written */
   p-syscr = 0;   /* I/O counter: read 

Re: Performance Stats: Kernel patch

2007-04-04 Thread Eric Dumazet
On Wed, 04 Apr 2007 17:15:43 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:


 --- linux-2.6.18.orig/arch/i386/kernel/entry.S
 +++ linux-2.6.18/arch/i386/kernel/entry.S
 @@ -394,6 +394,9 @@ syscall_exit:
 cli # make sure we don't miss an 
 interrupt
 # setting need_resched or sigpending
 # between sampling and the iret
 +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
 +   call inc_syscallcnt # Increment syscalls counter 
 current-sysc_cnt
 +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */

Please dont call a function to do one increment !

You are touching one of the most critical part of the kernel...

Also, dont do this while interrupts are masked, this is not necessary.

Maybe better to place sysc_cnt in 'struct thread_info' because %ebp point to it.

Also you missed the fact that syscalls on i386 can use sysenter (around line 
343)

 TRACE_IRQS_OFF
 movl TI_flags(%ebp), %ecx
 testw $_TIF_ALLWORK_MASK, %cx   # current-work

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Jesper Juhl

On 04/04/07, Maxim Uvarov [EMAIL PROTECTED] wrote:

Hello again,


[snip]

New version of this patch. Please flay it.



A few small comments below.



+config THREAD_PERF_STAT
+   bool Per-process (thread) performance statistics
+   depends on (X86 || PPC || MIPS)
+   help
+ Make available to the user the following new per-process
(thread) performance statistics:


Get rid of the word new - it won't continue to be a new feature forever :-)


+   * Involuntary Context Switches
+   * Voluntary Context Switches
+   * Number of system calls (option)


In the first two lines you Capitalize Each Word, but in the last line
you don't - why?
Shouldn't the first two have Number of prepended?
Perhaps it's just me, but I would write (optional) instead of (option).

In short, I'd suggest this :

  * Number of involuntary context switches
  * Number of voluntary context switches
  * Number of system calls (optional)


+ This information is available via /proc/PID/status.


What about tools that currently parse /proc/PID/status ?  Don't you
risk breaking userland stuff by changing this file?   Wouldn't it be
better to use a new file?


+
+config THREAD_PERF_STAT_SYSC
+   bool enable syscall counter


Capitalize the first word; Enable syscall counter .


+   depends on THREAD_PERF_STAT
+   help
+  This option add syscalls counter to  /proc/PID/status.


I'd probably have written This option adds a syscall counter to
/proc/PID/status.


--
Jesper Juhl [EMAIL PROTECTED]
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please  http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Maxim Uvarov

Hello Eric,

I changed patch according to your comments.
Could you please take a look at it?

Eric Dumazet wrote:


On Wed, 04 Apr 2007 17:15:43 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:

 


--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -394,6 +394,9 @@ syscall_exit:
   cli # make sure we don't miss an 
interrupt

   # setting need_resched or sigpending
   # between sampling and the iret
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   call inc_syscallcnt # Increment syscalls counter 
current-sysc_cnt

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
   



Please dont call a function to do one increment !
 


Yes, you are right. I have changed it.


You are touching one of the most critical part of the kernel...

Also, dont do this while interrupts are masked, this is not necessary.

Maybe better to place sysc_cnt in 'struct thread_info' because %ebp point to it.
 




Also you missed the fact that syscalls on i386 can use sysenter (around line 
343)

 


   TRACE_IRQS_OFF
   movl TI_flags(%ebp), %ecx
   testw $_TIF_ALLWORK_MASK, %cx   # current-work

   


I rewrote this patch for x86.   And I have question. Should /proc/PID/status
be used for these counters and this option be selectable or it will 
better to

create another file in /proc/PID/  directory?

I will include syscall counters for other arches later.

P.S.
Jesper Juhl, thank you.

Best regards,
Maxim.

Signed-off-by: Max Uvarov [EMAIL PROTECTED]
Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/asm-offsets.c |3 +++
arch/i386/kernel/entry.S   |6 ++
fs/proc/array.c|   14 ++
include/asm/thread_info.h  |3 +++
kernel/fork.c  |3 +++
lib/Kconfig.debug  |   16 
6 files changed, 45 insertions(+)

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,20 @@ static inline char *task_cap(struct task
   cap_t(p-cap_effective));
}

+#ifdef CONFIG_THREAD_PERF_STAT
+static inline char *task_perf(struct task_struct *p, char *buffer)
+{
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   buffer += sprintf(buffer, Syscalls:\t%lu\n, 
cap_t(p-thread_info-sysc_cnt));

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
+
+   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
+   Nivcsw:\t%lu\n,
+   cap_t(p-nvcsw),
+   cap_t(p-nivcsw));
+}
+#endif /* CONFIG_THREAD_PERF_STAT */
+
#define get_blocked_on(t)  (-1)

static char *show_blocked_on(struct task_struct *task, char *buffer)
Index: linux-2.6.18/arch/i386/kernel/entry.S
===
--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -334,6 +334,9 @@ sysenter_past_esp:
   jae syscall_badsys
   call *sys_call_table(,%eax,4)
   movl %eax,EAX(%esp)
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   inclTI_sysc_cnt(%ebp)   # Increment syscalls counter
+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
#ifdef CONFIG_MICROSTATE
   call msa_end_syscall
#endif
@@ -388,6 +391,9 @@ syscall_call:
   call *sys_call_table(,%eax,4)
   movl %eax,EAX(%esp) # store the return value
syscall_exit:
+#ifdef CONFIG_THREAD_PERF_STAT_SYSC
+   inclTI_sysc_cnt(%ebp)   # Increment syscalls counter 
current-sysc_cnt

+#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
#ifdef CONFIG_MICROSTATE
   call msa_end_syscall
#endif
Index: linux-2.6.18/lib/Kconfig.debug
===
--- linux-2.6.18.orig/lib/Kconfig.debug
+++ linux-2.6.18/lib/Kconfig.debug
@@ -539,4 +539,20 @@ config RCU_TORTURE_TEST
 Say M if you want the RCU torture tests to build as a module.
 Say N if you are unsure.

+config THREAD_PERF_STAT
+   bool Per-process (thread) performance statistics
+   depends on X86
+   help
+ Make available to the user the following per-process (thread) 
performance statistics:

+* Number of involuntary context switches
+* Number of voluntary context switches
+* Number of system calls (optional)
+ This information is available via /proc/PID/status.
+
+config THREAD_PERF_STAT_SYSC
+   bool Enable syscall counter
+   depends on THREAD_PERF_STAT
+   help
+ This option adds a syscall counter to /proc/PID/status.
+
source lib/Kconfig.kgdb
Index: linux-2.6.18/include/asm/thread_info.h
===
--- linux-2.6.18.orig/include/asm/thread_info.h
+++ linux-2.6.18/include/asm/thread_info.h
@@ -44,6 +44,9 @@ struct 

Re: Performance Stats: Kernel patch

2007-04-04 Thread Eric Dumazet
On Wed, 04 Apr 2007 20:52:34 +0400
Maxim Uvarov [EMAIL PROTECTED] wrote:


 Index: linux-2.6.18/include/asm/thread_info.h
 ===
 --- linux-2.6.18.orig/include/asm/thread_info.h
 +++ linux-2.6.18/include/asm/thread_info.h
 @@ -44,6 +44,9 @@ struct thread_info {
of nested (IRQ) stacks
 */
 __u8supervisor_stack[0];
 +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
 +   unsigned long   sysc_cnt;   /* Syscall counter */
 +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
  };
 
  #else /* !__ASSEMBLY__ */

You probably meant include/asm-i386/thread_info.h, not include/asm/thread_info.h

Then, you should not place sysc_cnt after supervisor_stack[0], since 
supervisor_stack[0] should be the last element of struct thread_info.

Better to put sysc_cnt right after preempt_count for example.

Also, is there any reason your patches are against 2.6.18, and not current 
kernel ?

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-04 Thread Valdis . Kletnieks
On Wed, 04 Apr 2007 17:15:43 +0400, Maxim Uvarov said:

 New version of this patch. Please flay it.
 
 
 Signed-off-by: Max Uvarov [EMAIL PROTECTED]

 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,20 @@ static inline char *task_cap(struct task
 cap_t(p-cap_effective));
  }
 
 +#ifdef CONFIG_THREAD_PERF_STAT
 +static inline char *task_perf(struct task_struct *p, char *buffer)
 +{
 +#ifdef THREAD_PERF_STAT_SYSC

Missed the CONFIG_ here.

 +   return buffer + sprintf(buffer, Nvcsw:\t%lu\n
 +   Nivcsw:\t%lu\n,
 +   cap_t(p-nvcsw),
 +   cap_t(p-nivcsw));

cap_t()??!?  That's from include/linux/capability.h, and looks something like:

#ifdef STRICT_CAP_T_TYPECHECKS
#define cap_t(x) (x).cap
#else
#define cap_t(x) (x)
#endif

and you're probably picking up the second part, making it a no-op.  And if you
ever hit the first part of that ifdef, you'll throw a compile error.

Somebody else can comment on the use of #ifdef - we tend to frown on it inside
open C code, but I'm not seeing a really brilliant way to avoid them entirely
(the 'static inline task_perf' can probably move to a .h, but it's hard to
find a clean way to avoid the ifdefs given that we have Kconfig variables
to select it. array.c already has a CONFIG_S390 in it, anyhow. :)

There's a mostly-hypothetical race between inc_syscall() and the places that
increment the context switch counters, and where we read the values - but at
worst, we'll output a stale off-by-one-ish value.  Certainly not worth
grabbing a lock on the task struct for *this* usage, but the sort of thing you
want to keep in mind as you write other code.

Other random comments:

1) You probably want to rebase against something more recent (2.6.21-rcmumble
or the final .21 when it's released).

2) It arrived here with some line-wrapping damage, most likely to the fact
that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
to make it not do that, but I have no idea what it is - it's in the list
archives someplace.


pgprOong3K6a3.pgp
Description: PGP signature


Re: Performance Stats: Kernel patch

2007-04-04 Thread Valdis . Kletnieks
On Wed, 04 Apr 2007 15:46:24 +0200, Eric Dumazet said:
 On Wed, 04 Apr 2007 17:15:43 +0400
 Maxim Uvarov [EMAIL PROTECTED] wrote:

  +#ifdef CONFIG_THREAD_PERF_STAT_SYSC
  +   call inc_syscallcnt # Increment syscalls counter 
  current-sysc_cnt
  +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */
 
 Please dont call a function to do one increment !
 
 You are touching one of the most critical part of the kernel...

Obviously Eric and I looked at this looking for totally different things. :)

Thanks for spotting that, I totally failed to notice that part



pgpwFN1WBqjUI.pgp
Description: PGP signature


Re: Performance Stats: Kernel patch

2007-04-04 Thread Randy Dunlap
On Wed, 04 Apr 2007 17:50:50 -0400 [EMAIL PROTECTED] wrote:

 Other random comments:
 
 1) You probably want to rebase against something more recent 
 (2.6.21-rcmumble
 or the final .21 when it's released).
 
 2) It arrived here with some line-wrapping damage, most likely to the fact
 that you posted it with Thunderbird.  There's a mystic Thunderbird incantation
 to make it not do that, but I have no idea what it is - it's in the list
 archives someplace.

This may help (or not):
  http://mbligh.org/linuxdocs/Email/Clients/Thunderbird

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Performance Stats: Kernel patch

2007-04-03 Thread Valdis . Kletnieks
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...




pgpHOsZBHCGlH.pgp
Description: PGP signature


Performance Stats: Kernel patch

2007-04-03 Thread Maxim Uvarov

Hello all,

I have idea to include to the user the following new per-process 
(thread) performance statistics:


   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls

What do you think about it? Patch is bellow.

Best regards,
Max Uvarov.


Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/entry.S   |3 +++
arch/mips/kernel/entry.S   |3 +++
arch/powerpc/kernel/entry_32.S |3 +++
arch/x86_64/kernel/entry.S |3 +++
fs/proc/array.c|   13 +
include/linux/sched.h  |3 +++
kernel/fork.c  |3 +++
kernel/sys.c   |8 
lib/Kconfig.debug  |   10 ++
9 files changed, 49 insertions(+)

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
+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));
+}
+#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);
   return buffer - orig;
}

Index: linux-2.6.18/include/linux/sched.h
===
--- linux-2.6.18.orig/include/linux/sched.h
+++ linux-2.6.18/include/linux/sched.h
@@ -1193,6 +1193,9 @@ struct task_struct {
   ltt_facility_t ltt_facilities[LTT_FAC_PER_PROCESS];
#endif //CONFIG_LTT_USERSPACE_GENERIC

+#ifdef THREAD_PERF_STAT
+   int sysc_cnt;   /* Syscall counter */
+#endif /* THREAD_PERF_STAT */
   /*
* task-specic data
* XXX: for a future release, MontaVista-only
Index: linux-2.6.18/kernel/sys.c
===
--- linux-2.6.18.orig/kernel/sys.c
+++ linux-2.6.18/kernel/sys.c
@@ -2071,3 +2071,11 @@ asmlinkage long sys_prctl(int option, un
   }
   return error;
}
+#ifdef THREAD_PERF_STAT
+asmlinkage void inc_syscallcnt(void)
+{
+   current->sysc_cnt += 1;
+   return;
+}
+#endif /* THREAD_PERF_STAT */
+
Index: linux-2.6.18/kernel/fork.c
===
--- linux-2.6.18.orig/kernel/fork.c
+++ linux-2.6.18/kernel/fork.c
@@ -1079,6 +1079,9 @@ static struct task_struct *copy_process(
   p->wchar = 0;   /* I/O counter: bytes written */
   p->syscr = 0;   /* I/O counter: read syscalls */
   p->syscw = 0;   /* I/O counter: write syscalls */
+#ifdef THREAD_PERF_STAT
+   p->sysc_cnt = 0;/* Syscall counter: total numbers of 
syscalls */

+#endif /* THREAD_PERF_STAT */
   acct_clear_integrals(p);

   p->it_virt_expires = cputime_zero;
Index: linux-2.6.18/arch/i386/kernel/entry.S
===
--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -394,6 +394,9 @@ syscall_exit:
   cli # make sure we don't miss an 
interrupt

   # setting need_resched or sigpending
   # between sampling and the iret
+#ifdef THREAD_PERF_STAT
+   call inc_syscallcnt # Increment syscalls counter 
current->sysc_cnt

+#endif /* THREAD_PERF_STAT */
   TRACE_IRQS_OFF
   movl TI_flags(%ebp), %ecx
   testw $_TIF_ALLWORK_MASK, %cx   # current->work
Index: linux-2.6.18/arch/x86_64/kernel/entry.S
===
--- linux-2.6.18.orig/arch/x86_64/kernel/entry.S
+++ linux-2.6.18/arch/x86_64/kernel/entry.S
@@ -388,6 +388,9 @@ ENTRY(int_ret_from_sys_call)
   /* edi: mask to check */
int_with_check:
   GET_THREAD_INFO(%rcx)
+#ifdef THREAD_PERF_STAT
+   call inc_syscallcnt # Increment syscalls counter 
current->sysc_cnt

+#endif /* THREAD_PERF_STAT */
   movl threadinfo_flags(%rcx),%edx
   andl %edi,%edx
   jnz   int_careful
Index: linux-2.6.18/arch/powerpc/kernel/entry_32.S
===
--- linux-2.6.18.orig/arch/powerpc/kernel/entry_32.S
+++ linux-2.6.18/arch/powerpc/kernel/entry_32.S
@@ -236,6 +236,9 @@ ret_from_syscall:
#ifdef SHOW_SYSCALLS
   bl  

Performance Stats: Kernel patch

2007-04-03 Thread Maxim Uvarov

Hello all,

I have idea to include to the user the following new per-process 
(thread) performance statistics:


   * Involuntary Context Switches
   * Voluntary Context Switches
   * Number of system calls

What do you think about it? Patch is bellow.

Best regards,
Max Uvarov.


Description:
   Patch adds Process Performance Statistics.

arch/i386/kernel/entry.S   |3 +++
arch/mips/kernel/entry.S   |3 +++
arch/powerpc/kernel/entry_32.S |3 +++
arch/x86_64/kernel/entry.S |3 +++
fs/proc/array.c|   13 +
include/linux/sched.h  |3 +++
kernel/fork.c  |3 +++
kernel/sys.c   |8 
lib/Kconfig.debug  |   10 ++
9 files changed, 49 insertions(+)

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
+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));
+}
+#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);
   return buffer - orig;
}

Index: linux-2.6.18/include/linux/sched.h
===
--- linux-2.6.18.orig/include/linux/sched.h
+++ linux-2.6.18/include/linux/sched.h
@@ -1193,6 +1193,9 @@ struct task_struct {
   ltt_facility_t ltt_facilities[LTT_FAC_PER_PROCESS];
#endif //CONFIG_LTT_USERSPACE_GENERIC

+#ifdef THREAD_PERF_STAT
+   int sysc_cnt;   /* Syscall counter */
+#endif /* THREAD_PERF_STAT */
   /*
* task-specic data
* XXX: for a future release, MontaVista-only
Index: linux-2.6.18/kernel/sys.c
===
--- linux-2.6.18.orig/kernel/sys.c
+++ linux-2.6.18/kernel/sys.c
@@ -2071,3 +2071,11 @@ asmlinkage long sys_prctl(int option, un
   }
   return error;
}
+#ifdef THREAD_PERF_STAT
+asmlinkage void inc_syscallcnt(void)
+{
+   current-sysc_cnt += 1;
+   return;
+}
+#endif /* THREAD_PERF_STAT */
+
Index: linux-2.6.18/kernel/fork.c
===
--- linux-2.6.18.orig/kernel/fork.c
+++ linux-2.6.18/kernel/fork.c
@@ -1079,6 +1079,9 @@ static struct task_struct *copy_process(
   p-wchar = 0;   /* I/O counter: bytes written */
   p-syscr = 0;   /* I/O counter: read syscalls */
   p-syscw = 0;   /* I/O counter: write syscalls */
+#ifdef THREAD_PERF_STAT
+   p-sysc_cnt = 0;/* Syscall counter: total numbers of 
syscalls */

+#endif /* THREAD_PERF_STAT */
   acct_clear_integrals(p);

   p-it_virt_expires = cputime_zero;
Index: linux-2.6.18/arch/i386/kernel/entry.S
===
--- linux-2.6.18.orig/arch/i386/kernel/entry.S
+++ linux-2.6.18/arch/i386/kernel/entry.S
@@ -394,6 +394,9 @@ syscall_exit:
   cli # make sure we don't miss an 
interrupt

   # setting need_resched or sigpending
   # between sampling and the iret
+#ifdef THREAD_PERF_STAT
+   call inc_syscallcnt # Increment syscalls counter 
current-sysc_cnt

+#endif /* THREAD_PERF_STAT */
   TRACE_IRQS_OFF
   movl TI_flags(%ebp), %ecx
   testw $_TIF_ALLWORK_MASK, %cx   # current-work
Index: linux-2.6.18/arch/x86_64/kernel/entry.S
===
--- linux-2.6.18.orig/arch/x86_64/kernel/entry.S
+++ linux-2.6.18/arch/x86_64/kernel/entry.S
@@ -388,6 +388,9 @@ ENTRY(int_ret_from_sys_call)
   /* edi: mask to check */
int_with_check:
   GET_THREAD_INFO(%rcx)
+#ifdef THREAD_PERF_STAT
+   call inc_syscallcnt # Increment syscalls counter 
current-sysc_cnt

+#endif /* THREAD_PERF_STAT */
   movl threadinfo_flags(%rcx),%edx
   andl %edi,%edx
   jnz   int_careful
Index: linux-2.6.18/arch/powerpc/kernel/entry_32.S
===
--- linux-2.6.18.orig/arch/powerpc/kernel/entry_32.S
+++ linux-2.6.18/arch/powerpc/kernel/entry_32.S
@@ -236,6 +236,9 @@ ret_from_syscall:
#ifdef SHOW_SYSCALLS
   bl  do_show_syscall_exit
#endif

Re: Performance Stats: Kernel patch

2007-04-03 Thread Valdis . Kletnieks
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...




pgpHOsZBHCGlH.pgp
Description: PGP signature