introduce option to time assert()s
. remove a few asserts in the kernel and 64bi library that are not compatible with the timing code . change the TIME_BLOCKS code a little to work in-kernel
This commit is contained in:
parent
aba3746220
commit
e785381d4d
4 changed files with 16 additions and 25 deletions
|
@ -64,12 +64,11 @@ _PROTOTYPE( clock_t tmrs_settimer, (timer_t **tmrs, timer_t *tp,
|
||||||
clock_t exp_time, tmr_func_t watchdog, clock_t *new_head) );
|
clock_t exp_time, tmr_func_t watchdog, clock_t *new_head) );
|
||||||
|
|
||||||
#define PRINT_STATS(cum_spenttime, cum_instances) { \
|
#define PRINT_STATS(cum_spenttime, cum_instances) { \
|
||||||
if(ex64hi(cum_spenttime)) { printf(" ???\n"); } \
|
if(ex64hi(cum_spenttime)) { util_stacktrace(); printf(" ( ??? %lu %lu)\n", \
|
||||||
printf("%s:%d,%lu,%lu,%lu,%d.%04d%%\n", \
|
ex64hi(cum_spenttime), ex64lo(cum_spenttime)); } \
|
||||||
__FILE__, __LINE__, cum_instances, \
|
printf("%s:%d,%lu,%lu\n", \
|
||||||
div64u(cum_spenttime, cum_instances), \
|
__FILE__, __LINE__, cum_instances, \
|
||||||
ex64lo(cum_spenttime), \
|
ex64lo(cum_spenttime)); \
|
||||||
perc/10000, perc%10000); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RESET_STATS(starttime, cum_instances, cum_spenttime, cum_starttime) { \
|
#define RESET_STATS(starttime, cum_instances, cum_spenttime, cum_starttime) { \
|
||||||
|
@ -83,7 +82,6 @@ _PROTOTYPE( clock_t tmrs_settimer, (timer_t **tmrs, timer_t *tp,
|
||||||
static int _cum_instances; \
|
static int _cum_instances; \
|
||||||
u64_t _next_cum_spent, _starttime, _endtime, _dt, _cum_dt; \
|
u64_t _next_cum_spent, _starttime, _endtime, _dt, _cum_dt; \
|
||||||
u32_t _dt_micros; \
|
u32_t _dt_micros; \
|
||||||
int perc; \
|
|
||||||
read_tsc_64(&_starttime); \
|
read_tsc_64(&_starttime); \
|
||||||
do { timed_code_block } while(0); \
|
do { timed_code_block } while(0); \
|
||||||
read_tsc_64(&_endtime); \
|
read_tsc_64(&_endtime); \
|
||||||
|
@ -99,7 +97,6 @@ _PROTOTYPE( clock_t tmrs_settimer, (timer_t **tmrs, timer_t *tp,
|
||||||
_cum_spenttime = add64(_cum_spenttime, _dt); \
|
_cum_spenttime = add64(_cum_spenttime, _dt); \
|
||||||
_cum_instances++; \
|
_cum_instances++; \
|
||||||
_cum_dt = sub64(_endtime, _cum_starttime); \
|
_cum_dt = sub64(_endtime, _cum_starttime); \
|
||||||
perc=ex64lo(div64(mul64(_cum_spenttime,make64(1000000,0)), _cum_dt)); \
|
|
||||||
if(cmp64(_cum_dt, make64(0, 120)) > 0) { \
|
if(cmp64(_cum_dt, make64(0, 120)) > 0) { \
|
||||||
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
PRINT_STATS(_cum_spenttime, _cum_instances); \
|
||||||
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \
|
||||||
|
|
|
@ -19,6 +19,12 @@
|
||||||
#include <minix/ansi.h>
|
#include <minix/ansi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TIME_ASSERTS
|
||||||
|
#define _ASSERT_EVALUATE(st) do { TIME_BLOCK(st); } while(0)
|
||||||
|
#else
|
||||||
|
#define _ASSERT_EVALUATE(st) do { st } while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
/* Debugging disabled -- do not evaluate assertions. */
|
/* Debugging disabled -- do not evaluate assertions. */
|
||||||
#define assert(expr) ((void) 0)
|
#define assert(expr) ((void) 0)
|
||||||
|
@ -29,10 +35,11 @@
|
||||||
#define __xstr(x) __makestr(x)
|
#define __xstr(x) __makestr(x)
|
||||||
|
|
||||||
_PROTOTYPE( void __bad_assertion, (const char *_mess) );
|
_PROTOTYPE( void __bad_assertion, (const char *_mess) );
|
||||||
#define assert(expr) ((expr)? (void)0 : \
|
#define assert(expr) do { int _av; \
|
||||||
__bad_assertion("Assertion \"" #expr \
|
_ASSERT_EVALUATE(_av = !!(expr);); \
|
||||||
"\" failed, file " __xstr(__FILE__) \
|
if(!_av) { \
|
||||||
", line " __xstr(__LINE__) "\n"))
|
__bad_assertion("Assertion \"" #expr "\" failed, file " __xstr(__FILE__) ", line " __xstr(__LINE__) "\n"); \
|
||||||
|
} } while(0)
|
||||||
#else
|
#else
|
||||||
#define assert(expr) ((void) ((expr) ? 0 : __assert( __FILE__, __LINE__)))
|
#define assert(expr) ((void) ((expr) ? 0 : __assert( __FILE__, __LINE__)))
|
||||||
#endif /* _ANSI */
|
#endif /* _ANSI */
|
||||||
|
|
|
@ -24,8 +24,6 @@ PRIVATE void pagefault( struct proc *pr,
|
||||||
message m_pagefault;
|
message m_pagefault;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
assert(frame);
|
|
||||||
|
|
||||||
pagefaultcr2 = read_cr2();
|
pagefaultcr2 = read_cr2();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -33,10 +31,6 @@ PRIVATE void pagefault( struct proc *pr,
|
||||||
pr->p_endpoint, pagefaultcr2, pr->p_seg.p_cr3, read_cr3());
|
pr->p_endpoint, pagefaultcr2, pr->p_seg.p_cr3, read_cr3());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(pr->p_seg.p_cr3) {
|
|
||||||
assert(pr->p_seg.p_cr3 == read_cr3());
|
|
||||||
}
|
|
||||||
|
|
||||||
in_physcopy = (frame->eip > (vir_bytes) phys_copy) &&
|
in_physcopy = (frame->eip > (vir_bytes) phys_copy) &&
|
||||||
(frame->eip < (vir_bytes) phys_copy_fault);
|
(frame->eip < (vir_bytes) phys_copy_fault);
|
||||||
|
|
||||||
|
@ -81,8 +75,6 @@ PRIVATE void pagefault( struct proc *pr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't schedule this process until pagefault is handled. */
|
/* Don't schedule this process until pagefault is handled. */
|
||||||
assert(pr->p_seg.p_cr3 == read_cr3());
|
|
||||||
assert(!RTS_ISSET(pr, RTS_PAGEFAULT));
|
|
||||||
RTS_SET(pr, RTS_PAGEFAULT);
|
RTS_SET(pr, RTS_PAGEFAULT);
|
||||||
|
|
||||||
/* tell Vm about the pagefault */
|
/* tell Vm about the pagefault */
|
||||||
|
|
|
@ -26,11 +26,6 @@ static u64_t divrem64(u64_t *i, u64_t j)
|
||||||
u64_t result = { 0, 0 };
|
u64_t result = { 0, 0 };
|
||||||
unsigned shift;
|
unsigned shift;
|
||||||
|
|
||||||
assert(i);
|
|
||||||
|
|
||||||
/* this function is not suitable for small divisors */
|
|
||||||
assert(ex64hi(j) != 0);
|
|
||||||
|
|
||||||
/* as long as i >= j we work on reducing i */
|
/* as long as i >= j we work on reducing i */
|
||||||
while (cmp64(*i, j) >= 0) {
|
while (cmp64(*i, j) >= 0) {
|
||||||
/* shift to obtain the 32 most significant bits */
|
/* shift to obtain the 32 most significant bits */
|
||||||
|
|
Loading…
Reference in a new issue