From owner-freebsd-arch@FreeBSD.ORG Mon Sep 22 13:11:40 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4D27016A4B3 for ; Mon, 22 Sep 2003 13:11:40 -0700 (PDT) Received: from herring.nlsystems.com (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5E6743FE0 for ; Mon, 22 Sep 2003 13:11:38 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from [10.0.0.2] (herring.nlsystems.com [10.0.0.2]) by herring.nlsystems.com (8.12.9/8.12.8) with ESMTP id h8MKBMY9075986; Mon, 22 Sep 2003 21:11:22 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: "Justin T. Gibbs" In-Reply-To: <1423490000.1064260204@aslan.btc.adaptec.com> References: <1064221837.15078.14.camel@herring.nlsystems.com> <1423490000.1064260204@aslan.btc.adaptec.com> Content-Type: text/plain Message-Id: <1064261482.68463.13.camel@herring.nlsystems.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.0 Date: 22 Sep 2003 21:11:22 +0100 Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-4.9 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_XIMIAN version=2.55 X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: arch@freebsd.org Subject: Re: kobj multiple inheritance X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Sep 2003 20:11:40 -0000 On Mon, 2003-09-22 at 20:50, Justin T. Gibbs wrote: > > I believe that I have the kobj multiple inheritance changes about ready > > for committing now. I have locked up the class handling in kobj and I've > > re-done the method dispatch so that it is MP-safe without needing locks > > (I would appreciate a close look at that part by another pair of eyes). > > I've only just glanced at these patches, but I don't see how the > method cache is now MP safe. Aren't you still vulnerable to a cache > collision from two different threads performing an operation on the > same class? Thats the cunning part :-). The key is that the cache entries now point directly at the method structures instead of being copies of the structure. The main race condition theoretically present in the old code was that one thread could read a cache entry part way through that entry being updated by another thread. Since the cache entries are now simple pointers, that can't happen. The other main change is that kobj_lookup_method will return the method structure pointer as well as updating the cache entry. The caller only uses the pointer returned from kobj_lookup_method - this ensures that the correct method is called even if another thread re-writes the cache entry with a different value, e.g. if two methods hash to the same cache entry. For the more common case of two threads independantly looking up the same method, both will write the exact same value to the cache. > I still believe that the concept of inherited interfaces is better > way to achieve multiple inheritance. The methods I may want to > inherit need not be associated with what we currently call a device > class. The nice thing about your approach is that it doesn't require > a massive rototilling of the drivers, but I fear it doesn't go far > enough toward providing flexible inheritence. It was the mass rototilling which I wanted to avoid. It still seems like a pretty good thing to maintain some kind of API compatibility between FreeBSD 4, 5 and 6 and this method can support that. Your original scheme was 'single inheritance of multiple interfaces'. This patch can support that since you can derive from as many base classes as you like - each base class will be looked at if the previous class doesn't find a match.