* Changed the interface of _kern_system_profiler_start(). The parameters are

passed in a structure now, so it is easier to extend it and ignore unused
  parameters.
* One can now select which system profiling events one is interested in.
* Added scheduling events to the system profiling interface. Those are pretty
  much the ones recorded when scheduler tracing is enabled. Still missing are
  the "wait object" events that allow to interpret what a thread is waiting
  for.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30243 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-04-18 17:35:28 +00:00
parent 79257a4ad6
commit 5b2f0f33f9
5 changed files with 279 additions and 61 deletions
+5 -2
View File
@@ -10,10 +10,13 @@
#include <OS.h>
struct system_profiler_parameters;
__BEGIN_DECLS
status_t _user_system_profiler_start(area_id bufferArea,
bigtime_t interval, int32 stackDepth);
status_t _user_system_profiler_start(
struct system_profiler_parameters* parameters);
status_t _user_system_profiler_next_buffer(size_t bytesRead);
status_t _user_system_profiler_stop();
+5 -4
View File
@@ -30,11 +30,12 @@ struct net_stat;
struct pollfd;
struct rlimit;
struct scheduling_analysis;
struct sigaction;
struct stat;
struct _sem_t;
struct sembuf;
union semun;
struct sigaction;
struct stat;
struct system_profiler_parameters;
struct disk_device_job_progress_info;
struct partitionable_space_data;
@@ -390,8 +391,8 @@ extern status_t _kern_set_debugger_breakpoint(void *address, uint32 type,
extern status_t _kern_clear_debugger_breakpoint(void *address,
bool watchpoint);
extern status_t _kern_system_profiler_start(area_id bufferArea,
bigtime_t interval, int32 stackDepth);
extern status_t _kern_system_profiler_start(
struct system_profiler_parameters* parameters);
extern status_t _kern_system_profiler_next_buffer(size_t bytesRead);
extern status_t _kern_system_profiler_stop();
+76 -2
View File
@@ -8,17 +8,60 @@
#include <image.h>
struct system_profiler_parameters {
// general
area_id buffer_area; // area the events will be written to
uint32 flags; // flags selecting the events to receive
// scheduling
size_t locking_lookup_size; // size of the lookup table used for
// caching the locking primitive infos
// sampling
bigtime_t interval; // interval at which to take samples
uint32 stack_depth; // maximum stack depth to sample
};
// event flags
enum {
B_SYSTEM_PROFILER_TEAM_EVENTS = 0x01,
B_SYSTEM_PROFILER_THREAD_EVENTS = 0x02,
B_SYSTEM_PROFILER_IMAGE_EVENTS = 0x04,
B_SYSTEM_PROFILER_SAMPLING_EVENTS = 0x08,
B_SYSTEM_PROFILER_SCHEDULING_EVENTS = 0x10
};
// events
enum {
B_SYSTEM_PROFILER_TEAM_ADDED = 0,
// reserved for the user application
B_SYSTEM_PROFILER_USER_EVENT = 0,
// ring buffer wrap-around marker
B_SYSTEM_PROFILER_BUFFER_END,
// team
B_SYSTEM_PROFILER_TEAM_ADDED,
B_SYSTEM_PROFILER_TEAM_REMOVED,
B_SYSTEM_PROFILER_TEAM_EXEC,
// thread
B_SYSTEM_PROFILER_THREAD_ADDED,
B_SYSTEM_PROFILER_THREAD_REMOVED,
// image
B_SYSTEM_PROFILER_IMAGE_ADDED,
B_SYSTEM_PROFILER_IMAGE_REMOVED,
// profiling samples
B_SYSTEM_PROFILER_SAMPLES,
B_SYSTEM_PROFILER_SAMPLES_END
// scheduling
B_SYSTEM_PROFILER_THREAD_SCHEDULED,
B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE,
B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE,
B_SYSTEM_PROFILER_WAIT_OBJECT_INFO
};
@@ -84,5 +127,36 @@ struct system_profiler_samples {
addr_t samples[0];
};
// B_SYSTEM_PROFILER_THREAD_SCHEDULED,
struct system_profiler_thread_scheduled {
bigtime_t time;
thread_id thread;
thread_id previous_thread;
uint16 previous_thread_state;
uint16 previous_thread_wait_object_type;
addr_t previous_thread_wait_object;
};
// B_SYSTEM_PROFILER_THREAD_ENQUEUED_IN_RUN_QUEUE,
struct system_profiler_thread_enqueued_in_run_queue {
bigtime_t time;
thread_id thread;
uint8 priority;
};
// B_SYSTEM_PROFILER_THREAD_REMOVED_FROM_RUN_QUEUE,
struct system_profiler_thread_removed_from_run_queue {
bigtime_t time;
thread_id thread;
};
// B_SYSTEM_PROFILER_WAIT_OBJECT_INFO
struct system_profiler_wait_object_info {
uint32 type;
addr_t object;
addr_t referenced_object;
char name[1];
};
#endif /* _SYSTEM_SYSTEM_PROFILER_DEFS_H */