bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add statistics for task_events_info


From: David Höppner
Subject: [PATCH] Add statistics for task_events_info
Date: Fri, 4 Jan 2013 23:20:00 +0100

Hi,

this adds the task_events_info statistics to the task structure. I will send
fixes for hurd ps and proc later.

thanks,
David


Subject: [PATCH] Add statistics for task_events_info

* ipc/ipc_mqueue.c (ipc_mqueue_send, ipc_mqueue_receive): Increment
counters for message sent and received.
* kern/ipc_kobject.c (ipc_kobject_server): Increment sent and received
counters for the kernel task.
* kern/task.c (task_create): Zero statistics.
* kern/task.c (task_info): Add task_events_info call.
* kern/task.h: Add statistics.
* vm/vm_fault.c (vm_fault_page): Increment zero_fills, pageins,
reactivations and cow_faults counters.
* vm/vm_fault.c (vm_fault_wire_fast): Increment faults counters.
* vm/vm_pageout.c (vm_pageout_scan): Increment reactivations counter.
---
 ipc/ipc_mqueue.c   |    4 ++++
 kern/ipc_kobject.c |   10 ++++++++--
 kern/task.c        |   31 +++++++++++++++++++++++++++++++
 kern/task.h        |    9 +++++++++
 vm/vm_fault.c      |    7 +++++++
 vm/vm_pageout.c    |    1 +
 6 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/ipc/ipc_mqueue.c b/ipc/ipc_mqueue.c
index f3d5d4b..80a34d3 100644
--- a/ipc/ipc_mqueue.c
+++ b/ipc/ipc_mqueue.c
@@ -374,6 +374,8 @@ ipc_mqueue_send(kmsg, option, time_out)
        }
     }

+       current_task()->messages_sent++;
+
        return MACH_MSG_SUCCESS;
 }

@@ -684,6 +686,8 @@ ipc_mqueue_receive(
        ip_unlock(port);
     }

+       current_task()->messages_received++;
+
        *kmsgp = kmsg;
        *seqnop = seqno;
        return MACH_MSG_SUCCESS;
diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c
index 5b35526..37d4eb9 100644
--- a/kern/ipc_kobject.c
+++ b/kern/ipc_kobject.c
@@ -177,15 +177,21 @@ ipc_kobject_server(request)
 #endif /* MACH_MACHINE_ROUTINES */
        ) {
            (*routine)(&request->ikm_header, &reply->ikm_header);
-       }
-       else if (!ipc_kobject_notify(&request->ikm_header,&reply->ikm_header)){
+           kernel_task->messages_received++;
+       } else {
+           if (!ipc_kobject_notify(&request->ikm_header,
+               &reply->ikm_header)) {
                ((mig_reply_header_t *) &reply->ikm_header)->RetCode
                    = MIG_BAD_ID;
 #if    MACH_IPC_TEST
                printf("ipc_kobject_server: bogus kernel message, id=%d\n",
                       request->ikm_header.msgh_id);
 #endif /* MACH_IPC_TEST */
+           } else {
+               kernel_task->messages_received++;
+           }
        }
+       kernel_task->messages_sent++;
     }
        check_simple_locks();

