EPOCH(9): Avoid inline functions

FreeBSD changed the epoch_enter() and epoch_exit() inline functions into
proper functions after a performance analysis to avoid code bloat.
This commit is contained in:
Sebastian Huber 2019-07-09 13:24:38 +02:00
parent 660a8835eb
commit ed1a63384b
2 changed files with 35 additions and 27 deletions

View File

@ -36,7 +36,6 @@
#include <sys/lock.h> #include <sys/lock.h>
#include <sys/pcpu.h> #include <sys/pcpu.h>
#include <rtems/score/percpudata.h> #include <rtems/score/percpudata.h>
#include <rtems/score/threaddispatch.h>
#endif #endif
#include <rtems/thread.h> #include <rtems/thread.h>
#include <ck_epoch.h> #include <ck_epoch.h>
@ -100,7 +99,10 @@ SYSINIT(epoch_##name, SI_SUB_TUNABLES, SI_ORDER_THIRD, \
void _bsd_epoch_init(epoch_t epoch, uintptr_t pcpu_record_offset, void _bsd_epoch_init(epoch_t epoch, uintptr_t pcpu_record_offset,
int flags); int flags);
void epoch_enter(epoch_t epoch);
void epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et); void epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et);
void epoch_exit(epoch_t epoch);
void epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et); void epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et);
void epoch_wait(epoch_t epoch); void epoch_wait(epoch_t epoch);
@ -113,30 +115,5 @@ int _bsd_in_epoch(epoch_t epoch);
#define in_epoch(epoch) _bsd_in_epoch(epoch) #define in_epoch(epoch) _bsd_in_epoch(epoch)
#define in_epoch_verbose(epoch, dump_onfail) _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( \
cpu_self, struct epoch_record, epoch->e_pcpu_record_offset)
static __inline void
epoch_enter(epoch_t epoch)
{
Per_CPU_Control *cpu_self;
struct epoch_record *er;
cpu_self = _Thread_Dispatch_disable();
er = EPOCH_GET_RECORD(cpu_self, epoch);
ck_epoch_begin(&er->er_record, NULL);
}
static __inline void
epoch_exit(epoch_t epoch)
{
Per_CPU_Control *cpu_self;
struct epoch_record *er;
cpu_self = _Per_CPU_Get();
er = EPOCH_GET_RECORD(cpu_self, epoch);
ck_epoch_end(&er->er_record, NULL);
_Thread_Dispatch_enable(cpu_self);
}
#endif /* _KERNEL */ #endif /* _KERNEL */
#endif /* _SYS_EPOCH_H_ */ #endif /* _SYS_EPOCH_H_ */

View File

@ -42,9 +42,13 @@
#include <rtems.h> #include <rtems.h>
#include <rtems/irq-extension.h> #include <rtems/irq-extension.h>
#include <rtems/score/smpimpl.h> #include <rtems/score/smpimpl.h>
#include <rtems/score/threaddispatch.h>
#include <rtems/score/threadimpl.h> #include <rtems/score/threadimpl.h>
#include <rtems/score/watchdogimpl.h> #include <rtems/score/watchdogimpl.h>
#define EPOCH_GET_RECORD(cpu_self, epoch) PER_CPU_DATA_GET_BY_OFFSET( \
cpu_self, struct epoch_record, epoch->e_pcpu_record_offset)
EPOCH_DEFINE(_bsd_global_epoch_preempt, EPOCH_PREEMPT); EPOCH_DEFINE(_bsd_global_epoch_preempt, EPOCH_PREEMPT);
EPOCH_DEFINE(_bsd_global_epoch, 0); EPOCH_DEFINE(_bsd_global_epoch, 0);
@ -175,6 +179,29 @@ epoch_sysinit(void)
} }
SYSINIT(epoch, SI_SUB_TUNABLES, SI_ORDER_SECOND, epoch_sysinit, NULL); SYSINIT(epoch, SI_SUB_TUNABLES, SI_ORDER_SECOND, epoch_sysinit, NULL);
void
epoch_enter(epoch_t epoch)
{
Per_CPU_Control *cpu_self;
struct epoch_record *er;
cpu_self = _Thread_Dispatch_disable();
er = EPOCH_GET_RECORD(cpu_self, epoch);
ck_epoch_begin(&er->er_record, NULL);
}
void
epoch_exit(epoch_t epoch)
{
Per_CPU_Control *cpu_self;
struct epoch_record *er;
cpu_self = _Per_CPU_Get();
er = EPOCH_GET_RECORD(cpu_self, epoch);
ck_epoch_end(&er->er_record, NULL);
_Thread_Dispatch_enable(cpu_self);
}
void void
epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et) epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
{ {
@ -266,12 +293,16 @@ epoch_block_handler_preempt(struct ck_epoch *g __unused,
{ {
struct epoch_record *er; struct epoch_record *er;
Per_CPU_Control *cpu_self; Per_CPU_Control *cpu_self;
uint32_t cpu_self_index;
struct epoch_tracker_mutex etm; struct epoch_tracker_mutex etm;
#ifdef RTEMS_SMP
uint32_t cpu_self_index;
#endif
er = __containerof(cr, struct epoch_record, er_record); er = __containerof(cr, struct epoch_record, er_record);
cpu_self = _Per_CPU_Get(); cpu_self = _Per_CPU_Get();
#ifdef RTEMS_SMP
cpu_self_index = _Per_CPU_Get_index(cpu_self); cpu_self_index = _Per_CPU_Get_index(cpu_self);
#endif
rtems_mutex_init(&etm.etm_mtx, "epoch"); rtems_mutex_init(&etm.etm_mtx, "epoch");
etm.etm_record = er; etm.etm_record = er;