From owner-freebsd-arch@FreeBSD.ORG Sat Oct 25 09:22:40 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DE3E2398 for ; Sat, 25 Oct 2014 09:22:40 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53494B2A for ; Sat, 25 Oct 2014 09:22:40 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9P9MYre036967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 25 Oct 2014 12:22:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9P9MYre036967 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9P9MYKD036966; Sat, 25 Oct 2014 12:22:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 25 Oct 2014 12:22:34 +0300 From: Konstantin Belousov To: Mateusz Guzik Subject: Re: syscalls from loadable modules compiled in statically into the kernel Message-ID: <20141025092234.GI1877@kib.kiev.ua> References: <20141025022808.GA14551@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141025022808.GA14551@dft-labs.eu> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-arch@freebsd.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2014 09:22:41 -0000 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.