diff --git a/kern/task.c b/kern/task.c
index 2624dd9..114dd31 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -108,6 +108,13 @@ kern_return_t task_create(
        new_task->active = TRUE;
        new_task->user_stop_count = 0;
        new_task->thread_count = 0;
+       new_task->faults = 0;
+       new_task->zero_fills = 0;
+       new_task->reactivations = 0;
+       new_task->pageins = 0;
+       new_task->cow_faults = 0;
+       new_task->messages_sent = 0;
+       new_task->messages_received = 0;

        eml_task_reference(new_task, parent_task);

@@ -747,6 +754,30 @@ kern_return_t task_info(
                break;
            }

+           case TASK_EVENTS_INFO:
+           {
+               register task_events_info_t     event_info;
+
+               if (*task_info_count < TASK_EVENTS_INFO_COUNT) {
+                   return KERN_INVALID_ARGUMENT;
+               }
+
+               event_info = (task_events_info_t) task_info_out;
+
+               task_lock(&task);
+               event_info->faults = task->faults;
+               event_info->zero_fills = task->zero_fills;
+               event_info->reactivations = task->reactivations;
+               event_info->pageins = task->pageins;
+               event_info->cow_faults = task->cow_faults;
+               event_info->messages_sent = task->messages_sent;
+               event_info->messages_received = task->messages_received;
+               task_unlock(&task);
+
+               *task_info_count = TASK_EVENTS_INFO_COUNT;
+               break;
+           }
+
            case TASK_THREAD_TIMES_INFO:
            {
                register task_thread_times_info_t times_info;
diff --git a/kern/task.h b/kern/task.h
index c425158..9bfea57 100644
--- a/kern/task.h
+++ b/kern/task.h
@@ -102,6 +102,15 @@ struct task {

        /* Hardware specific data.  */
        machine_task_t  machine;
+
+       /* Statistics */
+       natural_t       faults;         /* page faults counter */
+       natural_t       zero_fills;     /* zero fill pages counter */
+       natural_t       reactivations;  /* reactivated pages counter */
+       natural_t       pageins;        /* actual pageins couter */
+       natural_t       cow_faults;     /* copy-on-write faults counter */
+       natural_t       messages_sent;  /* messages sent counter */
+       natural_t       messages_received; /* messages received counter */
 };

 #define task_lock(task)                simple_lock(&(task)->lock)
diff --git a/vm/vm_fault.c b/vm/vm_fault.c
index 178f307..fe5b488 100644
--- a/vm/vm_fault.c
+++ b/vm/vm_fault.c
@@ -254,6 +254,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,

        vm_stat_sample(SAMPLED_PC_VM_FAULTS_ANY);
        vm_stat.faults++;               /* needs lock XXX */
+       current_task()->faults++;

 /*
  *     Recovery actions
@@ -471,6 +472,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,
                                        
vm_stat_sample(SAMPLED_PC_VM_ZFILL_FAULTS);

                                        vm_stat.zero_fill_count++;
+                                       current_task()->zero_fills;
                                        vm_object_lock(object);
                                        pmap_clear_modify(m->phys_addr);
                                        break;
@@ -552,6 +554,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,
                                if (m->inactive)  {
                                        
vm_stat_sample(SAMPLED_PC_VM_REACTIVATION_FAULTS);
                                        vm_stat.reactivations++;
+                                       current_task()->reactivations++;
                                }

                                VM_PAGE_QUEUES_REMOVE(m);
@@ -651,6 +654,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,

                        vm_stat.pageins++;
                        vm_stat_sample(SAMPLED_PC_VM_PAGEIN_FAULTS);
+                       current_task()->pageins++;

                        if ((rc = memory_object_data_request(object->pager,
                                object->pager_request,
@@ -740,6 +744,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,
                        vm_page_zero_fill(m);
                        vm_stat_sample(SAMPLED_PC_VM_ZFILL_FAULTS);
                        vm_stat.zero_fill_count++;
+                       current_task()->zero_fills;
                        vm_object_lock(object);
                        pmap_clear_modify(m->phys_addr);
                        break;
@@ -855,6 +860,7 @@ vm_fault_return_t vm_fault_page(first_object, first_offset,

                        vm_stat.cow_faults++;
                        vm_stat_sample(SAMPLED_PC_VM_COW_FAULTS);
+                       current_task()->cow_faults;
                        object = first_object;
                        offset = first_offset;

@@ -1638,6 +1644,7 @@ kern_return_t vm_fault_wire_fast(map, va, entry)
        vm_prot_t               prot;

        vm_stat.faults++;               /* needs lock XXX */
+       current_task()->faults++;
 /*
  *     Recovery actions
  */
diff --git a/vm/vm_pageout.c b/vm/vm_pageout.c
index 77c1cfe..661675f 100644
--- a/vm/vm_pageout.c
+++ b/vm/vm_pageout.c
@@ -764,6 +764,7 @@ void vm_pageout_scan()
                        vm_object_unlock(object);
                        vm_page_activate(m);
                        vm_stat.reactivations++;
+                       current_task()->reactivations++;
                        vm_page_unlock_queues();
                        vm_pageout_inactive_used++;
                        continue;
-- 
1.7.10.4

Attachment: 002-task-events-info.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]