syscalls from loadable modules compiled in statically into the kernel
Mateusz Guzik
mjguzik at gmail.com
Sat Oct 25 13:20:44 UTC 2014
On Sat, Oct 25, 2014 at 12:22:34PM +0300, Konstantin Belousov wrote:
> On Sat, Oct 25, 2014 at 04:28:09AM +0200, Mateusz Guzik wrote:
> > The kernel has the following mechanism:
> >
> > int
> > syscall_thread_enter(struct thread *td, struct sysent *se)
> > {
> > u_int32_t cnt, oldcnt;
> >
> > do {
> > oldcnt = se->sy_thrcnt;
> > if ((oldcnt & SY_THR_STATIC) != 0)
> > return (0);
> > if ((oldcnt & (SY_THR_DRAINING | SY_THR_ABSENT)) != 0)
> > return (ENOSYS);
> > cnt = oldcnt + SY_THR_INCR;
> > } while (atomic_cmpset_acq_32(&se->sy_thrcnt, oldcnt, cnt) == 0);
> > return (0);
> > }
> >
> > Except it turns out that it is used even if given module (here: sysvshm) is
> > compiled in statically.
> >
> > So my proposal is to give modules an easy way to tell whether they got
> > compiled in and extend syscall_register interface so that it would allow
> > registering static syscalls.
> >
> > The latter could also be used by modules which are loadable, but don't
> > support unloads.
> >
> > I don't have any good idea how to provide aforementioned detection
> > method though.
> The method would be a combination of some change to syscall_register()
> and #ifdef KLD_MODULE. Look at the sys/conf.h MAKEDEV_ETERNAL_KLD
> definition, which provides similar in spirit optimization for
> non-destructable cdevs.
>
Ok, so I'll add sysctl_register_flags and SY_THR_STATIC_KLD + making
sure SY_THR_STATIC cannot be unregistered.
> >
> > Also, please see https://reviews.freebsd.org/D1007 which moves
> > SY_THR_STATIC check to an inline function, saving us 2 function calls on
> > each syscall.
>
> Did you benchmarked this ? I dislike the code bloat.
with syscall_timing from tools/tools ministat says +4% for getuid and +1
for pipe+close.
--
Mateusz Guzik <mjguzik gmail.com>
More information about the freebsd-arch
mailing list