syscalls from loadable modules compiled in statically into the kernel

Konstantin Belousov kostikbel at gmail.com
Sat Oct 25 09:22:41 UTC 2014


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.

> 
> 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.


More information about the freebsd-arch mailing list