Skip to content

Commit

Permalink
Add a comment on why inlining critical_enter() may not be a good idea
Browse files Browse the repository at this point in the history
for the general case.

Reviewed by:	bde
MFC after:	1 week
  • Loading branch information
attilio authored and attilio committed Dec 9, 2012
1 parent c2c3784 commit 3e75d99
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sys/kern/kern_switch.c
Expand Up @@ -176,6 +176,12 @@ choosethread(void)
/*
* Kernel thread preemption implementation. Critical sections mark
* regions of code in which preemptions are not allowed.
*
* It might seem a good idea to inline critical_enter() but, in order
* to prevent instructions reordering by the compiler, a __compiler_membar()
* would have to be used here (the same as sched_pin()). The performance
* penalty imposed by the membar could, then, produce slower code than
* the function call itself, for most cases.
*/
void
critical_enter(void)
Expand Down

0 comments on commit 3e75d99

Please sign in to comment.