Date: Sun, 8 Jul 2018 10:22:17 -0400 From: Mark Johnston <markj@freebsd.org> To: Matt Macy <mmacy@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r335879 - in head/sys: conf kern sys Message-ID: <20180708142210.GA18193@pesky> In-Reply-To: <201807030155.w631tARo009470@repo.freebsd.org> References: <201807030155.w631tARo009470@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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; >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180708142210.GA18193>