Re: [PATCH] get_nodes mask miscalculation

From: Brent Casavant (bcasavan_at_sgi.com)
Date: 08/10/04

  • Next message: David Woodhouse: "Re: PATCH: cdrecord: avoiding scsi device numbering for ide devices"
    Date:	Tue, 10 Aug 2004 09:54:08 -0500
    To: Andi Kleen <ak@muc.de>
    
    

    On Tue, 10 Aug 2004, Andi Kleen wrote:

    > The idea behind this is was to make it behave like select.
    > And select passes highest valid value + 1.

    Not that my opinion is worth much, but this seems a very peculiar
    interface to mimic.

    > In this case
    > valid value is not the highest bit number, but the length
    > of the bitmap.
    >
    > For some reason nobody except me seems to get it though,
    > probably because the description in the manpages is a bit confusing:
    >
    > get_mempolicy(2):
    >
    > "maxnode is the maximum bit number plus one that can be stored into
    > nodemask."

    Actually, I worked from the following description:

    mbind(3)
            . . .
            nodemask is a bit field of nodes that contains up to
            maxnode bits.
            . . .

    This very clearly indicates that I should pass the number of bits
    in the nodemask field, not the number of bits plus one.

    Granted, the man page makes it clear that I should use libnuma, but
    in this case I was working on implementing a new MPOL_ROUNDROBIN, and
    wanted to go directly to the system call for testing purposes.

    And not to make things even more confusing, but the way things are
    designed now, the value I need to pass to mbind() is numa_max_node()+2.
    Very confusing.

    > Problem is that you'll break all existing libnuma binaries
    > which pass NUMA_MAX_NODES + 1. In your scheme the kernel
    > will access one bit beyond the bitmap that got passed,
    > and depending on its random value you may get a failure or not.

    Well, again, not that my opinion carries much weight (nor really should
    it), but this whole off-by-one (or two) interface seems unnecessarily
    confusing. Is there no way we can get this fixed? The temporary pain
    of breaking the relatively new libnuma seems worth the price of getting
    this forever cleaned up.

    Brent

    -- 
    Brent Casavant             bcasavan@sgi.com        Forget bright-eyed and
    Operating System Engineer  http://www.sgi.com/     bushy-tailed; I'm red-
    Silicon Graphics, Inc.     44.8562N 93.1355W 860F  eyed and bushy-haired.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: David Woodhouse: "Re: PATCH: cdrecord: avoiding scsi device numbering for ide devices"

    Relevant Pages

    • Re: [PATCH] get_nodes mask miscalculation
      ... > Well, again, not that my opinion carries much weight (nor really should ... I'm just not sure it is worth it. ... don't find it that confusing, but I'm probably not a good benchmark ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Desired behaviour of "ifconfig -alias"
      ... But you called it "confusing". ... me, for example, and I would object for that syntax to go ... an interface are equal, just like hardlinks on a file. ... But when removing something without specifying which one, ...
      (freebsd-stable)
    • Re: Abstract Data Types - Separating Interface from Implementation
      ... >>You seem to be confusing implementation code and client code. ... I don't define any of the functions yet, I just declare them and compile ... Each such file defines an *interface*. ...
      (comp.lang.cpp)
    • Re: Is Class Synonymous with Type?
      ... I agree - if to do otherwise would be confusing. ... any more than this sentence is talking about defining "defining." ... meaning of "interface" to define a C# ...
      (microsoft.public.dotnet.languages.csharp)
    • Re:Linux sucks
      ... be less painful for dumbs like me.KDE Gnome are too confusing for ... BTW wats common with linux geeks is that u cud hardly find 2 of them ... I was all confused when deciding which dist and what interface to ... use.So now i use Gnome and KDE programmes! ...
      (Fedora)