* Kernel instrumentation
@ 2010-01-27 12:01 John Dallaway
2010-01-29 15:08 ` John Dallaway
0 siblings, 1 reply; 2+ messages in thread
From: John Dallaway @ 2010-01-27 12:01 UTC (permalink / raw)
To: eCos Patches List
[-- Attachment #1: Type: text/plain, Size: 148 bytes --]
This patch adds instrumentation for event flags and the bitmap
scheduler, as for the other kernel objects. Comments?
John Dallaway
eCos maintainer
[-- Attachment #2: instr-100127.patch --]
[-- Type: text/x-patch, Size: 17447 bytes --]
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.153
diff -U5 -r1.153 ChangeLog
--- ChangeLog 4 Oct 2009 12:48:57 -0000 1.153
+++ ChangeLog 27 Jan 2010 11:07:43 -0000
@@ -1,5 +1,14 @@
+2010-01-27 John Dallaway <john@dallaway.org.uk>
+
+ * include/instrmnt.h: Add instrumentation macros for event flags and
+ the bitmap scheduler.
+ * include/instrument_desc.h: Regenerate.
+ * src/sync/flag.cxx, src/sched/bitmap.cxx: Add instrumentation.
+ * cdl/instrument.cdl: Add CYGDBG_KERNEL_INSTRUMENT_FLAG and
+ CYGDBG_KERNEL_INSTRUMENT_BITMAP options.
+
2009-10-04 John Dallaway <john@dallaway.org.uk>
* cdl/instrument.cdl: Add CYGDBG_KERNEL_INSTRUMENT_MLQ option. Issue
reported by Pieter-Jan Busschaert.
@@ -4754,11 +4763,11 @@
//===========================================================================
// ####GPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009, 2010 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 or (at your option) any
// later version.
Index: cdl/instrument.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/cdl/instrument.cdl,v
retrieving revision 1.8
diff -U5 -r1.8 instrument.cdl
--- cdl/instrument.cdl 4 Oct 2009 12:48:57 -0000 1.8
+++ cdl/instrument.cdl 27 Jan 2010 11:07:43 -0000
@@ -6,11 +6,11 @@
#
# ====================================================================
## ####ECOSGPLCOPYRIGHTBEGIN####
## -------------------------------------------
## This file is part of eCos, the Embedded Configurable Operating System.
-## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009 Free Software Foundation, Inc.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2009, 2010 Free Software Foundation, Inc.
##
## eCos is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation; either version 2 or (at your option) any later
## version.
@@ -204,10 +204,23 @@
reducing the code size overheads. This option controls
whether or not instrumentation support is compiled into
the message box code."
}
+cdl_option CYGDBG_KERNEL_INSTRUMENT_FLAG {
+ display "Instrument event flag operations"
+ default_value 1
+ active_if CYGPKG_KERNEL_SYNCH
+ description "
+ It is possible to perform selective instrumentation at
+ run-time. It is also possible to disable instrumentation
+ in various kernel components at compile-time, thus
+ reducing the code size overheads. This option controls
+ whether or not instrumentation support is compiled into
+ the event flag code."
+}
+
cdl_option CYGDBG_KERNEL_INSTRUMENT_CLOCK {
display "Instrument clock operations"
default_value 1
active_if CYGVAR_KERNEL_COUNTERS_CLOCK
description "
@@ -256,10 +269,23 @@
reducing the code size overheads. This option controls
whether or not instrumentation support is compiled into
the code for the multi-level queue scheduler."
}
+cdl_option CYGDBG_KERNEL_INSTRUMENT_BITMAP {
+ display "Instrument bitmap scheduler operations"
+ default_value 1
+ active_if CYGSEM_KERNEL_SCHED_BITMAP
+ description "
+ It is possible to perform selective instrumentation at
+ run-time. It is also possible to disable instrumentation
+ in various kernel components at compile-time, thus
+ reducing the code size overheads. This option controls
+ whether or not instrumentation support is compiled into
+ the code for the bitmap scheduler."
+}
+
cdl_option CYGDBG_KERNEL_INSTRUMENT_USER {
display "Support application-level instrumentation"
default_value 1
description "
It is possible to perform selective instrumentation at
Index: include/instrmnt.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/include/instrmnt.h,v
retrieving revision 1.13
diff -U5 -r1.13 instrmnt.h
--- include/instrmnt.h 29 Jan 2009 17:49:50 -0000 1.13
+++ include/instrmnt.h 27 Jan 2010 11:07:44 -0000
@@ -9,11 +9,11 @@
//
//==========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
@@ -118,10 +118,12 @@
#define CYG_INSTRUMENT_CLASS_CLOCK 0x0800
#define CYG_INSTRUMENT_CLASS_ALARM 0x0900
#define CYG_INSTRUMENT_CLASS_MBOXT 0x0a00
#define CYG_INSTRUMENT_CLASS_SMP 0x0b00
#define CYG_INSTRUMENT_CLASS_MLQ 0x0c00
+#define CYG_INSTRUMENT_CLASS_FLAG 0x0d00
+#define CYG_INSTRUMENT_CLASS_BITMAP 0x0e00
#define CYG_INSTRUMENT_CLASS_USER 0x0f00
#define CYG_INSTRUMENT_CLASS_MAX CYG_INSTRUMENT_CLASS_USER
@@ -242,10 +244,28 @@
#define CYG_INSTRUMENT_EVENT_MLQ_YIELD 6
#define CYG_INSTRUMENT_EVENT_MLQ_ENQUEUE 7
#define CYG_INSTRUMENT_EVENT_MLQ_DEQUEUE 8
#define CYG_INSTRUMENT_EVENT_MLQ_REMOVE 9
+// Flag events
+
+#define CYG_INSTRUMENT_EVENT_FLAG_WAIT 1
+#define CYG_INSTRUMENT_EVENT_FLAG_WOKE 2
+#define CYG_INSTRUMENT_EVENT_FLAG_SETBITS 3
+#define CYG_INSTRUMENT_EVENT_FLAG_MASKBITS 4
+#define CYG_INSTRUMENT_EVENT_FLAG_TIMEOUT 5
+#define CYG_INSTRUMENT_EVENT_FLAG_WAKE 6
+#define CYG_INSTRUMENT_EVENT_FLAG_POLL 7
+
+// Bitmap scheduler events
+
+#define CYG_INSTRUMENT_EVENT_BITMAP_SCHEDULE 1
+#define CYG_INSTRUMENT_EVENT_BITMAP_ADD 2
+#define CYG_INSTRUMENT_EVENT_BITMAP_REM 3
+#define CYG_INSTRUMENT_EVENT_BITMAP_ENQUEUE 4
+#define CYG_INSTRUMENT_EVENT_BITMAP_DEQUEUE 5
+#define CYG_INSTRUMENT_EVENT_BITMAP_REMOVE 6
// User events
#define CYG_INSTRUMENT_EVENT_USER_1 1
#define CYG_INSTRUMENT_EVENT_USER_2 2
@@ -443,10 +463,38 @@
#define CYG_INSTRUMENT_MLQ(_event_,_arg1_,_arg2_)
#endif
// -------------------------------------------------------------------------
+// Flag instrumentation
+
+#ifdef CYGDBG_KERNEL_INSTRUMENT_FLAG
+
+#define CYG_INSTRUMENT_FLAG(_event_,_arg1_,_arg2_) \
+ CYG_INSTRUMENT(CYGINST_EVENT(FLAG,_event_),_arg1_,_arg2_)
+
+#else
+
+#define CYG_INSTRUMENT_FLAG(_event_,_arg1_,_arg2_)
+
+#endif
+
+// -------------------------------------------------------------------------
+// Bitmap instrumentation
+
+#ifdef CYGDBG_KERNEL_INSTRUMENT_BITMAP
+
+#define CYG_INSTRUMENT_BITMAP(_event_,_arg1_,_arg2_) \
+ CYG_INSTRUMENT(CYGINST_EVENT(BITMAP,_event_),_arg1_,_arg2_)
+
+#else
+
+#define CYG_INSTRUMENT_BITMAP(_event_,_arg1_,_arg2_)
+
+#endif
+
+// -------------------------------------------------------------------------
// User instrumentation
#ifdef CYGDBG_KERNEL_INSTRUMENT_USER
#define CYG_INSTRUMENT_USER(_event_,_arg1_,_arg2_) \
Index: include/instrument_desc.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/include/instrument_desc.h,v
retrieving revision 1.2
diff -U5 -r1.2 instrument_desc.h
--- include/instrument_desc.h 12 Dec 2002 18:31:44 -0000 1.2
+++ include/instrument_desc.h 27 Jan 2010 11:07:44 -0000
@@ -17,14 +17,22 @@
{"ALARM_REM", 2},
{"ALARM_TRIGGER", 5},
{"BINSEM", 0x0600},
{"BINSEM_CLAIM", 1},
{"BINSEM_POST", 5},
+{"BINSEM_TIMEOUT", 7},
{"BINSEM_TRY", 4},
{"BINSEM_WAIT", 2},
{"BINSEM_WAKE", 6},
{"BINSEM_WOKE", 3},
+{"BITMAP", 0x0e00},
+{"BITMAP_ADD", 2},
+{"BITMAP_DEQUEUE", 5},
+{"BITMAP_ENQUEUE", 4},
+{"BITMAP_REM", 3},
+{"BITMAP_REMOVE", 6},
+{"BITMAP_SCHEDULE", 1},
{"CLOCK", 0x0800},
{"CLOCK_ISR", 3},
{"CLOCK_TICK_END", 2},
{"CLOCK_TICK_START", 1},
{"CNTSEM", 0x0700},
@@ -40,10 +48,18 @@
{"CONDVAR_SIGNAL", 3},
{"CONDVAR_TIMED_WAIT", 6},
{"CONDVAR_WAIT", 1},
{"CONDVAR_WAKE", 4},
{"CONDVAR_WOKE", 2},
+{"FLAG", 0x0d00},
+{"FLAG_MASKBITS", 4},
+{"FLAG_POLL", 7},
+{"FLAG_SETBITS", 3},
+{"FLAG_TIMEOUT", 5},
+{"FLAG_WAIT", 1},
+{"FLAG_WAKE", 6},
+{"FLAG_WOKE", 2},
{"INTR", 0x0300},
{"INTR_ACK", 14},
{"INTR_ATTACH", 6},
{"INTR_CALL_DSR", 5},
{"INTR_CHAIN_ISR", 15},
Index: src/sched/bitmap.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/src/sched/bitmap.cxx,v
retrieving revision 1.11
diff -U5 -r1.11 bitmap.cxx
--- src/sched/bitmap.cxx 29 Jan 2009 17:49:50 -0000 1.11
+++ src/sched/bitmap.cxx 27 Jan 2010 11:07:44 -0000
@@ -6,11 +6,11 @@
//
//==========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
@@ -97,19 +97,23 @@
CYG_ASSERT(run_queue != 0, "Run queue empty");
cyg_uint32 index;
HAL_LSBIT_INDEX(index, run_queue);
+
+ CYG_INSTRUMENT_BITMAP(SCHEDULE, thread_table[index], index);
return thread_table[index];
}
// -------------------------------------------------------------------------
void Cyg_Scheduler_Implementation::add_thread(Cyg_Thread *thread)
{
CYG_REPORT_FUNCTION();
+
+ CYG_INSTRUMENT_BITMAP(ADD, thread, thread->priority);
CYG_ASSERT((CYG_THREAD_MIN_PRIORITY >= thread->priority)
&& (CYG_THREAD_MAX_PRIORITY <= thread->priority),
"Priority out of range!");
@@ -140,10 +144,12 @@
// -------------------------------------------------------------------------
void Cyg_Scheduler_Implementation::rem_thread(Cyg_Thread *thread)
{
CYG_REPORT_FUNCTION();
+
+ CYG_INSTRUMENT_BITMAP(REM, thread, thread->priority);
CYG_ASSERT( thread_table[thread->priority] == thread,
"Invalid thread priority" );
CYG_ASSERT( (run_queue & (1<<thread->priority)) != 0,
@@ -255,10 +261,12 @@
void Cyg_ThreadQueue_Implementation::enqueue(Cyg_Thread *thread)
{
CYG_REPORT_FUNCTION();
+
+ CYG_INSTRUMENT_BITMAP(ENQUEUE, this, thread);
wait_queue |= 1<<thread->priority;
thread->queue = CYG_CLASSFROMBASE(Cyg_ThreadQueue,
Cyg_ThreadQueue_Implementation,
this);
@@ -271,20 +279,26 @@
CYG_REPORT_FUNCTION();
// Isolate ls bit in run_queue.
cyg_sched_bitmap next_thread = wait_queue & -wait_queue;
- if( next_thread == 0 ) return NULL;
+ if( next_thread == 0 )
+ {
+ CYG_INSTRUMENT_BITMAP(DEQUEUE, this, NULL);
+ return NULL;
+ }
wait_queue &= ~next_thread;
cyg_uint32 index;
HAL_LSBIT_INDEX(index, next_thread);
Cyg_Thread *thread = Cyg_Scheduler::scheduler.thread_table[index];
+ CYG_INSTRUMENT_BITMAP(DEQUEUE, this, thread);
+
thread->queue = NULL;
return thread;
}
@@ -309,10 +323,12 @@
// -------------------------------------------------------------------------
void Cyg_ThreadQueue_Implementation::remove(Cyg_Thread *thread)
{
CYG_REPORT_FUNCTION();
+
+ CYG_INSTRUMENT_BITMAP(REMOVE, this, thread);
wait_queue &= ~(1<<thread->priority);
thread->queue = NULL;
}
Index: src/sync/flag.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/src/sync/flag.cxx,v
retrieving revision 1.8
diff -U5 -r1.8 flag.cxx
--- src/sync/flag.cxx 29 Jan 2009 17:49:50 -0000 1.8
+++ src/sync/flag.cxx 27 Jan 2010 11:07:44 -0000
@@ -6,11 +6,11 @@
//
//==========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2010 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
@@ -135,10 +135,13 @@
// Prevent preemption
Cyg_Scheduler::lock();
value &= arg;
+
+ CYG_INSTRUMENT_FLAG(MASKBITS, this, value);
+
// no need to wake anyone up; no waiter can become valid in
// consequence of this operation.
// Unlock scheduler and allow other threads to run
Cyg_Scheduler::unlock();
@@ -162,10 +165,12 @@
Cyg_Scheduler::lock();
// OR in the argument to get a new flag value.
value |= arg;
+ CYG_INSTRUMENT_FLAG(SETBITS, this, value);
+
// anyone waiting?
if ( !(queue.empty()) ) {
FlagWaitInfo *p;
Cyg_Thread *thread;
Cyg_ThreadQueue holding;
@@ -181,10 +186,13 @@
if ( ((p->allmask != 0) && (p->allmask & value) == p->allmask) ||
((p->anymask & value) != 0 ) ) {
// success! awaken the thread
thread->set_wake_reason( Cyg_Thread::DONE );
thread->wake();
+
+ CYG_INSTRUMENT_FLAG(WAKE, this, thread);
+
// return the successful value to it
p->value_out = value;
// do we clear the value; is this the end?
if ( p->do_clear ) {
// we can break here but need to preserve ordering
@@ -248,13 +256,17 @@
self->set_sleep_reason( Cyg_Thread::WAIT );
self->sleep();
// keep track of myself on the queue of waiting threads
queue.enqueue( self );
+ CYG_INSTRUMENT_FLAG(WAIT, this, value);
+
// Allow other threads to run
Cyg_Scheduler::reschedule();
+ CYG_INSTRUMENT_FLAG(WOKE, this, value);
+
CYG_ASSERT( ((CYG_ADDRWORD)&saveme) ==
Cyg_Thread::self()->get_wait_info(),
"Wait info lost" );
switch( self->get_wake_reason() )
@@ -335,20 +347,25 @@
self->set_sleep_reason( Cyg_Thread::TIMEOUT );
self->sleep();
// keep track of myself on the queue of waiting threads
queue.enqueue( self );
+ CYG_INSTRUMENT_FLAG(WAIT, this, value);
+
// Allow other threads to run
Cyg_Scheduler::reschedule();
+ CYG_INSTRUMENT_FLAG(WOKE, this, value);
+
CYG_ASSERT( ((CYG_ADDRWORD)&saveme) ==
Cyg_Thread::self()->get_wait_info(),
"Wait info lost" );
switch( self->get_wake_reason() )
{
case Cyg_Thread::TIMEOUT:
+ CYG_INSTRUMENT_FLAG(TIMEOUT, this, value);
result = false;
break;
case Cyg_Thread::DESTRUCT:
case Cyg_Thread::BREAK:
@@ -404,10 +421,12 @@
// result != 0 <=> test passed
if ( result && (Cyg_Flag::CLR & mode) )
value = 0;
+ CYG_INSTRUMENT_FLAG(POLL, this, result);
+
Cyg_Scheduler::unlock();
CYG_REPORT_RETVAL( result );
return result;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Kernel instrumentation
2010-01-27 12:01 Kernel instrumentation John Dallaway
@ 2010-01-29 15:08 ` John Dallaway
0 siblings, 0 replies; 2+ messages in thread
From: John Dallaway @ 2010-01-29 15:08 UTC (permalink / raw)
To: eCos Patches List
John Dallaway wrote:
> This patch adds instrumentation for event flags and the bitmap
> scheduler, as for the other kernel objects. Comments?
Now checked-in.
John Dallaway
eCos maintainer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-29 15:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-27 12:01 Kernel instrumentation John Dallaway
2010-01-29 15:08 ` John Dallaway
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).