Re: kobj multiple inheritance

From: Justin T. Gibbs (gibbs_at_scsiguy.com)
Date: 09/23/03

  • Next message: M. Warner Losh: "Re: kobj multiple inheritance"
    Date: Mon, 22 Sep 2003 16:24:23 -0600
    To: Doug Rabson <dfr@nlsystems.com>
    
    

    >> The code assumes that pointer accesses are atomic, which I didn't
    >> think was guaranteed on all machines we support. That's why I didn't
    >> think it was safe.
    >
    > I think that we are guaranteed that a pointer read from a memory
    > location will be a whole copy of some value written to that location
    > (i.e. not a combination of part of one write with part of another) That
    > might not be true for bde's exotic i386/64bit long platform.

    Okay. That was my only concern. For some reason I thought that
    some early Sparc64 machines only enforced load/store atomicity on 16bit
    entities and that was only true with some platform specific magic.

    >> There were quite a few differences:
    >>
    >> 1) Inheritence was not limited to only inheriting from a base interface.
    >> The method lookup traversed all the way to the root.
    >
    > This proposed scheme also traverses through base classes of base classes
    > up to the roots.

    I see the recursion now.

    >> 4) The method cache was removed in favor of a direct indexing into
    >> the interface's static method table. Interface lookup was explicit,
    >> the hope being that one interface lookup could be amortized over
    >> multiple method calls. This would allow using kobj interfaces
    >> for more heavy weight tasks such as exporting the correct XPT
    >> interface in CAM to low-level drivers (FC, SPI, SATA, SAS, etc).
    >
    > Interface lookup using current kobj can be done expliticly. There is
    > nothing to say that you must call the generated inline function - you
    > can just as well call KOBJOPLOOKUP yourself e.g. if you need to call the
    > method a few hundred thousand times. Given that the amortised cost of
    > calling a kobj method is only about 20% slower than a direct function
    > call, this kind of thing should only be needed in extreme cases.

    The problem is not entirely that of speed. The cache is large even
    for classes that may only export or use a few methods. This also
    means that an active cache requires more than one cache line even
    if only a few methods are used repeatedly. Lastly, the lookup
    code is a bit large for an inline. All of this is fine for interfaces
    largely used for device configuration, but this makes the current
    scheme less interesting in, for example, a device driver's main code
    path.

    >> 5) I also planned to add a way to do "super" invocations. This would
    >> cut down on lots of the bloat in things like cardbus.
    >
    > I've been thinking a bit about that. In C++, the normal way is to
    > explicitly call the base method:
    >
    > void foo() {
    > do important stuff;
    > BaseClass::foo();
    > OtherBaseClass::foo();
    > }
    >
    > This version is easy and is what cardbus does now. You simply export the
    > function and call it directly. This is what happens for instance in
    > cardbus_read_ivar - it handles its own variables and then calls
    > pci_read_ivar for everything else.

    Yes. This is one of the sore points of C++. You shouldn't have to
    know where a method implementation resides in order to call it. It
    makes it difficult in add layers to a class or interface hierarchy
    since all consumers of a moved method must be updated.

    > It would be possible to do something with dynamic lookups using the ops
    > cache of the base class but I haven't thought of a way of presenting the
    > API which isn't messy.

    A method typically knows the interface that it belongs to. At interface
    compile time, super methods could be recorded into an alternate method
    table within the interface. This would allow chained super calls all the
    way to the root without having to explicitly walk interface pointers or do
    cache lookups. The only time you then need to massively update the code is
    if you move a method that makes use of the super feature to a different
    interface.

    >> Do you also have a proposal for handling ivar in the multiple-inheritance
    >> scheme? This is required to make multiple inheritance really useful.
    >
    > Off the top of my head, assign ranges to drivers at compile time in such
    > a way that the ivar indices of one driver are guaranteed to be different
    > from the indices of another driver. Requires a centralised registry but
    > we have one - the CVS repository would serve.

    This doesn't work well for binary only modules that create their own
    interfaces. Ivars should work even in this case. I also hope to avoid
    having large sparce ivar tables if possible. My current thought is
    to use variables for the ivar indexes within an interface so that any
    offsets needed to deal with parent interfaces can be made during interface
    registration. This becomes easier to deal with in the interface scheme
    since, with classes able to inherit from multiple interfaces, there is
    no need for interfaces to be polymorphic, so it is easy to determine how
    much space to allocate for the parent interface. The same scheme could
    be used for method table allocations.

    --
    Justin
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
    

  • Next message: M. Warner Losh: "Re: kobj multiple inheritance"

    Relevant Pages

    • Re: kobj multiple inheritance
      ... The kobj lookup scheme doesn't require any kind of locked memory ... >> This proposed scheme also traverses through base classes of base classes ... >> Interface lookup using current kobj can be done expliticly. ... The cache is large even ...
      (freebsd-arch)
    • Cisco 7204VXR Interface ignored packet
      ... see the configuration not just the show diag & interface info. ... 509K bytes of non-volatile configuration memory. ... 256 max cache size, 256 in cache ... 22496866 hits in cache, 0 misses in cache ...
      (comp.dcom.sys.cisco)
    • Re: [PATCH 08/28] SECURITY: Allow kernel services to override LSM settings for task actions [try #2]
      ... interface, at the granularity you want to support distinctions to be made. ... context and begin caching". ... Do any of the interfaces allow a task to act on a cache other than one ...
      (Linux-Kernel)
    • Generics mit "Zirkulärer Typreferenz"
      ... generischen Cache speichern. ... Interface implementieren: ... internal interface ICacheablewhere T: ... Über den Key wird das Objekt identifiziert, ...
      (microsoft.public.de.german.entwickler.dotnet.csharp)
    • Re: instanciate an interface - alternatives?
      ... > I know that it is not possible to instanciate an interface. ... It is not a matter of workarounds. ... > It shall look up if this object is stored in the cache, if not it shall> create it and automatically load its data:> ... > private Hashtable cache = new Hashtable; ...
      (comp.lang.java.programmer)

  • Quantcast