Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Oct 2014 12:22:34 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: syscalls from loadable modules compiled in statically into the kernel
Message-ID:  <20141025092234.GI1877@kib.kiev.ua>
In-Reply-To: <20141025022808.GA14551@dft-labs.eu>
References:  <20141025022808.GA14551@dft-labs.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141025092234.GI1877>