svn commit: r335879 - in head/sys: conf kern sys
Mark Johnston
markj at freebsd.org
Sun Jul 8 14:22:25 UTC 2018
On Tue, Jul 03, 2018 at 01:55:10AM +0000, Matt Macy wrote:
> Author: mmacy
> Date: Tue Jul 3 01:55:09 2018
> New Revision: 335879
> URL: https://svnweb.freebsd.org/changeset/base/335879
>
> Log:
> make critical_{enter, exit} inline
>
> Avoid pulling in all of the <sys/proc.h> dependencies by
> automatically generating a stripped down thread_lite exporting
> only the fields of interest. The field declarations are type checked
> against the original and the offsets of the generated result is
> automatically checked.
>
> kib has expressed disagreement and would have preferred to simply
> use genassym style offsets (which loses type check enforcement).
> jhb has expressed dislike of it due to header pollution and a
> duplicate structure. He would have preferred to just have defined
> thread in _thread.h. Nonetheless, he admits that this is the only
> viable solution at the moment.
>
> The impetus for this came from mjg's D15331:
> "Inline critical_enter/exit for amd64"
>
> Reviewed by: jeff
> Differential Revision: https://reviews.freebsd.org/D16078
>
> [...]
> +#if defined(KLD_MODULE) || defined(KTR_CRITICAL) || !defined(_KERNEL) || defined(GENOFFSET)
> +#define critical_enter() critical_enter_KBI()
> +#define critical_exit() critical_exit_KBI()
> +#else
> +static __inline void
> +critical_enter(void)
> +{
> + struct thread_lite *td;
> +
> + td = (struct thread_lite *)curthread;
> + td->td_critnest++;
Don't we need a compiler barrier here?
> +}
> +
> +static __inline void
> +critical_exit(void)
> +{
> + struct thread_lite *td;
> +
> + td = (struct thread_lite *)curthread;
> + KASSERT(td->td_critnest != 0,
> + ("critical_exit: td_critnest == 0"));
> + td->td_critnest--;
> + __compiler_membar();
> + if (__predict_false(td->td_owepreempt))
> + critical_exit_preempt();
> +
> +}
> +#endif
> +
> +
> #ifdef EARLY_PRINTF
> typedef void early_putc_t(int ch);
> extern early_putc_t *early_putc;
>
More information about the svn-src-all
mailing list