Fix INVARIANTS support

This commit is contained in:
Sebastian Huber 2019-01-15 15:35:11 +01:00
parent 1354d9bf97
commit 34cb55db70
2 changed files with 35 additions and 2 deletions

View File

@ -109,8 +109,9 @@ void epoch_wait_preempt(epoch_t epoch);
void epoch_call(epoch_t epoch, epoch_context_t ctx, void epoch_call(epoch_t epoch, epoch_context_t ctx,
void (*callback) (epoch_context_t)); void (*callback) (epoch_context_t));
int in_epoch(epoch_t epoch); int _bsd_in_epoch(epoch_t epoch);
int in_epoch_verbose(epoch_t epoch, int dump_onfail); #define in_epoch(epoch) _bsd_in_epoch(epoch)
#define in_epoch_verbose(epoch, dump_onfail) _bsd_in_epoch(epoch)
#define EPOCH_GET_RECORD(cpu_self, epoch) PER_CPU_DATA_GET_BY_OFFSET( \ #define EPOCH_GET_RECORD(cpu_self, epoch) PER_CPU_DATA_GET_BY_OFFSET( \
cpu_self, struct epoch_record, epoch->e_pcpu_record_offset) cpu_self, struct epoch_record, epoch->e_pcpu_record_offset)

View File

@ -33,6 +33,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/kernel.h> #include <sys/kernel.h>
#include <sys/epoch.h> #include <sys/epoch.h>
#ifdef INVARIANTS
#include <sys/systm.h>
#endif
#include <machine/cpu.h> #include <machine/cpu.h>
@ -322,3 +325,32 @@ epoch_call(epoch_t epoch, epoch_context_t ctx,
ck_epoch_call(&er->er_record, ctx, callback); ck_epoch_call(&er->er_record, ctx, callback);
_Thread_Dispatch_enable(cpu_self); _Thread_Dispatch_enable(cpu_self);
} }
#ifdef INVARIANTS
int
_bsd_in_epoch(epoch_t epoch)
{
Per_CPU_Control *cpu_self;
Thread_Control *executing;
struct epoch_record *er;
struct epoch_pcpu *epcpu;
struct epoch_tracker *tdwait;
int in;
in = 0;
cpu_self = _Thread_Dispatch_disable();
executing = _Per_CPU_Get_executing(cpu_self);
epcpu = PER_CPU_DATA_GET(cpu_self, struct epoch_pcpu, epoch);
er = EPOCH_GET_RECORD(cpu_self, epoch);
TAILQ_FOREACH(tdwait, &er->er_tdlist, et_link) {
if (tdwait->et_td == executing) {
in = 1;
break;
}
}
_Thread_Dispatch_enable(cpu_self);
return (in);
}
#endif