From owner-freebsd-current@FreeBSD.ORG Wed Jun 4 02:01:40 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F2D8337B401; Wed, 4 Jun 2003 02:01:39 -0700 (PDT) Received: from herring.nlsystems.com (mailgate.nlsystems.com [62.49.251.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id CDBEA43F75; Wed, 4 Jun 2003 02:01:36 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from herring.nlsystems.com (herring.nlsystems.com [10.0.0.2]) by herring.nlsystems.com (8.12.9/8.12.8) with ESMTP id h54917RP039412; Wed, 4 Jun 2003 10:01:07 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: Paul Richards , "M. Warner Losh" Date: Wed, 4 Jun 2003 10:01:07 +0100 User-Agent: KMail/1.5 References: <26877.1054676171@critter.freebsd.dk> <20030603.160943.102571653.imp@bsdimp.com> <1054594801.1641.49.camel@cf.freebsd-services.com> In-Reply-To: <1054594801.1641.49.camel@cf.freebsd-services.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200306041001.07145.dfr@nlsystems.com> X-Spam-Status: No, hits=-26.1 required=6.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT version=2.50 X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) cc: phk@phk.freebsd.dk cc: dfr@freebsd.org cc: current@freebsd.org Subject: Re: VFS: C99 sparse format for struct vfsops X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2003 09:01:40 -0000 On Tuesday 03 June 2003 12:00 am, Paul Richards wrote: > On Tue, 2003-06-03 at 23:09, M. Warner Losh wrote: > > In message: <1054590840.1641.12.camel@cf.freebsd-services.com> > > > > Paul Richards writes: > > : The possible methods available in an interface are fixed, they're > > : defined in the .m files. > > > > No it isn't. One can add additional interfaces at any time without > > breaking binary compatibility, so you don't know, a priori, the > > number of methods in a given interface when you build a client of > > that interface. > > I don't think that's true. > > The interface is defined in the .m file and it's created using > makeobjs. You can't do that at runtime because it creates the > kobj_desc struct that uniquely represents the existence of that > method globally for the whole of the kobj subsystem. The set of all > kobj_desc defines all possible methods that can be implemented by an > object, and yes you can extend that interface later and previously > built modules will still work because they only implement a subset of > those possible methods, but the set of all methods that can exist is > determined at compile time from the interface definitions > > A class is then defined which specifies the set of methods that > objects instantiated into that class *can* implement (but are note > required to). The set of methods in a class is also fixed, since it's > basically the method table plus some class fields and the method > table is created at compile time. Again though, if you later extend > the class older compiled modules will still work because if the > method doesn't exist in that older module the default from the > kobj_desc will be used or the kobj_error_method will be called (which > is safe). > > So yes you can extend the interface and the class and keep backwards > compatibility but that all happens at compile time, and therefore at > runtime when the object is instantiated you know the maximum number > of methods that the object can possibly call. It is true, I'm afraid. A class is can implement any number of interfaces so knowing the compile-time size of an interface doesn't help you reserve space for a class. The system is intended to have a robust ABI so that e.g. a class implementing an interface can be used safely by a kernel in which new methods have been added to that interface. The class is a concrete definition of a set of methods (at this level, the interfaces are mostly ignored). Objects instantiated in that class use exactly that set of methods, no more, no less. There is no choice involved. You appear to be confusing class and interface here. This incarnation of kobj uses a smallish fixed-size method dispatch table, with hashing. A previous version (embedded into 4.x's newbus) allocated space in the method dispatch table for every interface which was currently resident in the kernel. This was fine when the expected number of interfaces was small but as the number of interfaces increases, the wasted space per-class increases unacceptably. This is the sole reason for changing the method-dispatch algorithm for kobj. The only valid objection to kobj at this point is that resolving hash collisions is not SMP safe. I believe that this is a limitation which can be overcome without pessimising the dispatch mechanism. Performance is not an issue. The performance of method dispatch in kobj is very slightly slower than a vtable-style array of function pointers but the difference is barely measurable. Given the behaviour of modern caches, it is possible to make nearly as many kobj method calls per second as normal function calls. -- Doug Rabson Mail: dfr@nlsystems.com Phone: +44 20 8348 6160